@ls-stack/extended-lint 0.55.0 → 0.56.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/extended-lint.js +10 -7
- package/dist/extended-lint.mjs +10 -7
- package/package.json +11 -11
package/dist/extended-lint.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";var rr=Object.create;var ze=Object.defineProperty;var ir=Object.getOwnPropertyDescriptor;var sr=Object.getOwnPropertyNames;var or=Object.getPrototypeOf,ar=Object.prototype.hasOwnProperty;var lr=(e,t)=>{for(var r in t)ze(e,r,{get:t[r],enumerable:!0})},qt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of sr(t))!ar.call(e,o)&&o!==r&&ze(e,o,{get:()=>t[o],enumerable:!(n=ir(t,o))||n.enumerable});return e};var Re=(e,t,r)=>(r=e!=null?rr(or(e)):{},qt(t||!e||!e.__esModule?ze(r,"default",{value:e,enumerable:!0}):r,e)),pr=e=>qt(ze({},"__esModule",{value:!0}),e);var ns={};lr(ns,{extendedLintPlugin:()=>ts});module.exports=pr(ns);var Z=require("@typescript-eslint/utils");var tt=Symbol.for("optional");function $(e){return{...e,[tt]:!0}}function Jt(e,t){return{enum:e,...t}}function Fe(e){return{...e,type:"boolean"}}function H(e){return{...e,type:"string"}}function de(e){return{...e,type:"number"}}function ne(e,t){return{...t,type:"array",items:e}}function Y(e,t){let r={...t,type:"object",properties:e};if(e&&(r.additionalProperties||=!1,!r.required)){let n,o=[];for(n in e)e[n][tt]?e[n][tt]=void 0:o.push(n);o.length>0&&(r.required=o)}return r}var cr=Z.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Xt="react-compiler-extra",ur=Y({runOnlyWithEnableCompilerDirective:$(Fe())}),fr=/eslint +react-compiler\/react-compiler: +\["error/;function mr(e){return e.type===Z.AST_NODE_TYPES.Identifier?e.name.startsWith("use"):e.type===Z.AST_NODE_TYPES.MemberExpression&&e.property.type===Z.AST_NODE_TYPES.Identifier?e.property.name.startsWith("use"):!1}var dr=/\bthis[.[]/;function Bt(e){return dr.test(e)}var yr=cr({name:Xt,meta:{type:"suggestion",fixable:"code",docs:{description:"Extra rules to enforce best practices when using the React compiler"},messages:{objectMethodIsNotSupported:"Object methods such as `{ method() {} }` have limited support to optimizations in the React compiler, use a function expression `{ method: () => {} }` instead.",replaceWithFunctionExpression:"Replace with function expression",thisKeywordInMethod:"Object method uses `this` keyword which would have different behavior if converted to an arrow function. Fix this manually."},hasSuggestions:!0,schema:[ur]},defaultOptions:[{}],create(e,[t]){let r=!1;if(t.runOnlyWithEnableCompilerDirective){for(let a of e.sourceCode.getAllComments())if(fr.test(a.value)){r=!0;break}if(!r)return{}}function n(a){for(let i of a.properties)if(i.type===Z.AST_NODE_TYPES.Property&&i.method&&i.value.type===Z.AST_NODE_TYPES.FunctionExpression){let s=e.sourceCode,l=s.getText(i.key),p=i.value,c=s.getText(p.body);if(Bt(c))e.report({node:i,messageId:"thisKeywordInMethod"});else{let f=p.params.map(T=>s.getText(T)).join(", "),y="";p.generator?y=`${l}: function* (${f}) ${c}`:y=`${l}: (${f}) => ${c}`,e.report({node:i,messageId:"objectMethodIsNotSupported",fix:T=>T.replaceText(i,y)})}}}function o(a){for(let i of a.properties)if(i.type===Z.AST_NODE_TYPES.Property&&i.value.type===Z.AST_NODE_TYPES.ObjectExpression){for(let s of i.value.properties)if(s.type===Z.AST_NODE_TYPES.Property&&s.method&&s.value.type===Z.AST_NODE_TYPES.FunctionExpression){let p=e.sourceCode.getText(s.value.body);Bt(p)&&e.report({node:s,messageId:"thisKeywordInMethod"})}}}return{CallExpression(a){if(mr(a.callee))for(let i of a.arguments){if(i.type===Z.AST_NODE_TYPES.ObjectExpression&&(n(i),o(i)),i.type===Z.AST_NODE_TYPES.ArrowFunctionExpression&&(i.body.type===Z.AST_NODE_TYPES.ObjectExpression&&(n(i.body),o(i.body)),i.body.type===Z.AST_NODE_TYPES.BlockStatement))for(let s of i.body.body)s.type===Z.AST_NODE_TYPES.ReturnStatement&&s.argument?.type===Z.AST_NODE_TYPES.ObjectExpression&&(n(s.argument),o(s.argument));if(i.type===Z.AST_NODE_TYPES.FunctionExpression)for(let s of i.body.body)s.type===Z.AST_NODE_TYPES.ReturnStatement&&s.argument?.type===Z.AST_NODE_TYPES.ObjectExpression&&(n(s.argument),o(s.argument))}}}}}),nt={name:Xt,rule:yr};var re=require("@typescript-eslint/utils"),w=require("zod/v4");var Gt=require("@typescript-eslint/utils"),Kt=Re(require("zod/v4"));function G(e){let r=Gt.ESLintUtils.RuleCreator(n=>`https://github.com/lucasols/extended-lint#${n}`)(e);return{name:e.name,rule:r}}function Ie(e){return Kt.toJSONSchema(e)}var gr=w.z.object({disallow:w.z.array(w.z.object({selector:w.z.string(),message:w.z.string(),replace:w.z.optional(w.z.union([w.z.string(),w.z.object({regex:w.z.string(),with:w.z.string()})])),replaceType:w.z.optional(w.z.enum(["suggestion","autofix"]))})).optional(),disallowFnCalls:w.z.optional(w.z.array(w.z.object({fn:w.z.string(),withArgs:w.z.optional(w.z.array(w.z.object({atIndex:w.z.number(),value:w.z.union([w.z.string(),w.z.number(),w.z.boolean()])}))),message:w.z.string(),replaceWith:w.z.optional(w.z.string()),ignoreRegex:w.z.optional(w.z.string())}))),__dev_simulateFileName:w.z.optional(w.z.string()),mustMatchSyntax:w.z.optional(w.z.array(w.z.object({includeRegex:w.z.string(),mustCallFn:w.z.optional(w.z.array(w.z.object({anyCall:w.z.array(w.z.object({fn:w.z.string(),withArgs:w.z.array(w.z.object({atIndex:w.z.number(),literal:w.z.union([w.z.string(),w.z.number(),w.z.boolean()])}))})),message:w.z.optional(w.z.string())}))),mustMatchSelector:w.z.optional(w.z.array(w.z.object({selector:w.z.string(),message:w.z.string()}))),mustHaveExport:w.z.optional(w.z.array(w.z.object({name:w.z.string(),type:w.z.enum(["function","variable","any"]).default("any"),message:w.z.string()})))})))}),rt=G({name:"advanced-no-restricted-syntax",meta:{type:"suggestion",docs:{description:"Disallow specific syntax patterns"},schema:[Ie(gr)],messages:{default:"{{message}}"},fixable:"code",hasSuggestions:!0},defaultOptions:[{disallow:[]}],create(e,[t]){let r={},{mustMatchSyntax:n,__dev_simulateFileName:o,disallow:a,disallowFnCalls:i}=t,s=o??e.filename,l=[],p=new Map,c=new Set,f=new Map,y=new Set,T=new Map;function I(m){for(let S of m.specifiers)S.type===re.AST_NODE_TYPES.ImportSpecifier&&S.imported.type===re.AST_NODE_TYPES.Identifier&&S.imported.name!==S.local.name&&T.set(S.local.name,S.imported.name)}function b(m){if(m.declaration){if(m.declaration.type===re.AST_NODE_TYPES.FunctionDeclaration&&m.declaration.id){let S=m.declaration.id.name;for(let k of Array.from(y)){let[R,C]=k.split(":");R===S&&(C==="function"||C==="any")&&y.delete(k)}}else if(m.declaration.type===re.AST_NODE_TYPES.VariableDeclaration){for(let S of m.declaration.declarations)if(S.id.type===re.AST_NODE_TYPES.Identifier){let k=S.id.name;for(let R of Array.from(y)){let[C,N]=R.split(":");C===k&&(N==="variable"||N==="any")&&y.delete(R)}}}}for(let S of m.specifiers)if(S.exported.type===re.AST_NODE_TYPES.Identifier){let k=S.exported.name;for(let R of Array.from(y)){let[C,N]=R.split(":");C===k&&N==="any"&&y.delete(R)}}}function E(m){m.id.type===re.AST_NODE_TYPES.Identifier&&m.init?.type===re.AST_NODE_TYPES.Identifier&&T.set(m.id.name,m.init.name)}function u(m){return T.get(m)??m}function A(m,S){return u(m)===S||m===S}for(let{includeRegex:m,mustCallFn:S,mustMatchSelector:k,mustHaveExport:R}of n??[]){let C=Sr(s,new RegExp(m));if(!C)continue;let N=z=>{let B=z;for(let{name:K,value:ee}of C)B=B.replaceAll(K,ee);return B};for(let{anyCall:z,message:B}of S??[]){let K=`Expected file to call the function: ${z.map(({fn:ee})=>ee).join(" or ")}`;c.add(K),l.push(ee=>{let{callee:be}=ee;if(be.type===re.AST_NODE_TYPES.Identifier){for(let{fn:te,withArgs:De}of z)if(be.name===te){c.delete(K);for(let ge of De){let me=ee.arguments[ge.atIndex],Se=typeof ge.literal=="string"?N(ge.literal):ge.literal;if(!me){e.report({node:ee,messageId:"default",data:{message:`Missing argument with value "${Se}" at index ${ge.atIndex}${B?`: ${N(B)}`:""}`}});continue}if(me.type!==re.AST_NODE_TYPES.Literal){e.report({node:me,messageId:"default",data:{message:`Argument at position ${ge.atIndex} should the literal "${Se}"${B?`: ${N(B)}`:""}`}});continue}me.value!==Se&&e.report({node:me,messageId:"default",data:{message:`Argument should have the value "${Se}"${B?`: ${N(B)}`:""}`},fix:Pe=>Pe.replaceText(me,typeof Se=="string"?`'${Se}'`:String(Se))})}break}}})}for(let{selector:z,message:B}of k??[])f.set(z,N(B)),p.set(N(z),()=>{f.delete(z)});for(let{name:z,type:B,message:K}of R??[]){let ee=N(z),be=N(K);y.add(`${ee}:${B}:${be}`)}}for(let{fn:m,withArgs:S,message:k,replaceWith:R,ignoreRegex:C}of i??[])C&&new RegExp(C).test(s)||l.push(N=>{let{callee:z}=N;if(z.type!==re.AST_NODE_TYPES.Identifier||!A(z.name,m))return;if(S)for(let K of S){let ee=N.arguments[K.atIndex];if(!ee){e.report({node:N,messageId:"default",data:{message:`Missing argument with value "${K.value}" at index ${K.atIndex}: ${k}`}});return}if(ee.type!==re.AST_NODE_TYPES.Literal||ee.value!==K.value)return}let B=K=>R?K.replaceText(N,R):null;e.report({node:N,messageId:"default",data:{message:k},suggest:R?[{messageId:"default",data:{message:`Replace with "${R}"`},fix:B}]:void 0})});function x(m,S){let k=r[m];k?r[m]=R=>{k(R),S(R)}:r[m]=S}for(let{selector:m,message:S,replace:k,replaceType:R="suggestion"}of a??[]){if(m==="CallExpression"){l.push(C=>{g(k,C,S,R)});continue}r[m]=C=>{g(k,C,S,R)}}if(p.size>0)for(let[m,S]of p)x(m,S);return l.length>0&&(r.CallExpression=m=>{if(m.type===re.AST_NODE_TYPES.CallExpression)for(let S of l)S(m)}),r.ImportDeclaration=m=>{m.type===re.AST_NODE_TYPES.ImportDeclaration&&I(m)},r.ExportNamedDeclaration=m=>{m.type===re.AST_NODE_TYPES.ExportNamedDeclaration&&b(m)},r.VariableDeclarator=m=>{m.type===re.AST_NODE_TYPES.VariableDeclarator&&E(m)},r["Program:exit"]=m=>{for(let S of c)e.report({node:m,messageId:"default",data:{message:S}});for(let[,S]of f)e.report({node:m,messageId:"default",data:{message:S}});for(let S of y){let[k,R,C]=S.split(":");e.report({node:m,messageId:"default",data:{message:`Missing required export "${k}" of type ${R}: ${C}`}})}},r;function g(m,S,k,R){let C=N=>{if(!m)return null;if(typeof m=="string")return N.replaceText(S,m);{let z=new RegExp(m.regex),B=e.sourceCode.getText(S);return N.replaceText(S,B.replace(z,m.with))}};e.report({node:S,messageId:"default",data:{message:k},fix:m&&R==="autofix"?C:void 0,suggest:m&&R==="suggestion"?[{messageId:"default",data:{message:`Replace with "${typeof m=="string"?m:m.with}"`},fix:C}]:void 0})}}});function Sr(e,t){let r=[],n=t.exec(e);if(!n)return null;let[o,...a]=n;r.push({name:"$0_lowercase",value:o.toLowerCase()}),r.push({name:"$0_capitalize",value:Zt(o)}),r.push({name:"$0_uncapitalize",value:Qt(o)}),r.push({name:"$0",value:o});for(let i=0;i<a.length;i++){let s=`$${i+1}`,l=a[i];r.push({name:`${s}_lowercase`,value:l.toLowerCase()}),r.push({name:`${s}_capitalize`,value:Zt(l)}),r.push({name:`${s}_uncapitalize`,value:Qt(l)}),r.push({name:s,value:l})}return r}function Zt(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Qt(e){return e.charAt(0).toLowerCase()+e.slice(1)}var _=require("@typescript-eslint/utils");var Tr=_.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),tn="collapse-simple-objs-in-one-line",hr=Y({maxLineLength:$(de()),maxProperties:$(de()),nestedObjMaxLineLength:$(de()),nestedObjMaxProperties:$(de()),ignoreTypesWithSuffix:$(ne(H()))}),Er=Tr({name:tn,meta:{type:"suggestion",fixable:"code",docs:{description:"Format simple objects and types in one line"},messages:{singleLineProp:"Object/type should be written in a single line"},schema:[hr]},defaultOptions:[{}],create(e,[t]){let r=e.sourceCode,n=t.ignoreTypesWithSuffix??[],o=t.maxProperties??2,a=t.nestedObjMaxLineLength??t.maxLineLength,i=t.nestedObjMaxProperties??3;function s(p){if(p.type===_.AST_NODE_TYPES.ObjectExpression){let c=p.parent.type===_.AST_NODE_TYPES.Property,f=c?i:o,y=p.properties.length;if(y>f)return!1;if(y===1){let I=p.properties[0];return I.type===_.AST_NODE_TYPES.Property&&I.value.type===_.AST_NODE_TYPES.ObjectExpression||I.type===_.AST_NODE_TYPES.Property&&I.value.type===_.AST_NODE_TYPES.ArrayExpression&&!I.value.elements.every(E=>E&&it(E))?!1:{text:r.getText(I),isNested:c,propsSize:y}}let T=[];for(let I of p.properties){if(I.type===_.AST_NODE_TYPES.Property&&!it(I.value))return!1;T.push(r.getText(I))}return{text:T.join(", "),isNested:c,propsSize:y}}else{let c=p.parent.parent?.type===_.AST_NODE_TYPES.TSPropertySignature,f=c?i:o,y=p.members.length;if(y>f)return!1;if(n.length>0&&p.parent.type===_.AST_NODE_TYPES.TSTypeAliasDeclaration){let I=p.parent.id.name;if(n.some(b=>I.endsWith(b)))return!1}if(y===1){let I=p.members[0];return I.type===_.AST_NODE_TYPES.TSPropertySignature&&I.typeAnnotation?.typeAnnotation.type===_.AST_NODE_TYPES.TSTypeLiteral?!1:{text:r.getText(I),isNested:c,propsSize:1}}if(p.parent.type===_.AST_NODE_TYPES.TSIntersectionType||p.parent.type===_.AST_NODE_TYPES.TSUnionType&&p.parent.types[0]!==p)return!1;let T=[];for(let I of p.members){if(I.type!==_.AST_NODE_TYPES.TSPropertySignature)return!1;let b=I.typeAnnotation?.typeAnnotation;if(!b||b.type===_.AST_NODE_TYPES.TSTypeLiteral||!en(b))return!1;if(b.type===_.AST_NODE_TYPES.TSTypeReference&&b.typeArguments){if(b.typeArguments.params.length>1)return!1;let u=b.typeArguments.params[0];if(!en(u))return!1}let E=r.getText(I).trim();(E.endsWith(";")||E.endsWith(","))&&(E=E.slice(0,-1)),T.push(E)}return{text:T.join("; "),isNested:c,propsSize:y}}}function l(p){if(p.loc.start.line===p.loc.end.line)return;if(p.parent.type!==_.AST_NODE_TYPES.JSXExpressionContainer){let b=0,E=!1,u=r.getTokenAfter(p,{filter:x=>x.type!==_.AST_TOKEN_TYPES.Punctuator||E?!0:x.value===","?(b++,!1):x.value===";"?(b++,E=!0,!1):x.value===")"||x.value==="}"?(b++,!1):!0});if(b>4)return;let A=u?.type===_.AST_TOKEN_TYPES.Template&&u.value.startsWith(`}
|
|
1
|
+
"use strict";var rr=Object.create;var ze=Object.defineProperty;var ir=Object.getOwnPropertyDescriptor;var sr=Object.getOwnPropertyNames;var or=Object.getPrototypeOf,ar=Object.prototype.hasOwnProperty;var lr=(e,t)=>{for(var r in t)ze(e,r,{get:t[r],enumerable:!0})},qt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of sr(t))!ar.call(e,o)&&o!==r&&ze(e,o,{get:()=>t[o],enumerable:!(n=ir(t,o))||n.enumerable});return e};var ve=(e,t,r)=>(r=e!=null?rr(or(e)):{},qt(t||!e||!e.__esModule?ze(r,"default",{value:e,enumerable:!0}):r,e)),pr=e=>qt(ze({},"__esModule",{value:!0}),e);var ns={};lr(ns,{extendedLintPlugin:()=>ts});module.exports=pr(ns);var Z=require("@typescript-eslint/utils");var tt=Symbol.for("optional");function $(e){return{...e,[tt]:!0}}function Jt(e,t){return{enum:e,...t}}function Ne(e){return{...e,type:"boolean"}}function H(e){return{...e,type:"string"}}function ge(e){return{...e,type:"number"}}function te(e,t){return{...t,type:"array",items:e}}function Y(e,t){let r={...t,type:"object",properties:e};if(e&&(r.additionalProperties||=!1,!r.required)){let n,o=[];for(n in e)e[n][tt]?e[n][tt]=void 0:o.push(n);o.length>0&&(r.required=o)}return r}var cr=Z.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Xt="react-compiler-extra",ur=Y({runOnlyWithEnableCompilerDirective:$(Ne())}),fr=/eslint +react-compiler\/react-compiler: +\["error/;function mr(e){return e.type===Z.AST_NODE_TYPES.Identifier?e.name.startsWith("use"):e.type===Z.AST_NODE_TYPES.MemberExpression&&e.property.type===Z.AST_NODE_TYPES.Identifier?e.property.name.startsWith("use"):!1}var dr=/\bthis[.[]/;function Bt(e){return dr.test(e)}var yr=cr({name:Xt,meta:{type:"suggestion",fixable:"code",docs:{description:"Extra rules to enforce best practices when using the React compiler"},messages:{objectMethodIsNotSupported:"Object methods such as `{ method() {} }` have limited support to optimizations in the React compiler, use a function expression `{ method: () => {} }` instead.",replaceWithFunctionExpression:"Replace with function expression",thisKeywordInMethod:"Object method uses `this` keyword which would have different behavior if converted to an arrow function. Fix this manually."},hasSuggestions:!0,schema:[ur]},defaultOptions:[{}],create(e,[t]){let r=!1;if(t.runOnlyWithEnableCompilerDirective){for(let a of e.sourceCode.getAllComments())if(fr.test(a.value)){r=!0;break}if(!r)return{}}function n(a){for(let i of a.properties)if(i.type===Z.AST_NODE_TYPES.Property&&i.method&&i.value.type===Z.AST_NODE_TYPES.FunctionExpression){let s=e.sourceCode,l=s.getText(i.key),p=i.value,c=s.getText(p.body);if(Bt(c))e.report({node:i,messageId:"thisKeywordInMethod"});else{let f=p.params.map(T=>s.getText(T)).join(", "),y="";p.generator?y=`${l}: function* (${f}) ${c}`:y=`${l}: (${f}) => ${c}`,e.report({node:i,messageId:"objectMethodIsNotSupported",fix:T=>T.replaceText(i,y)})}}}function o(a){for(let i of a.properties)if(i.type===Z.AST_NODE_TYPES.Property&&i.value.type===Z.AST_NODE_TYPES.ObjectExpression){for(let s of i.value.properties)if(s.type===Z.AST_NODE_TYPES.Property&&s.method&&s.value.type===Z.AST_NODE_TYPES.FunctionExpression){let p=e.sourceCode.getText(s.value.body);Bt(p)&&e.report({node:s,messageId:"thisKeywordInMethod"})}}}return{CallExpression(a){if(mr(a.callee))for(let i of a.arguments){if(i.type===Z.AST_NODE_TYPES.ObjectExpression&&(n(i),o(i)),i.type===Z.AST_NODE_TYPES.ArrowFunctionExpression&&(i.body.type===Z.AST_NODE_TYPES.ObjectExpression&&(n(i.body),o(i.body)),i.body.type===Z.AST_NODE_TYPES.BlockStatement))for(let s of i.body.body)s.type===Z.AST_NODE_TYPES.ReturnStatement&&s.argument?.type===Z.AST_NODE_TYPES.ObjectExpression&&(n(s.argument),o(s.argument));if(i.type===Z.AST_NODE_TYPES.FunctionExpression)for(let s of i.body.body)s.type===Z.AST_NODE_TYPES.ReturnStatement&&s.argument?.type===Z.AST_NODE_TYPES.ObjectExpression&&(n(s.argument),o(s.argument))}}}}}),nt={name:Xt,rule:yr};var re=require("@typescript-eslint/utils"),w=require("zod/v4");var Gt=require("@typescript-eslint/utils"),Kt=ve(require("zod/v4"));function K(e){let r=Gt.ESLintUtils.RuleCreator(n=>`https://github.com/lucasols/extended-lint#${n}`)(e);return{name:e.name,rule:r}}function Ce(e){return Kt.toJSONSchema(e)}var gr=w.z.object({disallow:w.z.array(w.z.object({selector:w.z.string(),message:w.z.string(),replace:w.z.optional(w.z.union([w.z.string(),w.z.object({regex:w.z.string(),with:w.z.string()})])),replaceType:w.z.optional(w.z.enum(["suggestion","autofix"]))})).optional(),disallowFnCalls:w.z.optional(w.z.array(w.z.object({fn:w.z.string(),withArgs:w.z.optional(w.z.array(w.z.object({atIndex:w.z.number(),value:w.z.union([w.z.string(),w.z.number(),w.z.boolean()])}))),message:w.z.string(),replaceWith:w.z.optional(w.z.string()),ignoreRegex:w.z.optional(w.z.string())}))),__dev_simulateFileName:w.z.optional(w.z.string()),mustMatchSyntax:w.z.optional(w.z.array(w.z.object({includeRegex:w.z.string(),mustCallFn:w.z.optional(w.z.array(w.z.object({anyCall:w.z.array(w.z.object({fn:w.z.string(),withArgs:w.z.array(w.z.object({atIndex:w.z.number(),literal:w.z.union([w.z.string(),w.z.number(),w.z.boolean()])}))})),message:w.z.optional(w.z.string())}))),mustMatchSelector:w.z.optional(w.z.array(w.z.object({selector:w.z.string(),message:w.z.string()}))),mustHaveExport:w.z.optional(w.z.array(w.z.object({name:w.z.string(),type:w.z.enum(["function","variable","any"]).default("any"),message:w.z.string()})))})))}),rt=K({name:"advanced-no-restricted-syntax",meta:{type:"suggestion",docs:{description:"Disallow specific syntax patterns"},schema:[Ce(gr)],messages:{default:"{{message}}"},fixable:"code",hasSuggestions:!0},defaultOptions:[{disallow:[]}],create(e,[t]){let r={},{mustMatchSyntax:n,__dev_simulateFileName:o,disallow:a,disallowFnCalls:i}=t,s=o??e.filename,l=[],p=new Map,c=new Set,f=new Map,y=new Set,T=new Map;function I(m){for(let S of m.specifiers)S.type===re.AST_NODE_TYPES.ImportSpecifier&&S.imported.type===re.AST_NODE_TYPES.Identifier&&S.imported.name!==S.local.name&&T.set(S.local.name,S.imported.name)}function x(m){if(m.declaration){if(m.declaration.type===re.AST_NODE_TYPES.FunctionDeclaration&&m.declaration.id){let S=m.declaration.id.name;for(let k of Array.from(y)){let[R,C]=k.split(":");R===S&&(C==="function"||C==="any")&&y.delete(k)}}else if(m.declaration.type===re.AST_NODE_TYPES.VariableDeclaration){for(let S of m.declaration.declarations)if(S.id.type===re.AST_NODE_TYPES.Identifier){let k=S.id.name;for(let R of Array.from(y)){let[C,N]=R.split(":");C===k&&(N==="variable"||N==="any")&&y.delete(R)}}}}for(let S of m.specifiers)if(S.exported.type===re.AST_NODE_TYPES.Identifier){let k=S.exported.name;for(let R of Array.from(y)){let[C,N]=R.split(":");C===k&&N==="any"&&y.delete(R)}}}function E(m){m.id.type===re.AST_NODE_TYPES.Identifier&&m.init?.type===re.AST_NODE_TYPES.Identifier&&T.set(m.id.name,m.init.name)}function u(m){return T.get(m)??m}function A(m,S){return u(m)===S||m===S}for(let{includeRegex:m,mustCallFn:S,mustMatchSelector:k,mustHaveExport:R}of n??[]){let C=Sr(s,new RegExp(m));if(!C)continue;let N=z=>{let B=z;for(let{name:ne,value:ee}of C)B=B.replaceAll(ne,ee);return B};for(let{anyCall:z,message:B}of S??[]){let ne=`Expected file to call the function: ${z.map(({fn:ee})=>ee).join(" or ")}`;c.add(ne),l.push(ee=>{let{callee:xe}=ee;if(xe.type===re.AST_NODE_TYPES.Identifier){for(let{fn:X,withArgs:ye}of z)if(xe.name===X){c.delete(ne);for(let fe of ye){let se=ee.arguments[fe.atIndex],Te=typeof fe.literal=="string"?N(fe.literal):fe.literal;if(!se){e.report({node:ee,messageId:"default",data:{message:`Missing argument with value "${Te}" at index ${fe.atIndex}${B?`: ${N(B)}`:""}`}});continue}if(se.type!==re.AST_NODE_TYPES.Literal){e.report({node:se,messageId:"default",data:{message:`Argument at position ${fe.atIndex} should the literal "${Te}"${B?`: ${N(B)}`:""}`}});continue}se.value!==Te&&e.report({node:se,messageId:"default",data:{message:`Argument should have the value "${Te}"${B?`: ${N(B)}`:""}`},fix:Fe=>Fe.replaceText(se,typeof Te=="string"?`'${Te}'`:String(Te))})}break}}})}for(let{selector:z,message:B}of k??[])f.set(z,N(B)),p.set(N(z),()=>{f.delete(z)});for(let{name:z,type:B,message:ne}of R??[]){let ee=N(z),xe=N(ne);y.add(`${ee}:${B}:${xe}`)}}for(let{fn:m,withArgs:S,message:k,replaceWith:R,ignoreRegex:C}of i??[])C&&new RegExp(C).test(s)||l.push(N=>{let{callee:z}=N;if(z.type!==re.AST_NODE_TYPES.Identifier||!A(z.name,m))return;if(S)for(let ne of S){let ee=N.arguments[ne.atIndex];if(!ee){e.report({node:N,messageId:"default",data:{message:`Missing argument with value "${ne.value}" at index ${ne.atIndex}: ${k}`}});return}if(ee.type!==re.AST_NODE_TYPES.Literal||ee.value!==ne.value)return}let B=ne=>R?ne.replaceText(N,R):null;e.report({node:N,messageId:"default",data:{message:k},suggest:R?[{messageId:"default",data:{message:`Replace with "${R}"`},fix:B}]:void 0})});function b(m,S){let k=r[m];k?r[m]=R=>{k(R),S(R)}:r[m]=S}for(let{selector:m,message:S,replace:k,replaceType:R="suggestion"}of a??[]){if(m==="CallExpression"){l.push(C=>{g(k,C,S,R)});continue}r[m]=C=>{g(k,C,S,R)}}if(p.size>0)for(let[m,S]of p)b(m,S);return l.length>0&&(r.CallExpression=m=>{if(m.type===re.AST_NODE_TYPES.CallExpression)for(let S of l)S(m)}),r.ImportDeclaration=m=>{m.type===re.AST_NODE_TYPES.ImportDeclaration&&I(m)},r.ExportNamedDeclaration=m=>{m.type===re.AST_NODE_TYPES.ExportNamedDeclaration&&x(m)},r.VariableDeclarator=m=>{m.type===re.AST_NODE_TYPES.VariableDeclarator&&E(m)},r["Program:exit"]=m=>{for(let S of c)e.report({node:m,messageId:"default",data:{message:S}});for(let[,S]of f)e.report({node:m,messageId:"default",data:{message:S}});for(let S of y){let[k,R,C]=S.split(":");e.report({node:m,messageId:"default",data:{message:`Missing required export "${k}" of type ${R}: ${C}`}})}},r;function g(m,S,k,R){let C=N=>{if(!m)return null;if(typeof m=="string")return N.replaceText(S,m);{let z=new RegExp(m.regex),B=e.sourceCode.getText(S);return N.replaceText(S,B.replace(z,m.with))}};e.report({node:S,messageId:"default",data:{message:k},fix:m&&R==="autofix"?C:void 0,suggest:m&&R==="suggestion"?[{messageId:"default",data:{message:`Replace with "${typeof m=="string"?m:m.with}"`},fix:C}]:void 0})}}});function Sr(e,t){let r=[],n=t.exec(e);if(!n)return null;let[o,...a]=n;r.push({name:"$0_lowercase",value:o.toLowerCase()}),r.push({name:"$0_capitalize",value:Zt(o)}),r.push({name:"$0_uncapitalize",value:Qt(o)}),r.push({name:"$0",value:o});for(let i=0;i<a.length;i++){let s=`$${i+1}`,l=a[i];r.push({name:`${s}_lowercase`,value:l.toLowerCase()}),r.push({name:`${s}_capitalize`,value:Zt(l)}),r.push({name:`${s}_uncapitalize`,value:Qt(l)}),r.push({name:s,value:l})}return r}function Zt(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Qt(e){return e.charAt(0).toLowerCase()+e.slice(1)}var _=require("@typescript-eslint/utils");var Tr=_.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),tn="collapse-simple-objs-in-one-line",hr=Y({maxLineLength:$(ge()),maxProperties:$(ge()),nestedObjMaxLineLength:$(ge()),nestedObjMaxProperties:$(ge()),ignoreTypesWithSuffix:$(te(H()))}),Er=Tr({name:tn,meta:{type:"suggestion",fixable:"code",docs:{description:"Format simple objects and types in one line"},messages:{singleLineProp:"Object/type should be written in a single line"},schema:[hr]},defaultOptions:[{}],create(e,[t]){let r=e.sourceCode,n=t.ignoreTypesWithSuffix??[],o=t.maxProperties??2,a=t.nestedObjMaxLineLength??t.maxLineLength,i=t.nestedObjMaxProperties??3;function s(p){if(p.type===_.AST_NODE_TYPES.ObjectExpression){let c=p.parent.type===_.AST_NODE_TYPES.Property,f=c?i:o,y=p.properties.length;if(y>f)return!1;if(y===1){let I=p.properties[0];return I.type===_.AST_NODE_TYPES.Property&&I.value.type===_.AST_NODE_TYPES.ObjectExpression||I.type===_.AST_NODE_TYPES.Property&&I.value.type===_.AST_NODE_TYPES.ArrayExpression&&!I.value.elements.every(E=>E&&it(E))?!1:{text:r.getText(I),isNested:c,propsSize:y}}let T=[];for(let I of p.properties){if(I.type===_.AST_NODE_TYPES.Property&&!it(I.value))return!1;T.push(r.getText(I))}return{text:T.join(", "),isNested:c,propsSize:y}}else{let c=p.parent.parent?.type===_.AST_NODE_TYPES.TSPropertySignature,f=c?i:o,y=p.members.length;if(y>f)return!1;if(n.length>0&&p.parent.type===_.AST_NODE_TYPES.TSTypeAliasDeclaration){let I=p.parent.id.name;if(n.some(x=>I.endsWith(x)))return!1}if(y===1){let I=p.members[0];return I.type===_.AST_NODE_TYPES.TSPropertySignature&&I.typeAnnotation?.typeAnnotation.type===_.AST_NODE_TYPES.TSTypeLiteral?!1:{text:r.getText(I),isNested:c,propsSize:1}}if(p.parent.type===_.AST_NODE_TYPES.TSIntersectionType||p.parent.type===_.AST_NODE_TYPES.TSUnionType&&p.parent.types[0]!==p)return!1;let T=[];for(let I of p.members){if(I.type!==_.AST_NODE_TYPES.TSPropertySignature)return!1;let x=I.typeAnnotation?.typeAnnotation;if(!x||x.type===_.AST_NODE_TYPES.TSTypeLiteral||!en(x))return!1;if(x.type===_.AST_NODE_TYPES.TSTypeReference&&x.typeArguments){if(x.typeArguments.params.length>1)return!1;let u=x.typeArguments.params[0];if(!en(u))return!1}let E=r.getText(I).trim();(E.endsWith(";")||E.endsWith(","))&&(E=E.slice(0,-1)),T.push(E)}return{text:T.join("; "),isNested:c,propsSize:y}}}function l(p){if(p.loc.start.line===p.loc.end.line)return;if(p.parent.type!==_.AST_NODE_TYPES.JSXExpressionContainer){let x=0,E=!1,u=r.getTokenAfter(p,{filter:b=>b.type!==_.AST_TOKEN_TYPES.Punctuator||E?!0:b.value===","?(x++,!1):b.value===";"?(x++,E=!0,!1):b.value===")"||b.value==="}"?(x++,!1):!0});if(x>4)return;let A=u?.type===_.AST_TOKEN_TYPES.Template&&u.value.startsWith(`}
|
|
2
2
|
`);if(u?.loc.start.line===p.loc.end.line&&!A)return}let c=s(p);if(!c)return;let f=c.text;if(f.includes(`
|
|
3
|
-
`)||r.getCommentsInside(p).length>0)return;f.endsWith(";")&&(f=f.slice(0,-1));let y=`{ ${f} }`,T=xr(r,p),I=c.isNested&&c.propsSize>2?a:t.maxLineLength;I&&y.length+T.length+br(p,r)>I||e.report({node:p,messageId:"singleLineProp",fix:
|
|
4
|
-
`,r.range[1]);return(n!==-1?n:t.text.length)-r.range[1]}function xr(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}var st={name:tn,rule:Er};var Ir=/eslint +react-compiler\/react-compiler: +\["error/,rn={meta:{type:"suggestion",docs:{description:"verifies the list of dependencies for Hooks like useEffect and similar",recommended:!0,url:"https://github.com/facebook/react/issues/14920"},fixable:"code",hasSuggestions:!0,schema:[{type:"object",additionalProperties:!1,ignoreIfReactCompilerIsEnabled:!1,enableDangerousAutofixThisMayCauseInfiniteLoops:!1,properties:{additionalHooks:{type:"string"},ignoreIfReactCompilerIsEnabled:{type:"boolean"},enableDangerousAutofixThisMayCauseInfiniteLoops:{type:"boolean"}}}]},create(e){let t=!1,r=typeof e.getSource=="function"?u=>r(u):u=>e.sourceCode.getText(u),n=typeof e.getScope=="function"?()=>n():u=>e.sourceCode.getScope(u),o=e.options&&e.options[0]&&e.options[0].additionalHooks?new RegExp(e.options[0].additionalHooks):void 0,a=e.options&&e.options[0]&&e.options[0].enableDangerousAutofixThisMayCauseInfiniteLoops||!1,i={additionalHooks:o,enableDangerousAutofixThisMayCauseInfiniteLoops:a};function s(u){a&&Array.isArray(u.suggest)&&u.suggest.length>0&&(u.fix=u.suggest[0].fix),e.report(u)}let l=e.getSourceCode().scopeManager,p=new WeakMap,c=new WeakSet,f=new WeakMap,y=new WeakMap,T=new WeakSet;function I(u,A){return function(
|
|
3
|
+
`)||r.getCommentsInside(p).length>0)return;f.endsWith(";")&&(f=f.slice(0,-1));let y=`{ ${f} }`,T=xr(r,p),I=c.isNested&&c.propsSize>2?a:t.maxLineLength;I&&y.length+T.length+br(p,r)>I||e.report({node:p,messageId:"singleLineProp",fix:x=>x.replaceText(p,y)})}return{TSTypeLiteral:l,ObjectExpression:l}}});function en(e){return e.type===_.AST_NODE_TYPES.TSLiteralType||e.type===_.AST_NODE_TYPES.TSTypeReference||e.type===_.AST_NODE_TYPES.TSNumberKeyword||e.type===_.AST_NODE_TYPES.TSStringKeyword||e.type===_.AST_NODE_TYPES.TSBooleanKeyword||e.type===_.AST_NODE_TYPES.TSNullKeyword||e.type===_.AST_NODE_TYPES.TSUndefinedKeyword}function it(e,t){return!!(e.type===_.AST_NODE_TYPES.Literal||e.type===_.AST_NODE_TYPES.Identifier||e.type===_.AST_NODE_TYPES.TemplateLiteral||e.type===_.AST_NODE_TYPES.TaggedTemplateExpression||!t&&e.type===_.AST_NODE_TYPES.ArrayExpression&&e.elements.every(r=>r&&it(r,!0)))}function br(e,t){let r=t.getLastToken(e);if(!r)return 0;let n=t.text.indexOf(`
|
|
4
|
+
`,r.range[1]);return(n!==-1?n:t.text.length)-r.range[1]}function xr(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}var st={name:tn,rule:Er};var Ir=/eslint +react-compiler\/react-compiler: +\["error/,rn={meta:{type:"suggestion",docs:{description:"verifies the list of dependencies for Hooks like useEffect and similar",recommended:!0,url:"https://github.com/facebook/react/issues/14920"},fixable:"code",hasSuggestions:!0,schema:[{type:"object",additionalProperties:!1,ignoreIfReactCompilerIsEnabled:!1,enableDangerousAutofixThisMayCauseInfiniteLoops:!1,properties:{additionalHooks:{type:"string"},ignoreIfReactCompilerIsEnabled:{type:"boolean"},enableDangerousAutofixThisMayCauseInfiniteLoops:{type:"boolean"}}}]},create(e){let t=!1,r=typeof e.getSource=="function"?u=>r(u):u=>e.sourceCode.getText(u),n=typeof e.getScope=="function"?()=>n():u=>e.sourceCode.getScope(u),o=e.options&&e.options[0]&&e.options[0].additionalHooks?new RegExp(e.options[0].additionalHooks):void 0,a=e.options&&e.options[0]&&e.options[0].enableDangerousAutofixThisMayCauseInfiniteLoops||!1,i={additionalHooks:o,enableDangerousAutofixThisMayCauseInfiniteLoops:a};function s(u){a&&Array.isArray(u.suggest)&&u.suggest.length>0&&(u.fix=u.suggest[0].fix),e.report(u)}let l=e.getSourceCode().scopeManager,p=new WeakMap,c=new WeakSet,f=new WeakMap,y=new WeakMap,T=new WeakSet;function I(u,A){return function(b){if(A.has(b))return A.get(b);let g=u(b);return A.set(b,g),g}}function x(u,A,b,g,m){m&&u.async&&s({node:u,message:`Effect callbacks are synchronous to prevent race conditions. Put the async function inside:
|
|
5
5
|
|
|
6
6
|
useEffect(() => {
|
|
7
7
|
async function fetchData() {
|
|
@@ -12,7 +12,10 @@ useEffect(() => {
|
|
|
12
12
|
fetchData();
|
|
13
13
|
}, [someId]); // Or [] if effect doesn't need props or state
|
|
14
14
|
|
|
15
|
-
Learn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching`});let S=l.acquire(u),k=new Set,R=null;{let d=S.upper;for(;d&&(k.add(d),d.type!=="function");)d=d.upper;if(!d)return;R=d}let C=Array.isArray;function N(d){if(!C(d.defs))return!1;let h=d.defs[0];if(h==null||h.node.type!=="VariableDeclarator")return!1;let v=h.node.init;if(v==null)return!1;for(;v.type==="TSAsExpression";)v=v.expression;let O=h.node.parent;if(O==null&&(lt(R.block,h.node.id),O=h.node.parent,O==null))return!1;if(O.kind==="const"&&v.type==="Literal"&&(typeof v.value=="string"||typeof v.value=="number"||v.value===null))return!0;if(v.type!=="CallExpression")return!1;let F=v.callee;if(F.type==="MemberExpression"&&F.object.name==="React"&&F.property!=null&&!F.computed&&(F=F.property),F.type!=="Identifier")return!1;let P=h.node.id,{name:j}=F;if(j==="useRef"&&P.type==="Identifier")return!0;if(vr(F)&&P.type==="Identifier"){for(let D of d.references)D!==P&&T.add(D.identifier);return!0}else if(j==="useState"||j==="useReducer"){if(P.type==="ArrayPattern"&&P.elements.length===2&&C(d.identifiers)){if(P.elements[1]===d.identifiers[0]){if(j==="useState"){let D=d.references,le=0;for(let Te=0;Te<D.length;Te++){if(D[Te].isWrite()&&le++,le>1)return!1;p.set(D[Te].identifier,P.elements[0])}}return!0}else if(P.elements[0]===d.identifiers[0]){if(j==="useState"){let D=d.references;for(let le=0;le<D.length;le++)c.add(D[le].identifier)}return!1}}}else if(j==="useTransition"&&P.type==="ArrayPattern"&&P.elements.length===2&&Array.isArray(d.identifiers)&&P.elements[1]===d.identifiers[0])return!0;return!1}function z(d){if(!C(d.defs))return!1;let h=d.defs[0];if(h==null||h.node==null||h.node.id==null)return!1;let v=h.node,O=R.childScopes,F=null,P;for(P=0;P<O.length;P++){let j=O[P],D=j.block;if(v.type==="FunctionDeclaration"&&D===v||v.type==="VariableDeclarator"&&D.parent===v){F=j;break}}if(F==null)return!1;for(P=0;P<F.through.length;P++){let j=F.through[P];if(j.resolved!=null&&k.has(j.resolved.scope)&&!B(j.resolved))return!1}return!0}let B=I(N,f),K=I(z,y),ee=new Map;function be(d){let h=d.from,v=!1;for(;h.block!==u;)h.type==="function"&&(v=h.block.parent!=null&&h.block.parent.type==="ReturnStatement"),h=h.upper;return v}let te=new Map,De=new Map;ge(S);function ge(d){for(let h of d.references){if(!h.resolved||!k.has(h.resolved.scope))continue;let v=lt(u,h.identifier),O=sn(v),F=he(O,De);if(m&&O.type==="Identifier"&&(O.parent.type==="MemberExpression"||O.parent.type==="OptionalMemberExpression")&&!O.parent.computed&&O.parent.property.type==="Identifier"&&O.parent.property.name==="current"&&be(h)&&ee.set(F,{reference:h,dependencyNode:O}),O.parent.type==="TSTypeQuery"||O.parent.type==="TSTypeReference")continue;let P=h.resolved.defs[0];if(P!=null&&!(P.node!=null&&P.node.init===u.parent)&&P.type!=="TypeParameter")if(te.has(F))te.get(F).references.push(h);else{let j=h.resolved,D=B(j)||K(j);te.set(F,{isStable:D,references:[h]})}}for(let h of d.childScopes)ge(h)}ee.forEach(({reference:d,dependencyNode:h},v)=>{let O=d.resolved.references,F=!1;for(let P=0;P<O.length;P++){let{identifier:j}=O[P],{parent:D}=j;if(D!=null&&D.type==="MemberExpression"&&!D.computed&&D.property.type==="Identifier"&&D.property.name==="current"&&D.parent.type==="AssignmentExpression"&&D.parent.left===D){F=!0;break}}F||s({node:h.parent.property,message:`The ref value '${v}.current' will likely have changed by the time this effect cleanup function runs. If this ref points to a node rendered by React, copy '${v}.current' to a variable inside the effect, and use that variable in the cleanup function.`})});let me=new Set;function Se(d,h){me.has(h)||(me.add(h),s({node:d,message:`Assignments to the '${h}' variable from inside React Hook ${r(x)} 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(x)}.`}))}let Pe=new Set;if(te.forEach(({isStable:d,references:h},v)=>{d&&Pe.add(v),h.forEach(O=>{O.writeExpr&&Se(O.writeExpr,v)})}),me.size>0)return;if(!A){let d=null;if(te.forEach(({isStable:h,references:v},O)=>{d||v.forEach(F=>{if(d)return;let P=F.identifier;if(!p.has(P))return;let D=F.from;for(;D.type!=="function";)D=D.upper;D.block===u&&(d=O)})}),d){let{suggestedDependencies:h}=ot({dependencies:te,declaredDependencies:[],stableDependencies:Pe,externalDependencies:new Set,isEffect:!0});s({node:x,message:`React Hook ${g} contains a call to '${d}'. Without a list of dependencies, this can lead to an infinite chain of updates. To fix this, pass [`+h.join(", ")+`] as a second argument to the ${g} Hook.`,suggest:[{desc:`Add dependencies array: [${h.join(", ")}]`,fix(v){return v.insertTextAfter(u,`, [${h.join(", ")}]`)}}]})}return}let Le=[],_e=new Set;A.type!=="ArrayExpression"?s({node:A,message:`React Hook ${r(x)} was passed a dependency list that is not an array literal. This means we can't statically verify whether you've passed the correct dependencies.`}):A.elements.forEach(d=>{if(d===null)return;if(d.type==="SpreadElement"){s({node:d,message:`React Hook ${r(x)} has a spread element in its dependency array. This means we can't statically verify whether you've passed the correct dependencies.`});return}T.has(d)&&s({node:d,message:`Functions returned from \`useEffectEvent\` must not be included in the dependency array. Remove \`${r(d)}\` from the list.`,suggest:[{desc:`Remove the dependency \`${r(d)}\``,fix(F){return F.removeRange(d.range)}}]});let h;try{h=he(d,De)}catch(F){if(/Unsupported node type/.test(F.message)){d.type==="Literal"?te.has(d.value)?s({node:d,message:`The ${d.raw} literal is not a valid dependency because it never changes. Did you mean to include ${d.value} in the array instead?`}):s({node:d,message:`The ${d.raw} literal is not a valid dependency because it never changes. You can safely remove it.`}):s({node:d,message:`React Hook ${r(x)} has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked.`});return}else throw F}let v=d;for(;v.type==="MemberExpression"||v.type==="OptionalMemberExpression"||v.type==="ChainExpression";)v=v.object||v.expression.object;let O=!R.through.some(F=>F.identifier===v);Le.push({key:h,node:d}),O||_e.add(h)});let{suggestedDependencies:Qn,unnecessaryDependencies:We,missingDependencies:xe,duplicateDependencies:zt}=ot({dependencies:te,declaredDependencies:Le,stableDependencies:Pe,externalDependencies:_e,isEffect:m}),Ve=Qn;if(zt.size+xe.size+We.size===0){if(t)return;Cr({declaredDependencies:Le,declaredDependenciesNode:A,componentScope:R,scope:S}).forEach(({construction:h,isUsedOutsideOfHook:v,depType:O})=>{let F=O==="function"?"useCallback":"useMemo",P=O==="function"?"definition":"initialization",j=`wrap the ${P} of '${h.name.name}' in its own ${F}() Hook.`,D=v?`To fix this, ${j}`:`Move it inside the ${g} callback. Alternatively, ${j}`,le=O==="conditional"||O==="logical expression"?"could make":"makes",Te=`The '${h.name.name}' ${O} ${le} the dependencies of ${g} Hook (at line ${A.loc.start.line}) change on every render. ${D}`,Ht;v&&h.type==="Variable"&&O==="function"&&(Ht=[{desc:`Wrap the ${P} of '${h.name.name}' in its own ${F}() Hook.`,fix(Yt){let[tr,nr]=F==="useMemo"?["useMemo(() => { return ","; })"]:["useCallback(",")"];return[Yt.insertTextBefore(h.node.init,tr),Yt.insertTextAfter(h.node.init,nr)]}}]),s({node:h.node,message:Te,suggest:Ht})});return}!m&&xe.size>0&&(Ve=ot({dependencies:te,declaredDependencies:[],stableDependencies:Pe,externalDependencies:_e,isEffect:m}).suggestedDependencies);function er(){if(Le.length===0)return!0;let d=Le.map(v=>v.key),h=d.slice().sort();return d.join(",")===h.join(",")}er()&&Ve.sort();function Qe(d){let h=d.split("."),v="";for(let O=0;O<h.length;O++){if(O!==0){let F=h.slice(0,O+1).join("."),P=De.get(F)===!0;v+=P?"?.":"."}v+=h[O]}return v}function et(d,h,v,O){return d.size===0?null:(d.size>1?"":h+" ")+v+" "+(d.size>1?"dependencies":"dependency")+": "+Ar(Array.from(d).sort().map(F=>"'"+Qe(F)+"'"))+`. Either ${O} ${d.size>1?"them":"it"} or remove the dependency array.`}let ue="";if(We.size>0){let d=null;if(Array.from(We.keys()).forEach(h=>{d===null&&h.endsWith(".current")&&(d=h)}),d!==null)ue=` Mutable values like '${d}' aren't valid dependencies because mutating them doesn't re-render the component.`;else if(_e.size>0){let h=Array.from(_e)[0];S.set.has(h)||(ue=` Outer scope values like '${h}' aren't valid dependencies because mutating them doesn't re-render the component.`)}}if(!ue&&xe.has("props")){let d=te.get("props");if(d==null)return;let h=d.references;if(!Array.isArray(h))return;let v=!0;for(let O=0;O<h.length;O++){let F=h[O],P=lt(R.block,F.identifier);if(!P){v=!1;break}let j=P.parent;if(j==null){v=!1;break}if(j.type!=="MemberExpression"&&j.type!=="OptionalMemberExpression"){v=!1;break}}v&&(ue=` However, 'props' will change when *any* prop changes, so the preferred fix is to destructure the 'props' object outside of the ${g} call and refer to those specific props inside ${r(x)}.`)}if(!ue&&xe.size>0){let d=null;xe.forEach(h=>{if(d)return;let v=R.set.get(h),O=te.get(h);if(O.references[0].resolved!==v)return;let F=v.defs[0];if(F==null||F.name==null||F.type!=="Parameter")return;let P=!1,j;for(let D=0;D<O.references.length;D++)if(j=O.references[D].identifier,j!=null&&j.parent!=null&&(j.parent.type==="CallExpression"||j.parent.type==="OptionalCallExpression")&&j.parent.callee===j){P=!0;break}P&&(d=h)}),d!==null&&(ue=` If '${d}' changes too often, find the parent component that defines it and wrap that definition in useCallback.`)}if(!ue&&xe.size>0){let d=null;if(xe.forEach(h=>{if(d!==null)return;let O=te.get(h).references,F,P;for(let j=0;j<O.length;j++){for(F=O[j].identifier,P=F.parent;P!=null&&P!==R.block;){if(P.type==="CallExpression"){let D=p.get(P.callee);if(D!=null){if(D.name===h)d={missingDep:h,setter:P.callee.name,form:"updater"};else if(c.has(F))d={missingDep:h,setter:P.callee.name,form:"reducer"};else{let le=O[j].resolved;if(le!=null){let Te=le.defs[0];Te!=null&&Te.type==="Parameter"&&(d={missingDep:h,setter:P.callee.name,form:"inlineReducer"})}}break}}P=P.parent}if(d!==null)break}}),d!==null)switch(d.form){case"reducer":ue=` You can also replace multiple useState variables with useReducer if '${d.setter}' needs the current value of '${d.missingDep}'.`;break;case"inlineReducer":ue=` If '${d.setter}' needs the current value of '${d.missingDep}', you can also switch to useReducer instead of useState and read '${d.missingDep}' in the reducer.`;break;case"updater":ue=` You can also do a functional update '${d.setter}(${d.missingDep.slice(0,1)} => ...)' if you only need '${d.missingDep}' in the '${d.setter}' call.`;break;default:throw new Error("Unknown case.")}}s({node:A,message:`React Hook ${r(x)} has `+(et(xe,"a","missing","include")||et(We,"an","unnecessary","exclude")||et(zt,"a","duplicate","omit"))+ue,suggest:[{desc:`Update the dependencies array to be: [${Ve.map(Qe).join(", ")}]`,fix(d){return d.replaceText(A,`[${Ve.map(Qe).join(", ")}]`)}}]})}function E(u){let A=wr(u.callee,i);if(A===-1)return;let x=u.arguments[A],g=u.callee,m=on(g).name,S=u.arguments[A+1],k=/Effect($|[^a-z])/g.test(m);if(!x){s({node:g,message:`React Hook ${m} requires an effect callback. Did you forget to pass a callback to the hook?`});return}if(!(t&&!k)){if(!S&&!k){(m==="useMemo"||m==="useCallback")&&s({node:g,message:`React Hook ${m} does nothing when called with only one argument. Did you forget to pass an array of dependencies?`});return}switch(x.type){case"FunctionExpression":case"ArrowFunctionExpression":b(x,S,g,m,k);return;case"Identifier":if(!S||S.elements&&S.elements.some(N=>N&&N.type==="Identifier"&&N.name===x.name))return;let R=n(u).set.get(x.name);if(R==null||R.defs==null)return;let C=R.defs[0];if(!C||!C.node||C.type!=="Variable"&&C.type!=="FunctionName")break;switch(C.node.type){case"FunctionDeclaration":b(C.node,S,g,m,k);return;case"VariableDeclarator":let N=C.node.init;if(!N)break;switch(N.type){case"ArrowFunctionExpression":case"FunctionExpression":b(N,S,g,m,k);return}break}break;default:s({node:g,message:`React Hook ${m} received a function whose dependencies are unknown. Pass an inline function instead.`});return}s({node:g,message:`React Hook ${m} has a missing dependency: '${x.name}'. Either include it or remove the dependency array.`,suggest:[{desc:`Update the dependencies array to be: [${x.name}]`,fix(R){return R.replaceText(S,`[${x.name}]`)}}]})}}if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let u of e.sourceCode.getAllComments())if(Ir.test(u.value))return t=!0,{CallExpression:A=>E(A,!0)}}return{CallExpression:u=>E(u)}}};function ot({dependencies:e,declaredDependencies:t,stableDependencies:r,externalDependencies:n,isEffect:o}){let a=i();function i(){return{isUsed:!1,isSatisfiedRecursively:!1,isSubtreeUsed:!1,children:new Map}}e.forEach((b,E)=>{let u=s(a,E);u.isUsed=!0,l(a,E,A=>{A.isSubtreeUsed=!0})}),t.forEach(({key:b})=>{let E=s(a,b);E.isSatisfiedRecursively=!0}),r.forEach(b=>{let E=s(a,b);E.isSatisfiedRecursively=!0});function s(b,E){let u=E.split("."),A=b;for(let x of u){let g=A.children.get(x);g||(g=i(),A.children.set(x,g)),A=g}return A}function l(b,E,u){let A=E.split("."),x=b;for(let g of A){let m=x.children.get(g);if(!m)return;u(m),x=m}}let p=new Set,c=new Set;f(a,p,c,b=>b);function f(b,E,u,A){b.children.forEach((x,g)=>{let m=A(g);if(x.isSatisfiedRecursively){x.isSubtreeUsed&&u.add(m);return}if(x.isUsed){E.add(m);return}f(x,E,u,S=>m+"."+S)})}let y=[],T=new Set,I=new Set;return t.forEach(({key:b})=>{c.has(b)?y.indexOf(b)===-1?y.push(b):I.add(b):T.add(b)}),p.forEach(b=>{y.push(b)}),{suggestedDependencies:y,unnecessaryDependencies:T,duplicateDependencies:I,missingDependencies:p}}function Ce(e){switch(e.type){case"ObjectExpression":return"object";case"ArrayExpression":return"array";case"ArrowFunctionExpression":case"FunctionExpression":return"function";case"ClassExpression":return"class";case"ConditionalExpression":return Ce(e.consequent)!=null||Ce(e.alternate)!=null?"conditional":null;case"LogicalExpression":return Ce(e.left)!=null||Ce(e.right)!=null?"logical expression":null;case"JSXFragment":return"JSX fragment";case"JSXElement":return"JSX element";case"AssignmentExpression":return Ce(e.right)!=null?"assignment expression":null;case"NewExpression":return"object construction";case"Literal":return e.value instanceof RegExp?"regular expression":null;case"TypeCastExpression":return Ce(e.expression);case"TSAsExpression":return Ce(e.expression)}return null}function Cr({declaredDependencies:e,declaredDependenciesNode:t,componentScope:r,scope:n}){let o=e.map(({key:i})=>{let s=r.variables.find(p=>p.name===i);if(s==null)return null;let l=s.defs[0];if(l==null)return null;if(l.type==="Variable"&&l.node.type==="VariableDeclarator"&&l.node.id.type==="Identifier"&&l.node.init!=null){let p=Ce(l.node.init);if(p!=null)return[s,p]}return l.type==="FunctionName"&&l.node.type==="FunctionDeclaration"?[s,"function"]:l.type==="ClassName"&&l.node.type==="ClassDeclaration"?[s,"class"]:null}).filter(Boolean);function a(i){let s=!1;for(let l=0;l<i.references.length;l++){let p=i.references[l];if(p.writeExpr){if(s)return!0;s=!0;continue}let c=p.from;for(;c!==n&&c!=null;)c=c.upper;if(c!==n&&!an(t,p.identifier))return!0}return!1}return o.map(([i,s])=>({construction:i.defs[0],depType:s,isUsedOutsideOfHook:a(i)}))}function sn(e){return(e.parent.type==="MemberExpression"||e.parent.type==="OptionalMemberExpression")&&e.parent.object===e&&e.parent.property.name!=="current"&&!e.parent.computed&&!(e.parent.parent!=null&&(e.parent.parent.type==="CallExpression"||e.parent.parent.type==="OptionalCallExpression")&&e.parent.parent.callee===e.parent)?sn(e.parent):e.type==="MemberExpression"&&e.parent&&e.parent.type==="AssignmentExpression"&&e.parent.left===e?e.object:e}function at(e,t,r){t&&(e.optional?t.has(r)||t.set(r,!0):t.has(r)||t.set(r,!1))}function he(e,t){if(e.type==="Identifier"||e.type==="JSXIdentifier"){let r=e.name;return t&&t.set(r,!1),r}else if(e.type==="MemberExpression"&&!e.computed){let r=he(e.object,t),n=he(e.property,null),o=`${r}.${n}`;return at(e,t,o),o}else if(e.type==="OptionalMemberExpression"&&!e.computed){let r=he(e.object,t),n=he(e.property,null),o=`${r}.${n}`;return at(e,t,o),o}else if(e.type==="ChainExpression"&&!e.computed){let r=e.expression;if(r.type==="CallExpression")throw new Error(`Unsupported node type: ${r.type}`);let n=he(r.object,t),o=he(r.property,null),a=`${n}.${o}`;return at(r,t,a),a}else throw new Error(`Unsupported node type: ${e.type}`)}function on(e,t){return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.object.name==="React"&&e.property.type==="Identifier"&&!e.computed?e.property:e}function wr(e,t){let r=on(e);if(r.type!=="Identifier")return-1;switch(r.name){case"useEffect":case"useLayoutEffect":case"useCallback":case"useMemo":return 0;case"useImperativeHandle":return 1;default:if(r===e&&t&&t.additionalHooks){let n;try{n=he(r,null)}catch(o){if(/Unsupported node type/.test(o.message))return 0;throw o}return t.additionalHooks.test(n)?0:-1}else return-1}}function lt(e,t){let r=[e],n=null;for(;r.length;){if(n=r.shift(),Rr(n,t))return n;if(an(n,t))for(let[o,a]of Object.entries(n))o!=="parent"&&(nn(a)?(a.parent=n,r.push(a)):Array.isArray(a)&&a.forEach(i=>{nn(i)&&(i.parent=n,r.push(i))}))}return null}function Ar(e){let t="";for(let r=0;r<e.length;r++)t+=e[r],r===0&&e.length===2?t+=" and ":r===e.length-2&&e.length>2?t+=", and ":r<e.length-1&&(t+=", ");return t}function nn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function Rr(e,t){return(e.type==="Identifier"||e.type==="JSXIdentifier")&&e.type===t.type&&e.name===t.name&&e.range[0]===t.range[0]&&e.range[1]===t.range[1]}function an(e,t){return e.range[0]<=t.range[0]&&e.range[1]>=t.range[1]}function vr(e){return!1}var we=require("@typescript-eslint/utils");var ie=Re(require("typescript")),kr=we.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),ln="improved-no-unnecessary-condition",Or=Y({}),Pr=["string","number","bigint","boolean","symbol","undefined","object","function","never"],Fr=new Set(Pr),pt={name:ln,rule:kr({name:ln,meta:{type:"suggestion",docs:{description:"Extends checks of `no-unnecessary-condition` rule"},messages:{unnecessaryTypeofCondition:'This condition is unnecessary. The type of "{{name}}" is always "{{type}}".',alwaysFalseTypeofCondition:'This condition will always be false. The type of "{{name}}" is "{{actualType}}" so the condition has no overlap with "{{conditionType}}".'},schema:[Or]},defaultOptions:[{}],create(e){let t=we.ESLintUtils.getParserServices(e,!0),r=t.program?.getTypeChecker();if(!r||!t.program)throw new Error("TypeScript services or program not available");function n(s){return s.type===we.AST_NODE_TYPES.UnaryExpression&&s.operator==="typeof"}function o(s){return s.flags&ie.default.TypeFlags.Any||s.flags&ie.default.TypeFlags.Unknown?null:s.flags&ie.default.TypeFlags.StringLike?["string"]:s.flags&ie.default.TypeFlags.NumberLike?["number"]:s.flags&ie.default.TypeFlags.BigIntLike?["bigint"]:s.flags&ie.default.TypeFlags.BooleanLike?["boolean"]:s.flags&ie.default.TypeFlags.ESSymbolLike?["symbol"]:s.flags&ie.default.TypeFlags.Undefined||s.flags&ie.default.TypeFlags.Void?["undefined"]:s.flags&ie.default.TypeFlags.Null?["object"]:s.getCallSignatures().length>0?["function"]:s.flags&ie.default.TypeFlags.Object?s.getProperties().length===0?["string","number","bigint","boolean","symbol","object","function"]:["object"]:s.flags&ie.default.TypeFlags.NonPrimitive?["object"]:s.flags&ie.default.TypeFlags.Never?["never"]:null}function a(s){if(!r)return null;let l=t.esTreeNodeToTSNodeMap.get(s),p=r.getTypeAtLocation(l.expression);if(p.flags&ie.default.TypeFlags.Any||p.flags&ie.default.TypeFlags.Unknown)return null;let c=[];if(p.isUnion()){for(let y of p.types){let T=o(y);if(T)c.push(...T);else return null}return c}let f=o(p);return f?(c.push(...f),c):null}function i(s){if(!(s.operator==="==="||s.operator==="!=="))return;let p=null,c=null;if(n(s.left)?(p=s.left,c=s.right.type===we.AST_NODE_TYPES.Literal&&typeof s.right.value=="string"?s.right.value:null):n(s.right)&&(p=s.right,c=s.left.type===we.AST_NODE_TYPES.Literal&&typeof s.left.value=="string"?s.left.value:null),!p||!c||!Nr(c,Fr))return;let f=a(p);if(!f)return;let y=s.operator==="!==",T=f.includes(c);f.length===1?T&&!y?e.report({node:s,messageId:"unnecessaryTypeofCondition",data:{name:Ne(p,e),type:c}}):!T&&y?e.report({node:s,messageId:"unnecessaryTypeofCondition",data:{name:Ne(p,e),type:Array.from(f)[0]}}):!T&&!y?e.report({node:s,messageId:"alwaysFalseTypeofCondition",data:{name:Ne(p,e),actualType:He(f),conditionType:c}}):T&&y&&e.report({node:s,messageId:"alwaysFalseTypeofCondition",data:{name:Ne(p,e),actualType:He(f),conditionType:c}}):!T&&!y?e.report({node:s,messageId:"alwaysFalseTypeofCondition",data:{name:Ne(p,e),actualType:He(f),conditionType:c}}):!T&&y&&e.report({node:s,messageId:"unnecessaryTypeofCondition",data:{name:Ne(p,e),type:He(f)}})}return{BinaryExpression:i}}})};function He(e){return Array.from(new Set(e)).join(" | ")||"never"}function Ne(e,t){let r=e.argument;return r.type===we.AST_NODE_TYPES.Identifier?r.name:t.sourceCode.getText(r)}function Nr(e,t){return t.has(e)}var Ye=require("@typescript-eslint/utils");var Mr=Ye.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),pn="no-call-with-explicit-generics",jr=Y({functions:ne(H())}),Dr=Mr({name:pn,meta:{type:"problem",docs:{description:"Enforce calling configured functions with inferred generics only"},messages:{noExplicitGenerics:"Function '{{ functionName }}' should be called with inferred generics (remove the explicit type parameters)"},schema:[jr]},defaultOptions:[{functions:[]}],create(e,[t]){let r=new Set(t.functions);return{CallExpression(n){let{callee:o}=n;o.type===Ye.AST_NODE_TYPES.Identifier&&r.has(o.name)&&n.typeArguments&&e.report({node:n,messageId:"noExplicitGenerics",data:{functionName:o.name}})}}}}),ct={name:pn,rule:Dr};var ve=require("@typescript-eslint/utils"),Lr=ve.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),cn="no-call-with-inferred-generics",_r=Lr({name:cn,meta:{type:"problem",docs:{description:"Disable calling configured functions with infered generics"},messages:{missingGenericDeclaration:"Function '{{ functionName }}' should be called with at least {{ minGenerics }} generic(s) (ex: `fn<Generic>()`) defined",anyUsedInGenerics:"Function '{{ functionName }}' should not be called with 'any' in generics"},schema:[{type:"object",properties:{functions:{type:"array",items:{type:"object",properties:{name:{type:"string"},minGenerics:{type:"number"},allowAny:{type:"boolean"},disallowTypes:{type:"array",items:{type:"string"}}},required:["name"]}},anyAliases:{type:"array",items:{type:"string"}}},required:["functions"]}]},defaultOptions:[{functions:[]}],create(e,[t]){let r=new Map(t.functions.map(n=>[n.name,n]));return{CallExpression(n){let{callee:o}=n;if(o.type!==ve.AST_NODE_TYPES.Identifier)return;let a=r.get(o.name);if(!a)return;let{minGenerics:i=1,allowAny:s,disallowTypes:l=t.disallowTypes}=a;(n.typeArguments?.params.length||0)<(i||0)&&e.report({node:n,messageId:"missingGenericDeclaration",data:{functionName:o.name,minGenerics:i||0}}),!(s&&!l)&&n.typeArguments?.params?.some(c=>!s&&c.type===ve.AST_NODE_TYPES.TSAnyKeyword||l&&c.type===ve.AST_NODE_TYPES.TSTypeReference&&c.typeName.type===ve.AST_NODE_TYPES.Identifier&&l.includes(c.typeName.name))&&e.report({node:n,messageId:"anyUsedInGenerics",data:{functionName:o.name}})}}}}),ut={name:cn,rule:_r};var fn=require("@typescript-eslint/utils"),$r=fn.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),mn="no-commented-out-code",Ur=["function ","class ","interface ","type ","enum ","namespace ","import ","export ","const ","let ","var ","return ","throw ","break","continue","try {","catch (","finally {","async ","await ","case ","switch (","while (","for (","default:"],X={returnStatement:/^\s*return\s+/,stringAssignment:/\w=("|'|`)/,objectPropertyWithQuotes:/\w+:\s*('|"|`)/,computedPropertyAssignment:/\[['"][^'"]*['"]\]:\s*('|"|`|[^'"`\s])/,kebabCaseProperty:/\w+-\w+:/,snakeCaseProperty:/\w+_\w+:/,ternaryOperator:/\?\s+\w/,colonWithWord:/:\s+\w/,quotedString:/^\s*('|"|`)[^'"]*('|"|`),?\s*$/,numberWithComma:/^\s*\d+[,}]/,arrayWithComma:/^\s*\[[^\]]*\][,}]/,objectWithComma:/^\s*\{[^}]*\}[,}]/,methodCall:/\.\w+\(/,arrayAccess:/\[\w+\]/,quotedPropertyKey:/^\s*(['"`]).+?\1\s*:/,jsxSelfClosing:/^<[A-Z]\w*(\s|>|\/)/,jsxElement:/^<[a-z]+(\s|>|\/)/,jsxOpeningTag:/<[A-Z]\w*(\s.*)?>/,jsxClosingTag:/<\/[A-Z]\w*>/,htmlOpeningTag:/<[a-z]+(\s.*)?>/,htmlClosingTag:/<\/[a-z]+>/,colonDescriptiveComment:/^[a-zA-Z]+(\s+[a-zA-Z]+)*:\s+[a-zA-Z]+\s+[a-zA-Z][^{=,'"]*$/,jsdocComment:/^\s*[*\s]*$/},Wr=[") {","return;",X.returnStatement,"if (","else {","else if (","/>","</","< ","},",": {"," } = ","={",X.stringAssignment,");",X.objectPropertyWithQuotes,X.computedPropertyAssignment,X.kebabCaseProperty,X.snakeCaseProperty,"&&","||","()",X.ternaryOperator,X.colonWithWord,X.quotedString,X.numberWithComma,X.arrayWithComma,X.objectWithComma,X.methodCall,X.arrayAccess,"?.(","??","=>",X.quotedPropertyKey],Vr=["/>","</",X.jsxSelfClosing,X.jsxElement,X.jsxOpeningTag,X.jsxClosingTag,X.htmlOpeningTag,X.htmlClosingTag],un=["INFO:","TODO:","DOCS:","FIX:","FIXME:","HACK:","NOTE:","WARNING:","WARN:","BUG:","ISSUE:","TEMP:","TEMPORARY:","XXX:","REVIEW:","eslint"],zr=$r({name:mn,meta:{type:"problem",docs:{description:"Disallow commented code"},messages:{commentedOutCode:"Commented code is not allowed. Detected pattern: `{{ wrongPattern }}` Use a comment starting with one of these prefixes if you want to keep this code commented out: {{ allowedPrefixes }}"},schema:[]},defaultOptions:[],create(e){function t(n,o){if(n.startsWith("/"))return!1;let a=n.trimStart();if(n.startsWith("*")||a.startsWith("eslint-disable")||n.includes("@deprecated")||n.includes("@example")||n.includes("@param")||n.includes("@returns")||n.includes("@throws")||n.includes("typescript-eslint")||n.includes("@ts-")||n.includes("prettier-ignore")||X.jsdocComment.test(n))return!1;for(let i of un)if(a.startsWith(i))return!1;if(n.includes("https://")||a.includes(":")&&X.colonDescriptiveComment.test(a.trim()))return!1;if(o==="Block"){for(let i of Vr)if(typeof i=="string"){if(n.includes(i))return{wrongPattern:i}}else if(i.test(n))return{wrongPattern:`regex(${i.toString()})`};return!1}for(let i of Ur)if(a.startsWith(i))return{wrongPattern:i};for(let i of Wr)if(typeof i=="string"){if(n.includes(i))return{wrongPattern:i}}else if(i.test(n))return{wrongPattern:`regex(${i.toString()})`};return!1}function r(n,o){let a=n,i=a.trim();if(i.startsWith("`")&&(i.endsWith("`,")||i.endsWith("`;")||i.endsWith("`")))return a;if(o==="Block"&&a.includes("```")){let p=a.split(/```[\s\S]*?```/g);p.some(f=>/[a-zA-Z0-9]/.test(f))&&(a=p.join(""))}if(!a.includes("`"))return a;let s=a.split(/`[^`]*`/g);return s.some(p=>/[a-zA-Z0-9]/.test(p))?s.join(""):a}return{Program(){let o=e.sourceCode.getAllComments();for(let a of o){let i=r(a.value,a.type),s=t(i,a.type);s&&e.report({node:a,messageId:"commentedOutCode",data:{wrongPattern:s.wrongPattern,allowedPrefixes:un.join(", ")}})}}}}}),ft={name:mn,rule:zr};var qe=require("@typescript-eslint/utils"),Hr=qe.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),dn="no-default-export",Yr=Hr({name:dn,meta:{type:"problem",docs:{description:"Disallow default exports"},schema:[],messages:{noDefaultExport:"Default exports are not allowed, use named exports instead."}},defaultOptions:[],create(e){return{ExportDefaultDeclaration(t){e.report({node:t,messageId:"noDefaultExport"})},ExportNamedDeclaration(t){for(let r of t.specifiers)r.exported.type===qe.TSESTree.AST_NODE_TYPES.Identifier&&r.exported.name==="default"&&e.report({node:t,messageId:"noDefaultExport"})}}}}),mt={name:dn,rule:Yr};var yn=require("@typescript-eslint/utils"),qr=yn.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),gn="no-leaked-text-in-jsx",Jr=[",",";","[","]","(",")"],Br=qr({name:gn,meta:{type:"problem",docs:{description:"Prevents leaking of text in JSX that should be wrapped in an expression container"},messages:{leakedTextInJSX:'Text "{{ text }}" should be wrapped in a JSX expression container.'},schema:[],fixable:"code"},defaultOptions:[],create(e){return{JSXText(t){let r=t.value.trim();if(!r)return;let n="";Jr.includes(r)?n=r:r.includes("&&")?n="&&":r.includes("||")?n="||":r.endsWith("? (")&&(n="? ("),n&&e.report({node:t,messageId:"leakedTextInJSX",data:{text:n}})}}}}),dt={name:gn,rule:Br};var Ae=require("@typescript-eslint/utils"),Xr=Ae.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Tn="no-non-camel-case-functions",Gr=/^(\$?[a-z][a-zA-Z0-9]*)$/;function Sn(e){if(e.typeName.type!==Ae.AST_NODE_TYPES.TSQualifiedName)return!1;let{left:t,right:r}=e.typeName;return t.type===Ae.AST_NODE_TYPES.Identifier&&t.name==="JSX"&&r.name==="Element"}var Kr=Xr({name:Tn,meta:{type:"suggestion",docs:{description:"Enforce camelCase naming convention for function declarations"},schema:[],messages:{nonCamelCaseFunction:'Function name "{{functionName}}" should be in camelCase format. If this fn is a React component and can\'t use the `FC` type, add a explicit "JSX.Element" return type to it'}},defaultOptions:[],create(e){return{FunctionDeclaration(t){if(t.id&&!Gr.test(t.id.name)){let r=t.returnType?.typeAnnotation;if(r&&(r.type===Ae.AST_NODE_TYPES.TSTypeReference?Sn(r):r.type===Ae.AST_NODE_TYPES.TSUnionType&&r.types.some(o=>o.type===Ae.AST_NODE_TYPES.TSTypeReference&&Sn(o))))return;e.report({node:t.id,messageId:"nonCamelCaseFunction",data:{functionName:t.id.name}})}}}}}),yt={name:Tn,rule:Kr};var W=require("@typescript-eslint/utils");var gt=require("@typescript-eslint/utils");function Me(e,t,r=1/0){if(r!==0&&e.parent)return e.type===t?e:Me(e.parent,t,r===1/0?r:r-1)}function*St(e){yield e,e.parent&&(yield*St(e.parent))}function Tt(e,t){for(let r of e){let n=t(r);if(n!=null&&n!==!1)return n}}function hn(e,t,r){let o=r.getDeclaredVariables(e).find(a=>a.name===t||a.identifiers[0]?.parent.type===gt.AST_NODE_TYPES.Property&&a.identifiers[0]?.parent.key.type===gt.AST_NODE_TYPES.Identifier&&a.identifiers[0]?.parent.key.name===t);return o?o.references.filter(a=>!a.init):[]}var Zr=W.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),En="no-optional-root-props",Qr=Zr({name:En,meta:{type:"problem",docs:{description:"Prevents usage of optional properties at the root of a type if that type is a local type alias or interface referenced only once"},messages:{optionalNotAllowed:'Optional property "{{ propertyName }}" is not allowed on a local type used only once. Use `prop: undefined | ...` instead.',suggestion:"Use `prop: undefined | ...` instead."},hasSuggestions:!0,schema:[]},defaultOptions:[],create(e){function t(n){let a=e.sourceCode.getDeclaredVariables(n)[0];if(!a||a.references.length!==1)return!1;let i=a.references[0];if(!i)return!1;for(let s of St(i.identifier)){if("returnType"in s||s.type===W.TSESTree.AST_NODE_TYPES.ExportNamedDeclaration)return!1;let l=s.parent;if(!l)return!1;if(l.type===W.TSESTree.AST_NODE_TYPES.TSTypeParameterInstantiation&&l.parent.type===W.TSESTree.AST_NODE_TYPES.TSTypeReference&&l.parent.typeName.type===W.TSESTree.AST_NODE_TYPES.Identifier&&l.parent.typeName.name==="FC"){let c=Me(l.parent.parent,W.TSESTree.AST_NODE_TYPES.VariableDeclaration,4);if(!c)return!1;let f=Je(c,e.sourceCode);return f?!(f.parent.type===W.TSESTree.AST_NODE_TYPES.CallExpression&&f.parent.callee.type===W.TSESTree.AST_NODE_TYPES.Identifier&&f.parent.callee.name==="memo"):!1}if(s.type===W.TSESTree.AST_NODE_TYPES.AssignmentPattern)return!1;if(l.type===W.TSESTree.AST_NODE_TYPES.ArrowFunctionExpression){let p=Me(l,W.TSESTree.AST_NODE_TYPES.VariableDeclaration);return p?!!Je(p,e.sourceCode):!1}if(l.type===W.TSESTree.AST_NODE_TYPES.FunctionDeclaration)return!!Je(l,e.sourceCode)}return!1}function r(n){n.key.type!==W.TSESTree.AST_NODE_TYPES.Identifier||!n.optional||e.report({node:n.key,messageId:"optionalNotAllowed",data:{propertyName:n.key.name},suggest:[{messageId:"suggestion",fix:o=>{let a=Me(n,W.TSESTree.AST_NODE_TYPES.TSPropertySignature);if(!a)return null;let i=e.sourceCode.getText(a);return o.replaceText(a,i.replace("?:",": undefined |"))}}]})}return{TSTypeAliasDeclaration(n){if(n.typeAnnotation.type===W.TSESTree.AST_NODE_TYPES.TSTypeLiteral&&!(Be(n)||!t(n)))for(let o of n.typeAnnotation.members)o.type===W.TSESTree.AST_NODE_TYPES.TSPropertySignature&&r(o)},TSInterfaceDeclaration(n){if(!(Be(n)||!t(n)))for(let o of n.body.body)o.type===W.TSESTree.AST_NODE_TYPES.TSPropertySignature&&r(o)},TSTypeReference(n){if(n.typeName.type!==W.TSESTree.AST_NODE_TYPES.Identifier||n.typeName.name!=="FC"||!n.typeArguments?.params[0])return;let o=n.typeArguments.params[0];if(o.type!==W.TSESTree.AST_NODE_TYPES.TSTypeLiteral)return;let a=Me(n.parent,W.TSESTree.AST_NODE_TYPES.VariableDeclaration,4);if(!a)return;let i=Je(a,e.sourceCode);if(!(!i||i.parent.type===W.TSESTree.AST_NODE_TYPES.CallExpression&&i.parent.callee.type===W.TSESTree.AST_NODE_TYPES.Identifier&&i.parent.callee.name==="memo"))for(let l of o.members)l.type===W.TSESTree.AST_NODE_TYPES.TSPropertySignature&&r(l)}}}});function Be(e){return e?e.parent?.type===W.TSESTree.AST_NODE_TYPES.ExportNamedDeclaration||e.parent?.type===W.TSESTree.AST_NODE_TYPES.ExportDefaultDeclaration:!1}function Je(e,t){if(Be(e))return;let r;if(e.type===W.TSESTree.AST_NODE_TYPES.VariableDeclaration){if(e.declarations.length!==1)return;e.declarations[0].id.type===W.TSESTree.AST_NODE_TYPES.Identifier&&(r=e.declarations[0].id)}else{if(!e.id)return;r=e.id}if(!r)return;let n=t.getScope(e);e.type===W.TSESTree.AST_NODE_TYPES.FunctionDeclaration&&n.upper&&(n=n.upper);let o=n.variables.find(i=>i.identifiers.includes(r));if(!o)return;let a=o.references.filter(i=>i.identifier!==r);if(!(a.length!==1||!a[0])&&!Be(a[0].identifier.parent.parent))return a[0].identifier}var ht={name:En,rule:Qr};var bn=require("@typescript-eslint/utils"),Xe=Re(require("path"));var ei=bn.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),xn="no-relative-imports",ti=Y({find:H(),replacement:H()}),ni=Y({aliases:ne(ti),rootDir:$(H()),allowNotFoundAliases:$(Fe()),_dev_simulateFileName:$(H())}),ri=ei({name:xn,meta:{type:"problem",fixable:"code",docs:{description:"Prevent relative imports and auto-fix them using configured aliases"},messages:{noRelativeImports:"Relative imports are not allowed. Use one of the valid aliases in tsconfig.json instead.",noRelativeImportsWithAlias:'Relative imports are not allowed. Use the "{{ alias }}" alias instead.'},schema:[ni]},defaultOptions:[{aliases:[],rootDir:void 0}],create(e,[t]){let r=t._dev_simulateFileName??e.filename;function n(i){return i.startsWith(".")||i.startsWith("..")}function o(i,s){let l=Xe.default.dirname(s);return Xe.default.resolve(l,i)}function a(i){let s=t.rootDir??process.cwd(),l=Xe.default.relative(s,i);if(l.startsWith("."))return null;l.startsWith("/")||(l=`/${l}`);for(let{find:p,replacement:c}of t.aliases)if(l.startsWith(c)){let f=l.replace(c,p);return{alias:p,newPath:f}}return null}return{ImportDeclaration(i){let s=i.source.value;if(!n(s))return;let l=o(s,r),p=a(l);!p&&t.allowNotFoundAliases||e.report({node:i,messageId:p?"noRelativeImportsWithAlias":"noRelativeImports",data:{alias:p?.alias},fix:p?c=>c.replaceText(i.source,`'${p.newPath}'`):void 0})}}}}),Et={name:xn,rule:ri};var $e=require("@typescript-eslint/utils"),ke=Re(require("zod/v4"));var ii=ke.object({alternativeMsgs:ke.object({inArrayFind:ke.string().optional(),inArrayFilter:ke.string().optional()}).optional(),__dev_simulateFileName:ke.string().optional()});function si(e){return e.typeAnnotation.type!==$e.AST_NODE_TYPES.TSTypePredicate?!1:e.typeAnnotation.asserts===!1}function oi(e){return/\.(typeGuards|type-guards)\.(ts|tsx)$/.test(e)}function ai(e){let t=e.parent;for(;t;){if(t.type===$e.AST_NODE_TYPES.CallExpression&&t.callee.type===$e.AST_NODE_TYPES.MemberExpression&&t.callee.property.type===$e.AST_NODE_TYPES.Identifier){let r=t.callee.property.name;if(r==="filter"||r==="find")return{method:r}}t=t.parent}return null}var bt=G({name:"no-type-guards",meta:{type:"problem",docs:{description:"Disallow type guards unless in *.typeGuards.(ts|tsx) or *.type-guards.(ts|tsx) files"},messages:{typeGuardNotAllowed:"Type guards are only allowed in *.typeGuards.(ts|tsx) or *.type-guards.(ts|tsx) files",useFilterWithTypeCheck:"{{message}}",useFindWithTypeCheck:"{{message}}"},schema:[Ie(ii)],hasSuggestions:!0},defaultOptions:[{}],create(e,[t]){let r=t.__dev_simulateFileName??e.filename;if(oi(r))return{};function n(o){if(!si(o))return;let a=ai(o),i=[];if(t.alternativeMsgs&&a){let s=a.method==="filter"?t.alternativeMsgs.inArrayFilter:t.alternativeMsgs.inArrayFind;if(s){let l=a.method==="filter"?"useFilterWithTypeCheck":"useFindWithTypeCheck";e.report({node:o,messageId:l,data:{message:s}});return}}e.report({node:o,messageId:"typeGuardNotAllowed"})}return{"FunctionDeclaration > :matches(TSTypeAnnotation)":n,"ArrowFunctionExpression > :matches(TSTypeAnnotation)":n,"MethodDefinition > FunctionExpression > :matches(TSTypeAnnotation)":n}}});var Oe=require("@typescript-eslint/utils");var li="no-unnecessary-async-on-jsx-props";function pi(e){if(e.body.type!==Oe.AST_NODE_TYPES.BlockStatement)return!1;let t=e.body.body;if(t.length!==1)return!1;let r=t[0];return!r||r.type!==Oe.AST_NODE_TYPES.ExpressionStatement?!1:r.expression.type===Oe.AST_NODE_TYPES.AwaitExpression}var xt=G({name:li,meta:{type:"suggestion",fixable:"code",docs:{description:"Disallow unnecessary async/await in JSX props where a single await provides no benefit"},messages:{unnecessaryAsyncInJsxProp:"Unnecessary async/await in JSX prop. The single await expression provides no benefit here."},schema:[]},defaultOptions:[],create(e){function t(r){pi(r)&&e.report({node:r,messageId:"unnecessaryAsyncInJsxProp",fix(n){let o=e.sourceCode,a=[],i=o.getFirstToken(r,l=>l.value==="async");if(i){let l=o.getTokenAfter(i);l?a.push(n.replaceTextRange([i.range[0],l.range[0]],"")):a.push(n.remove(i))}function s(l){if(l.type===Oe.AST_NODE_TYPES.AwaitExpression){let p=o.getFirstToken(l);if(p&&p.value==="await"){let c=o.getTokenAfter(p);c?a.push(n.replaceTextRange([p.range[0],c.range[0]],"")):a.push(n.remove(p))}}if(l.type===Oe.AST_NODE_TYPES.BlockStatement)for(let p of l.body)s(p);else l.type===Oe.AST_NODE_TYPES.ExpressionStatement&&s(l.expression)}return s(r.body),a}})}return{"JSXAttribute ArrowFunctionExpression[async=true]":t,"JSXAttribute FunctionExpression[async=true]":t}}});var Ee=require("@typescript-eslint/utils");var It=Re(require("typescript")),ci=Ee.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),In="no-unnecessary-casting",ui=Y({additionalCastFunctions:$(ne(Y({name:H(),expectedType:Jt(["string","number"])})))}),Ct={name:In,rule:ci({name:In,meta:{type:"suggestion",docs:{description:"Prevents unnecessary Number and String castings"},messages:{unnecessaryNumberCasting:"Unnecessary Number() casting on a value already of number type",unnecessaryStringCasting:"Unnecessary String() casting on a value already of string type",unnecessaryCustomCasting:"Unnecessary {{name}}() casting on a value already of {{type}} type"},schema:[ui],fixable:"code"},defaultOptions:[{}],create(e){let r=e.options[0].additionalCastFunctions||[],n=[{name:"Number",expectedType:"number"},{name:"String",expectedType:"string"},...r],o=Ee.ESLintUtils.getParserServices(e,!0),a=o.program?.getTypeChecker();if(!a||!o.program)throw new Error("TypeScript services or program not available");function i(c,f){switch(c.type){case Ee.AST_NODE_TYPES.Literal:return f==="number"?typeof c.value=="number":typeof c.value=="string";case Ee.AST_NODE_TYPES.TemplateLiteral:return f==="string";case Ee.AST_NODE_TYPES.UnaryExpression:return f==="number"?c.operator==="+"||c.operator==="-"||c.operator==="~":!1;default:return!1}}function s(c,f){return f==="number"?!!(c.flags&It.TypeFlags.NumberLike):!!(c.flags&It.TypeFlags.StringLike)}function l(c,f){return y=>y.replaceText(c,e.sourceCode.getText(f))}function p(c){if(!a||c.arguments.length!==1)return;let f=c.arguments[0];if(!f||f.type===Ee.AST_NODE_TYPES.SpreadElement)return;let{callee:y}=c;if(y.type!==Ee.AST_NODE_TYPES.Identifier)return;let T=y.name,I=n.find(E=>E.name===T);if(!I)return;if(i(f,I.expectedType)||s(a.getTypeAtLocation(o.esTreeNodeToTSNodeMap.get(f)),I.expectedType)){let E,u;T==="Number"?E="unnecessaryNumberCasting":T==="String"?E="unnecessaryStringCasting":(E="unnecessaryCustomCasting",u={name:I.name,type:I.expectedType}),e.report({node:c,messageId:E,...u?{data:u}:{},fix:l(c,f)})}}return{CallExpression:p}}})};var Ue=require("@typescript-eslint/utils"),pe=Re(require("zod/v4"));var fi=pe.object({methods:pe.union([pe.array(pe.string()),pe.literal("array")])}),wt=G({name:"no-unnecessary-typing",meta:{type:"suggestion",docs:{description:"Prevents unnecessary explicit type annotations in callback parameters where TypeScript can infer the type"},messages:{unnecessaryTypeAnnotation:"Unnecessary type annotation. TypeScript can infer this type from context."},fixable:"code",schema:[pe.toJSONSchema(fi)]},defaultOptions:[{methods:"array"}],create(e,[t]){let r=t.methods,n=new Set(["find","filter","map","forEach","some","every","reduce","findIndex","sort"]);function o(s){return Array.isArray(r)?r.includes(s):n.has(s)}function a(s){let{callee:l}=s;if(l.type===Ue.AST_NODE_TYPES.MemberExpression){let p=l.property;if(p.type===Ue.AST_NODE_TYPES.Identifier)return p.name}return null}function i(s,l){if(s.type!==Ue.AST_NODE_TYPES.Identifier||!s.typeAnnotation)return;let p=l.parent;if(p.type===Ue.AST_NODE_TYPES.CallExpression){let c=a(p);c&&o(c)&&p.arguments.indexOf(l)===0&&e.report({node:s.typeAnnotation,messageId:"unnecessaryTypeAnnotation",fix(y){return y.remove(s.typeAnnotation)}})}}return{ArrowFunctionExpression(s){for(let l of s.params)i(l,s)},FunctionExpression(s){for(let l of s.params)i(l,s)}}}});var ae=require("@typescript-eslint/utils");var At=G({name:"no-unused-obj-props",meta:{type:"suggestion",docs:{description:"Disallow unused properties when it is safe to remove them"},messages:{unusedObjectProperty:'The object property "{{name}}" is not being used',unusedReturnObjectProperty:'The object property "{{name}}" returned by this function is not being used'},schema:[]},defaultOptions:[],create(e){return{VariableDeclarator(t){if(t.id.type===ae.AST_NODE_TYPES.ObjectPattern||!t.init||t.init.type!==ae.AST_NODE_TYPES.ObjectExpression||t.id.type===ae.AST_NODE_TYPES.Identifier&&t.id.typeAnnotation||t.parent.parent.type===ae.AST_NODE_TYPES.ExportNamedDeclaration)return;let r=new Map;for(let i of t.init.properties)i.type===ae.AST_NODE_TYPES.Property&&i.key.type===ae.AST_NODE_TYPES.Identifier&&r.set(i.key.name,i);if(r.size===0||t.id.type!==ae.AST_NODE_TYPES.Identifier)return;let n=mi(t,e.sourceCode);if(n.length===0)return;let o=t.init.properties.some(i=>i.type!==ae.AST_NODE_TYPES.Property?!1:i.value.type===ae.AST_NODE_TYPES.FunctionExpression),a=new Set;for(let i of n){if(i.identifier.parent.type!==ae.AST_NODE_TYPES.MemberExpression)return;let s=i.identifier.parent;if(s.object!==i.identifier)return;if(s.computed)if(s.property.type===ae.AST_NODE_TYPES.Literal&&typeof s.property.value=="string")a.add(s.property.value);else return;else{if(s.property.type!==ae.AST_NODE_TYPES.Identifier)return;a.add(s.property.name)}if(s.parent.type===ae.AST_NODE_TYPES.CallExpression&&o)return}for(let[i,s]of r)a.has(i)||e.report({node:s,messageId:"unusedObjectProperty",data:{name:i}})}}}});function mi(e,t){let r=t.getDeclaredVariables(e);if(r.length!==1)return[];let n=r[0];return n?n.references.filter(o=>o.identifier!==e.id):[]}var V=require("@typescript-eslint/utils");var di=Y({selectors:ne(Y({name:H(),selectorProp:$(H()),selectorArgPos:$(de()),returnProp:$(H())}))}),yi=V.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Cn="no-unused-selected-values",Rt={name:Cn,rule:yi({name:Cn,meta:{type:"suggestion",docs:{description:"Disallow unused values in selector objects"},messages:{unusedSelectedValue:'The selected value "{{name}}" is not being used'},schema:[di]},defaultOptions:[{selectors:[]}],create(e,[t]){let{selectors:r=[]}=t,n=new Map(r.map(o=>[o.name,o]));return{VariableDeclarator(o){let a=null;if(o.init?.type===V.AST_NODE_TYPES.CallExpression&&(a=o.init),!a)return;let i=Si(a);if(!i)return;let s=n.get(i);if(!s)return;let l=gi(a,s.selectorArgPos??0,s.selectorProp);if(!l)return;let p=Ti(l);if(!p)return;let c=wn(p.properties,void 0);if(!c)return;if(o.id.type===V.AST_NODE_TYPES.ObjectPattern){let T=wn(o.id.properties,s.returnProp);if(!T)return;for(let[I,b]of c)T.has(I)||e.report({node:b,messageId:"unusedSelectedValue",data:{name:I}});return}if(o.id.type!==V.AST_NODE_TYPES.Identifier||s.returnProp)return;let f=hi(o,e.sourceCode);if(f.length===0)return;let y=new Set;for(let T of f){if(T.identifier.parent.type!==V.AST_NODE_TYPES.MemberExpression)return;let I=T.identifier.parent.property;if(I.type!==V.AST_NODE_TYPES.Identifier)return;y.add(I.name)}for(let[T,I]of c)y.has(T)||e.report({node:I,messageId:"unusedSelectedValue",data:{name:T}})}}}})};function gi(e,t,r){let n=e.arguments[t];if(!n)return null;if(n.type===V.AST_NODE_TYPES.ArrowFunctionExpression||n.type===V.AST_NODE_TYPES.FunctionExpression)return n;if(r&&n.type===V.AST_NODE_TYPES.ObjectExpression){let o=n.properties.find(i=>i.type===V.AST_NODE_TYPES.Property&&i.key.type===V.AST_NODE_TYPES.Identifier&&i.key.name===r);if(o?.type!==V.AST_NODE_TYPES.Property)return null;let a=o.value;if(a.type===V.AST_NODE_TYPES.ArrowFunctionExpression||a.type===V.AST_NODE_TYPES.FunctionExpression)return a}return null}function Si(e){return e.callee.type===V.AST_NODE_TYPES.Identifier?e.callee.name:e.callee.type===V.AST_NODE_TYPES.MemberExpression&&e.callee.property.type===V.AST_NODE_TYPES.Identifier?e.callee.property.name:null}function Ti(e){if(e.body.type===V.AST_NODE_TYPES.ObjectExpression)return e.body;if(e.body.type===V.AST_NODE_TYPES.BlockStatement){let t=e.body.body.filter(r=>r.type===V.AST_NODE_TYPES.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==V.AST_NODE_TYPES.ObjectExpression?null:t[0].argument}return null}function wn(e,t){let r=e;if(t){let o=e.find(a=>a.type===V.AST_NODE_TYPES.Property&&a.key.type===V.AST_NODE_TYPES.Identifier&&a.key.name===t);if(o?.type!==V.AST_NODE_TYPES.Property||o.value.type!==V.AST_NODE_TYPES.ObjectPattern)return null;r=o.value.properties}let n=new Map;for(let o of r){if(o.type!==V.AST_NODE_TYPES.Property||o.key.type!==V.AST_NODE_TYPES.Identifier)return null;n.set(o.key.name,o)}return n.size>0?n:null}function hi(e,t){let r=t.getDeclaredVariables(e);if(r.length!==1)return[];let n=r[0];return n?n.references.filter(o=>o.identifier!==e.id):[]}var q=require("@typescript-eslint/utils");var vt=G({name:"no-unused-t-state-field",meta:{type:"suggestion",docs:{description:"Prevent declaring unused t-state fields"},messages:{unusedField:'Field "{{name}}" is not being used, you can safely remove it'},schema:[]},defaultOptions:[],create(e){if(!(e.filename.endsWith(".jsx")||e.filename.endsWith(".tsx")))return{};if(!e.sourceCode.ast.body.some(a=>a.type===q.AST_NODE_TYPES.ImportDeclaration&&a.source.value==="t-state-form"))return{};let n=null,o=!1;return{CallExpression(a){if(o)return;if(!n){let s=Ei(a);s&&(n=s);return}let i=bi(a,e.sourceCode);if(i){o=!0;for(let s of i)n.delete(s);if(n.size!==0)for(let[s,l]of n)e.report({node:l,messageId:"unusedField",data:{name:s}})}}}}});function Ei(e){if(!(e.callee.type===q.AST_NODE_TYPES.Identifier&&e.callee.name==="useForm"))return null;let r=e.arguments[0];if(!r||r.type!==q.AST_NODE_TYPES.ObjectExpression)return null;let n=Tt(r.properties,a=>a.type!==q.AST_NODE_TYPES.Property||a.key.type!==q.AST_NODE_TYPES.Identifier||a.key.name!=="initialConfig"?null:a.value.type===q.AST_NODE_TYPES.ObjectExpression?a.value:a.value.type===q.AST_NODE_TYPES.ArrowFunctionExpression||a.value.type===q.AST_NODE_TYPES.FunctionExpression?xi(a.value):null);if(!n)return null;let o=new Map;for(let a of n.properties)a.type===q.AST_NODE_TYPES.Property&&a.key.type===q.AST_NODE_TYPES.Identifier&&o.set(a.key.name,a);return o}function bi(e,t){if(!(e.callee.type===q.AST_NODE_TYPES.Identifier&&e.callee.name==="useFormState")||e.parent.type!==q.AST_NODE_TYPES.VariableDeclarator||e.parent.id.type!==q.AST_NODE_TYPES.ObjectPattern||!Tt(e.parent.id.properties,i=>i.type===q.AST_NODE_TYPES.Property&&i.key.type===q.AST_NODE_TYPES.Identifier&&i.key.name==="formFields"&&i))return null;let o=hn(e.parent,"formFields",t),a=new Set;for(let{identifier:i}of o){if(i.type!==q.AST_NODE_TYPES.Identifier||i.parent.type===q.AST_NODE_TYPES.Property&&i.parent.parent.type===q.AST_NODE_TYPES.ObjectExpression&&i.parent.parent.parent.type===q.AST_NODE_TYPES.ReturnStatement||i.parent.type===q.AST_NODE_TYPES.ReturnStatement)return null;if(i.parent.type===q.AST_NODE_TYPES.MemberExpression){if(i.parent.object.type!==q.AST_NODE_TYPES.Identifier||i.parent.property.type!==q.AST_NODE_TYPES.Identifier)return null;a.add(i.parent.property.name)}}return a}function xi(e){if(e.body.type===q.AST_NODE_TYPES.ObjectExpression)return e.body;if(e.body.type===q.AST_NODE_TYPES.BlockStatement){let t=e.body.body.filter(r=>r.type===q.AST_NODE_TYPES.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==q.AST_NODE_TYPES.ObjectExpression?null:t[0].argument}return null}var U=require("@typescript-eslint/utils");var Ii=U.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function An(e){let t=[];for(let r of e.members)r.type===U.AST_NODE_TYPES.TSPropertySignature&&r.key.type===U.AST_NODE_TYPES.Identifier&&t.push([r.key.name,r]);return t}function Rn(e,...t){for(let r of t)e.set(...r);return e}var Ci=Y({forceCheckOnFCPropTypesWithName:$(ne(H()))}),vn="no-unused-type-props-in-args",kt=null,wi=Ii({name:vn,meta:{type:"problem",docs:{description:"Disallow unused undestructured object type properties"},messages:{unusedObjectTypeProperty:"Object type property '{{ propertyName }}' is defined but never used",missingComponentParam:"Component has declared props but no props are used"},schema:[Ci],fixable:"code"},defaultOptions:[{}],create(e,[t]){let{forceCheckOnFCPropTypesWithName:r}=t;r&&!kt&&(kt=r.map(s=>new RegExp(s)));function n(s,l,p,c,f=!0){let y=p.name,T=e.sourceCode.getScope(l).references.find(E=>E.identifier.name===y)?.resolved,I=s&&kt?.some(E=>E.test(y));if(!T||!I&&T.references.filter(E=>E.isTypeReference).length>1)return;let b=T?.defs[0]?.node;if(!(f&&b?.parent?.type===U.AST_NODE_TYPES.ExportNamedDeclaration)){if(b?.type===U.AST_NODE_TYPES.TSTypeAliasDeclaration){o(s,l,c,b.typeAnnotation,!0);return}if(b?.type===U.AST_NODE_TYPES.TSInterfaceDeclaration){o(s,l,c,b.body,!0);return}}}function o(s,l,p,c,f){if(c.type===U.AST_NODE_TYPES.TSInterfaceBody){for(let y of c.body)y.type===U.AST_NODE_TYPES.TSPropertySignature&&y.key.type===U.AST_NODE_TYPES.Identifier&&p.set(y.key.name,y);return}if(c.type===U.AST_NODE_TYPES.TSTypeLiteral){Rn(p,...An(c));return}if(c.type===U.AST_NODE_TYPES.TSIntersectionType){for(let y of c.types)o(s,l,p,y,!0);return}f||c.type===U.AST_NODE_TYPES.TSTypeReference&&c.typeName.type===U.AST_NODE_TYPES.Identifier&&n(s,l,c.typeName,p)}function a(s,l,p){for(let c of p)if(c.type==="ObjectPattern"&&c.typeAnnotation){let f=new Map;if(o(s,l,f,c.typeAnnotation.typeAnnotation,!1),f.size===0)continue;i(c,f)}else c.type===U.AST_NODE_TYPES.AssignmentPattern&&c.left.type===U.AST_NODE_TYPES.ObjectPattern&&a(s,l,[c.left])}function i(s,l){let p=[];if(s.properties.at(-1)?.type===U.AST_NODE_TYPES.RestElement)return;for(let T of s.properties)T.type===U.AST_NODE_TYPES.Property&&T.key.type===U.AST_NODE_TYPES.Identifier&&p.push(T.key.name);let f=[],y=[];for(let[T,I]of l)p.includes(T)||(y.push(T),f.push({node:I,messageId:"unusedObjectTypeProperty",data:{propertyName:T}}));for(let[T,I]of f.entries())e.report({...I,fix:T===f.length-1?b=>{let E=s.properties.at(-1),u=y.join(", ");return E?E?.type===U.AST_NODE_TYPES.RestElement?null:b.insertTextAfter(E,`, ${u}`):b.insertTextBeforeRange([s.range[0]+1,s.range[1]],`${u}`)}:void 0})}return{VariableDeclaration(s){let l=s.declarations[0];if(!l)return;let p=new Map,c=l.id.type===U.AST_NODE_TYPES.Identifier&&l.id.typeAnnotation?.typeAnnotation.type===U.AST_NODE_TYPES.TSTypeReference&&l.id.typeAnnotation.typeAnnotation.typeName.type===U.AST_NODE_TYPES.Identifier&&l.id.typeAnnotation.typeAnnotation.typeName.name==="FC"&&l.id.typeAnnotation.typeAnnotation.typeArguments?.params[0];if(c){if(c.type===U.AST_NODE_TYPES.TSTypeReference&&c.typeName.type===U.AST_NODE_TYPES.Identifier)n(!0,s,c.typeName,p,!1);else if(c.type===U.AST_NODE_TYPES.TSTypeLiteral)Rn(p,...An(c));else if(c.type===U.AST_NODE_TYPES.TSIntersectionType)for(let f of c.types)f.type===U.AST_NODE_TYPES.TSTypeReference&&f.typeName.type===U.AST_NODE_TYPES.Identifier?n(!0,s,f.typeName,p,!1):o(!0,s,p,f,!0);if(p.size!==0&&l.init?.type===U.AST_NODE_TYPES.ArrowFunctionExpression){let f=l.init.params[0];if(!f){e.report({node:l.init,messageId:"missingComponentParam"});return}f.type===U.AST_NODE_TYPES.ObjectPattern&&i(f,p)}}},FunctionDeclaration:function(s){a(!1,s,s.params)},ArrowFunctionExpression(s){a(!1,s,s.params)}}}}),Ot={name:vn,rule:wi};var ce=require("@typescript-eslint/utils");var Pt=G({name:"no-write-only-ref",meta:{type:"problem",docs:{description:"Disallow creating refs that are never read"},messages:{refNotRead:'Ref "{{name}}" is never read. Consider removing it if not needed.'},schema:[]},defaultOptions:[],create(e){let t=new Set;function r(n){return n.callee.type===ce.AST_NODE_TYPES.Identifier?t.has(n.callee.name):n.callee.type===ce.AST_NODE_TYPES.MemberExpression&&n.callee.object.type===ce.AST_NODE_TYPES.Identifier&&n.callee.property.type===ce.AST_NODE_TYPES.Identifier?n.callee.property.name==="useRef":!1}return{ImportDeclaration(n){if(n.source.value==="react")for(let o of n.specifiers)o.type===ce.AST_NODE_TYPES.ImportSpecifier&&o.imported.type===ce.AST_NODE_TYPES.Identifier&&o.imported.name==="useRef"&&t.add(o.local.name)},VariableDeclarator(n){if(n.init&&n.init.type===ce.AST_NODE_TYPES.CallExpression&&r(n.init)&&n.id.type===ce.AST_NODE_TYPES.Identifier){let a=e.sourceCode.getScope(n).set.get(n.id.name);if(a){let i=!1;for(let s of a.references){let p=s.identifier.parent;if(p!==n&&!(p.type===ce.AST_NODE_TYPES.JSXExpressionContainer&&p.parent.type===ce.AST_NODE_TYPES.JSXAttribute&&p.parent.name.type===ce.AST_NODE_TYPES.JSXIdentifier&&p.parent.name.name==="ref")){i=!0;break}}i||e.report({node:n.id,messageId:"refNotRead",data:{name:n.id.name}})}}}}}});var je=require("@typescript-eslint/utils"),Ai=je.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),On="prefer-named-functions",kn=new Map,Ri=Ai({name:On,meta:{hasSuggestions:!0,type:"suggestion",docs:{description:"Prevent using arrow functions when a named function can be used instead"},schema:[{type:"object",properties:{ignoreRegex:{type:"string"},disallowArrowFnWithImplicitReturns:{type:"boolean"}}}],messages:{suggestion:"Convert to named function",default:'Function {{functionName}} should be defined as a named function "function {{functionName}} () {}" instead of an arrow function',withIgnoreRegex:'Function {{functionName}} should be defined as a named function "function {{functionName}} () {}", if not possible to use `function` you can also use a name that matches the rule ignore regex'}},defaultOptions:[{}],create(e,[t]){let r=null;if(t.ignoreRegex){let n=kn.get(t.ignoreRegex);n?r=n:(r=new RegExp(t.ignoreRegex),kn.set(t.ignoreRegex,r))}return{VariableDeclarator(n){if(n.init&&n.init.type===je.AST_NODE_TYPES.ArrowFunctionExpression&&n.id.type===je.AST_NODE_TYPES.Identifier){let o=n.id.name;if(n.id.typeAnnotation||r&&r.test(o)||!t.disallowArrowFnWithImplicitReturns&&n.init.body.type!==je.AST_NODE_TYPES.BlockStatement)return;let a=n.parent,i=n.init.params,s=n.init.body,l=n.init;e.report({node:n.id,messageId:r?"withIgnoreRegex":"default",data:{functionName:o,ignoreRegex:t.ignoreRegex},suggest:[{messageId:"suggestion",fix:p=>p.replaceText(a,`${l.async?"async ":""}function ${o}(${i.map(c=>e.sourceCode.getText(c)).join(", ")||""}) ${e.sourceCode.getText(s)}`)}]})}}}}}),Ft={name:On,rule:Ri};var M=require("@typescript-eslint/utils");var vi=Y({disallowedFunctions:ne(Y({name:H(),allowUsingWithArgs:$(Fe()),hookAlternative:$(H()),message:$(H()),allowUseInside:$(ne(H()))}))});function Ge(e){return/^use[A-Z]/.test(e)}function Pn(e){return/^[A-Z]/.test(e)}function ki(e){return e.type===M.AST_NODE_TYPES.Identifier?Ge(e.name):e.type===M.AST_NODE_TYPES.MemberExpression&&e.property.type===M.AST_NODE_TYPES.Identifier?Ge(e.property.name):!1}function Fn(e,t){return e.type===M.AST_NODE_TYPES.Identifier?e.name===t:e.type===M.AST_NODE_TYPES.MemberExpression&&e.object.type===M.AST_NODE_TYPES.Identifier&&e.property.type===M.AST_NODE_TYPES.Identifier?e.object.name==="React"&&e.property.name===t:!1}function Nn(e){return!!(e.parent&&e.parent.type===M.AST_NODE_TYPES.CallExpression&&Fn(e.parent.callee,"forwardRef"))}function Mn(e){return!!(e.parent&&e.parent.type===M.AST_NODE_TYPES.CallExpression&&Fn(e.parent.callee,"memo"))}function Nt(e){if(e.type===M.AST_NODE_TYPES.FunctionDeclaration||e.type===M.AST_NODE_TYPES.FunctionExpression&&e.id)return e.id||void 0;if(e.type===M.AST_NODE_TYPES.FunctionExpression||e.type===M.AST_NODE_TYPES.ArrowFunctionExpression){if(e.parent.type===M.AST_NODE_TYPES.VariableDeclarator&&e.parent.init===e)return e.parent.id;if(e.parent.type===M.AST_NODE_TYPES.AssignmentExpression&&e.parent.right===e&&e.parent.operator==="=")return e.parent.left;if(e.parent.type===M.AST_NODE_TYPES.Property&&e.parent.value===e&&!e.parent.computed)return e.parent.key;if(e.parent.type===M.AST_NODE_TYPES.AssignmentPattern&&e.parent.right===e)return e.parent.left}}function Oi(e){let t=e.parent,r=!1;for(;t;){if(t.type===M.AST_NODE_TYPES.FunctionDeclaration||t.type===M.AST_NODE_TYPES.FunctionExpression||t.type===M.AST_NODE_TYPES.ArrowFunctionExpression){let n=Nt(t);if(n&&n.type===M.AST_NODE_TYPES.Identifier){if(Pn(n.name)||Ge(n.name))return!r;r=!0}else{if(Nn(t)||Mn(t))return!r;if(t.parent.type===M.AST_NODE_TYPES.CallExpression){let o=t.parent;ki(o.callee)||(r=!0)}else t.parent.type===M.AST_NODE_TYPES.JSXExpressionContainer||(r=!0)}}t=t.parent}return!1}function jn(e){return e.callee.type===M.AST_NODE_TYPES.Identifier?e.callee.name:e.callee.type===M.AST_NODE_TYPES.MemberExpression&&e.callee.property.type===M.AST_NODE_TYPES.Identifier?e.callee.property.name:null}function Pi(e,t){if(!t.length)return!1;let r=e.parent;for(;r;){if(r.type===M.AST_NODE_TYPES.FunctionDeclaration||r.type===M.AST_NODE_TYPES.FunctionExpression||r.type===M.AST_NODE_TYPES.ArrowFunctionExpression){let n=Nt(r);if(n&&n.type===M.AST_NODE_TYPES.Identifier&&t.includes(n.name))return!0}else if(r.type===M.AST_NODE_TYPES.CallExpression){let n=jn(r);if(n&&t.includes(n))return!0}r=r.parent}return!1}function Fi(e){return e.arguments.length>0&&!e.arguments.every(t=>t.type===M.AST_NODE_TYPES.Identifier&&t.name==="undefined")}function Ni(e,t){let r=!1,n=e.parent;for(;n;){if(n.type===M.AST_NODE_TYPES.FunctionDeclaration||n.type===M.AST_NODE_TYPES.FunctionExpression||n.type===M.AST_NODE_TYPES.ArrowFunctionExpression){let o=Nt(n);if(o&&o.type===M.AST_NODE_TYPES.Identifier){if(Pn(o.name)||Ge(o.name)){r=!0;break}}else if(Nn(n)||Mn(n)){r=!0;break}}n=n.parent}return r?t.length===0?Oi(e):!Pi(e,t):!1}var Mt=G({name:"prefer-react-hook-alternative",meta:{type:"suggestion",docs:{description:"Prefer hook alternatives for certain functions in React components and hooks"},messages:{preferHookAlternative:"This function should not be used in react{{message}}."},schema:[vi],hasSuggestions:!0},defaultOptions:[{disallowedFunctions:[]}],create(e,[t]){let{disallowedFunctions:r}=t,n=new Map(r.map(o=>[o.name,o]));return{CallExpression(o){let a=jn(o);if(!a)return;let i=n.get(a);if(!i||i.allowUsingWithArgs&&Fi(o))return;let s=i.allowUseInside||[];Ni(o,s)&&e.report({node:o,messageId:"preferHookAlternative",data:{message:i.message?` ${i.message}`:` use ${i.hookAlternative} instead`},suggest:i.hookAlternative?[{messageId:"preferHookAlternative",data:{message:`Replace with ${i.hookAlternative}`,hookAlternative:i.hookAlternative},fix:l=>{let p=i.hookAlternative;return o.callee.type===M.AST_NODE_TYPES.Identifier?l.replaceText(o.callee,p):o.callee.type===M.AST_NODE_TYPES.MemberExpression&&o.callee.property.type===M.AST_NODE_TYPES.Identifier?l.replaceText(o.callee.property,p):null}}]:[]})}}}});var J=require("@typescript-eslint/utils");var Mi=J.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ln="prefer-single-line-if",ji=Y({maxLineLength:$(de()),maxNonSimpleConditionLength:$(de())}),Di=Mi({name:Ln,meta:{type:"suggestion",fixable:"code",docs:{description:"Enforce single-line if in simple if statements"},messages:{noSingleLineCurly:"If return statement with single statement body should be written in a single line"},schema:[ji]},defaultOptions:[{}],create(e,[t]){let r=e.sourceCode;return{IfStatement(n){if(n.consequent.type!==J.AST_NODE_TYPES.BlockStatement||n.loc.start.line===n.loc.end.line||r.getCommentsInside(n.consequent).length>0||n.alternate||n.consequent.body.length!==1)return;let a=n.consequent.body[0];if(a.type===J.AST_NODE_TYPES.ReturnStatement){if(!$n(a))return}else if(!(a.type===J.AST_NODE_TYPES.ContinueStatement||a.type===J.AST_NODE_TYPES.BreakStatement))return;if(n.test.type===J.AST_NODE_TYPES.LogicalExpression||n.test.type===J.AST_NODE_TYPES.ConditionalExpression)return;let i;if(t.maxNonSimpleConditionLength){let f=Dn(n.test);if(!f&&n.test.type===J.AST_NODE_TYPES.UnaryExpression&&n.test.operator==="!"){let y=n.test.argument;Dn(y)&&(f=!0)}if(f&&(i=r.getText(n.test),i.length>t.maxNonSimpleConditionLength))return}i||(i=r.getText(n.test));let s=r.getText(a);if(i.includes(`
|
|
16
|
-
`))return;let l=r.getTokenAfter(n);if(l&&l.type===J.AST_TOKEN_TYPES.Punctuator&&l.value==="}"){let f=r.getTokenAfter(l);if(f&&f.type===J.AST_TOKEN_TYPES.Keyword&&(f.value==="else"||f.value==="catch"))return}let p=Li(r,n),c=`if (${i}) ${s}`;t.maxLineLength&&c.length+p.length>t.maxLineLength||e.report({node:n,messageId:"noSingleLineCurly",fix:f=>f.replaceText(n,c)})}}}});function Dn(e){return e.type===J.AST_NODE_TYPES.CallExpression||e.type===J.AST_NODE_TYPES.BinaryExpression||e.type===J.AST_NODE_TYPES.MemberExpression&&_n(e)}function _n(e){return e.object.type===J.AST_NODE_TYPES.MemberExpression?_n(e.object):e.object.type!==J.AST_NODE_TYPES.Identifier}function Li(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}function $n(e){if(!e.argument)return!0;let t=e.argument;return t.type===J.AST_NODE_TYPES.ArrayExpression&&t.elements.length===0||t.type===J.AST_NODE_TYPES.ObjectExpression&&t.properties.length===0||t.type===J.AST_NODE_TYPES.Literal||t.type===J.AST_NODE_TYPES.Identifier||t.type===J.AST_NODE_TYPES.TemplateLiteral||t.type===J.AST_NODE_TYPES.TaggedTemplateExpression?!0:t.type===J.AST_NODE_TYPES.CallExpression?t.arguments.length===0:t.type===J.AST_NODE_TYPES.UnaryExpression?$n(t):!1}var jt={name:Ln,rule:Di};var se=require("@typescript-eslint/utils");var _i=se.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Un="react-compiler-migration",$i=Y({disallowHooks:$(ne(Y({name:H(),replacement:H()}))),disallowMethods:$(ne(Y({name:H(),replacement:$(H()),requireTrueProp:$(H())})))}),Ui=/eslint +react-compiler\/react-compiler: +\["error/;function Wi(e){return e.type===se.AST_NODE_TYPES.Identifier?e.name.startsWith("use"):e.type===se.AST_NODE_TYPES.MemberExpression&&e.property.type===se.AST_NODE_TYPES.Identifier?e.property.name.startsWith("use"):!1}var Vi=_i({name:Un,meta:{type:"suggestion",fixable:"code",docs:{description:"Rules to help migrate to the new React compiler"},messages:{disallowedFunctionOrMethod:"{{functionOrMethod}} is not supported in react compiler. Use {{replacement}} instead.",replace:"Replace with safe alternative {{replacement}}",disallowedMethodWithMissingRequireTrueProp:"{{method}} is should have a prop named {{requireTrueProp}} set to true when used in react compiler."},hasSuggestions:!0,schema:[$i]},defaultOptions:[{}],create(e,[t]){let r=!1;for(let n of e.sourceCode.getAllComments())if(Ui.test(n.value)){r=!0;break}return r?{CallExpression(n){if(t.disallowHooks?.length){let o=null,a=null;if(n.callee.type===se.AST_NODE_TYPES.Identifier?(o=n.callee.name,a=n.callee):n.callee.type===se.AST_NODE_TYPES.MemberExpression&&n.callee.property.type===se.AST_NODE_TYPES.Identifier&&(o=n.callee.property.name,a=n.callee.property),o){let i=t.disallowHooks.find(s=>s.name===o);i&&a&&e.report({node:n,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:i.name,replacement:i.replacement},suggest:[{messageId:"replace",data:{replacement:i.replacement},fix:s=>s.replaceText(a,i.replacement)}]})}}if(t.disallowMethods?.length&&Wi(n.callee)){for(let o of n.arguments)if(o.type===se.AST_NODE_TYPES.ObjectExpression){for(let a of o.properties)if(a.type===se.AST_NODE_TYPES.Property&&a.key.type===se.AST_NODE_TYPES.Identifier){let i=a.key.name,s=t.disallowMethods.find(l=>l.name===i);if(s){if(s.requireTrueProp){let l=s.requireTrueProp,p=!1;for(let c of o.properties)if(c.type===se.AST_NODE_TYPES.Property&&c.key.type===se.AST_NODE_TYPES.Identifier&&c.key.name===l&&c.value.type===se.AST_NODE_TYPES.Literal&&c.value.value===!0){p=!0;break}if(!p){e.report({node:a,messageId:"disallowedMethodWithMissingRequireTrueProp",data:{method:s.name,requireTrueProp:l}});continue}}s.replacement&&e.report({node:a,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:s.name,replacement:s.replacement},suggest:[{messageId:"replace",data:{replacement:s.replacement},fix:l=>l.replaceText(a.key,s.replacement)}]})}}}}}}:{}}}),Dt={name:Un,rule:Vi};var Ke=require("@typescript-eslint/utils"),zi=Ke.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Wn="require-description",Hi=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,Yi=/^eslint-disable-(next-)?line$/u,qi=zi({name:Wn,meta:{type:"problem",docs:{description:"Require descriptions for eslint directives."},messages:{missingDescription:"Unexpected undescribed directive comment. Include descriptions to explain why the comment is necessary."},schema:[{type:"object",properties:{ignore:{type:"array",items:{type:"string",enum:["eslint","eslint-disable","eslint-disable-line","eslint-disable-next-line","eslint-enable","eslint-env","exported","global","globals"]},additionalItems:!1,uniqueItems:!0}},additionalProperties:!1}]},defaultOptions:[{ignore:[]}],create(e,[t]){let r=e.sourceCode,n=new Set(t.ignore||[]);return{Program(){for(let o of r.getAllComments()){let a=Ji(o);a!=null&&(n.has(a.kind)||a.description||e.report({loc:Xi(o.loc),messageId:"missingDescription"}))}}}}}),Vn={name:Wn,rule:qi};function Ji(e){let{text:t,description:r}=Bi(e.value);if(!t)return null;let n=Hi.exec(t);if(!n)return null;let o=n[1];if(!o)return null;let a=Yi.test(o);if(e.type===Ke.TSESTree.AST_TOKEN_TYPES.Line&&!a||a&&e.loc.start.line!==e.loc.end.line)return null;let i=t.slice(n.index+o.length);return{kind:o,value:i.trim(),description:r}}function Bi(e){let t=e.split(/\s-{2,}\s/u);return{text:t[0]?.trim(),description:t.length>1?t[1]?.trim()??null:null}}function Xi(e){return{start:{line:e.start.line,column:-1},end:e.end}}var L=require("@typescript-eslint/utils"),ye=require("zod/v4");var Gi=ye.z.object({varsToCheck:ye.z.array(ye.z.object({selector:ye.z.string().optional(),fromFnCall:ye.z.string().optional(),prop:ye.z.string().or(ye.z.array(ye.z.string())),errorMsg:ye.z.string().optional()}))}),Lt=G({name:"require-reads-to-var-prop",meta:{type:"suggestion",docs:{description:"Require specific properties from variables to be read or ensure the variable is passed to functions/components"},messages:{propNotRead:'"{{fnName}}" requires reads to the prop "{{prop}}". {{customMsg}}',propsNotRead:'"{{fnName}}" requires reads to the props {{props}}. {{customMsg}}'},schema:[Ie(Gi)]},defaultOptions:[{varsToCheck:[]}],create(e,[t]){let r=new Map,n=(i,s,l,p)=>{let c=new Set;for(let y of i.properties)y.type===L.AST_NODE_TYPES.Property&&y.key.type===L.AST_NODE_TYPES.Identifier&&c.add(y.key.name);let f=s.filter(y=>!c.has(y));if(f.length>0)if(f.length===1)e.report({node:i,messageId:"propNotRead",data:{prop:f[0],fnName:p,customMsg:l||""}});else{let y=f.map(T=>`"${T}"`).join(", ");e.report({node:i,messageId:"propsNotRead",data:{props:y,fnName:p,customMsg:l||""}})}},o=i=>{if(i.init?.type===L.AST_NODE_TYPES.CallExpression){if(i.init.callee.type===L.AST_NODE_TYPES.Identifier)return i.init.callee.name;if(i.init.callee.type===L.AST_NODE_TYPES.MemberExpression&&i.init.callee.property.type===L.AST_NODE_TYPES.Identifier)return i.init.callee.object.type===L.AST_NODE_TYPES.Identifier?`${i.init.callee.object.name}.${i.init.callee.property.name}`:i.init.callee.property.name}return"unknown function"},a={};for(let i of t.varsToCheck)i.selector&&(a[i.selector]=s=>{if(s.type===L.AST_NODE_TYPES.VariableDeclarator&&s.id.type===L.AST_NODE_TYPES.Identifier&&r.set(s.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:s.id,fnName:o(s)}),s.type===L.AST_NODE_TYPES.VariableDeclarator&&s.id.type===L.AST_NODE_TYPES.ObjectPattern){let l=Array.isArray(i.prop)?i.prop:[i.prop];n(s.id,l,i.errorMsg,o(s))}});for(let i of t.varsToCheck)if(i.fromFnCall){let s=i.fromFnCall;if(s.startsWith("*.")){let p=`VariableDeclarator > CallExpression > MemberExpression[property.name="${s.slice(2)}"]`;a[p]=c=>{if(c.type!==L.AST_NODE_TYPES.MemberExpression||c.parent.type!==L.AST_NODE_TYPES.CallExpression)return;let f=c.parent;if(f.parent.type!==L.AST_NODE_TYPES.VariableDeclarator)return;let y=f.parent;if(y.id.type===L.AST_NODE_TYPES.Identifier)r.set(y.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:y.id,fnName:i.fromFnCall||"unknown function"});else if(y.id.type===L.AST_NODE_TYPES.ObjectPattern){let T=Array.isArray(i.prop)?i.prop:[i.prop];n(y.id,T,i.errorMsg,i.fromFnCall||"unknown function")}}}else if(s.includes(".")){let[l,p]=s.split("."),c=`VariableDeclarator > CallExpression > MemberExpression[object.name="${l}"][property.name="${p}"]`;a[c]=f=>{if(f.type!==L.AST_NODE_TYPES.MemberExpression||f.parent.type!==L.AST_NODE_TYPES.CallExpression)return;let y=f.parent;if(y.parent.type!==L.AST_NODE_TYPES.VariableDeclarator)return;let T=y.parent;if(T.id.type===L.AST_NODE_TYPES.Identifier)r.set(T.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:T.id,fnName:i.fromFnCall||"unknown function"});else if(T.id.type===L.AST_NODE_TYPES.ObjectPattern){let I=Array.isArray(i.prop)?i.prop:[i.prop];n(T.id,I,i.errorMsg,i.fromFnCall||"unknown function")}}}else{let l=`VariableDeclarator > CallExpression > Identifier[name="${s}"]`;a[l]=p=>{if(p.type!==L.AST_NODE_TYPES.Identifier||p.parent.type!==L.AST_NODE_TYPES.CallExpression)return;let c=p.parent;if(c.parent.type!==L.AST_NODE_TYPES.VariableDeclarator)return;let f=c.parent;if(f.id.type===L.AST_NODE_TYPES.Identifier)r.set(f.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:f.id,fnName:i.fromFnCall||"unknown function"});else if(f.id.type===L.AST_NODE_TYPES.ObjectPattern){let y=Array.isArray(i.prop)?i.prop:[i.prop];n(f.id,y,i.errorMsg,i.fromFnCall||"unknown function")}}}}return{...a,"Program:exit"(){for(let[i,{props:s,errorMsg:l,node:p,fnName:c}]of r){let y=e.sourceCode.getScope(p).set.get(i);if(y){let T=new Set(s);for(let I of y.references){let b=I.identifier,E=b.parent;if(!(E.type===L.AST_NODE_TYPES.VariableDeclarator&&E.id===b)){if(E.type===L.AST_NODE_TYPES.MemberExpression&&E.object===b&&E.property.type===L.AST_NODE_TYPES.Identifier&&T.has(E.property.name)){if(T.delete(E.property.name),T.size===0)break;continue}if(E.type===L.AST_NODE_TYPES.VariableDeclarator&&E.init===b&&E.id.type===L.AST_NODE_TYPES.ObjectPattern){for(let u of E.id.properties)u.type===L.AST_NODE_TYPES.Property&&u.key.type===L.AST_NODE_TYPES.Identifier&&T.has(u.key.name)&&T.delete(u.key.name);if(T.size===0)break;continue}if(!(E.type===L.AST_NODE_TYPES.MemberExpression&&E.object===b&&E.property.type===L.AST_NODE_TYPES.Identifier&&!s.includes(E.property.name))){T.clear();break}}}if(T.size>0){let I=Array.from(T);if(I.length===1)e.report({node:p,messageId:"propNotRead",data:{prop:I[0],fnName:c,customMsg:l||""}});else{let b=I.map(E=>`"${E}"`).join(", ");e.report({node:p,messageId:"propsNotRead",data:{props:b,fnName:c,customMsg:l||""}})}}}}}}}});function Yn(e){return/^use[A-Z0-9]/.test(e)}function Ze(e){return e.type==="Identifier"?Yn(e.name):e.type==="MemberExpression"&&!e.computed&&Ze(e.property)?e.object.type==="Identifier":!1}function qn(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function Jn(e,t){return e.name===t||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===t}function Bn(e){return!!(e.parent&&e.parent.callee&&Jn(e.parent.callee,"forwardRef"))}function Xn(e){return!!(e.parent&&e.parent.callee&&Jn(e.parent.callee,"memo"))}function _t(e){for(;e;){let t=Kn(e);if(t&&(qn(t)||Ze(t))||Bn(e)||Xn(e))return!0;e=e.parent}return!1}function zn(e){return!1}function $t(e){return!1}var Ki=/eslint +react-compiler\/react-compiler: +\["error/,Gn={meta:{type:"problem",docs:{description:"enforces the Rules of Hooks",recommended:!0,url:"https://reactjs.org/docs/hooks-rules.html"},schema:[{type:"object",ignoreIfReactCompilerIsEnabled:!1,properties:{ignoreIfReactCompilerIsEnabled:{type:"boolean"}}}]},create(e){if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let l of e.sourceCode.getAllComments())if(Ki.test(l.value))return{CallExpression(p){let c=null;p.callee.name==="useMemo"?c="useMemo":p.callee.name==="useCallback"&&(c="useCallback"),c&&e.report({node:p,message:`"${c}" is not necessary when using React Compiler.`})}}}let t=typeof e.getSource=="function"?l=>t(l):l=>e.sourceCode.getText(l),r=typeof e.getScope=="function"?()=>r():l=>e.sourceCode.getScope(l),n=null,o=[],a=[],i=new WeakSet;function s(l){for(let p of l.references){let c=p.identifier.parent;if(c.type==="VariableDeclarator"&&c.init&&c.init.type==="CallExpression"&&c.init.callee&&zn(c.init.callee))for(let f of p.resolved.references)f!==p&&i.add(f.identifier)}}return{onCodePathSegmentStart:l=>a.push(l),onCodePathSegmentEnd:()=>a.pop(),onCodePathStart:()=>o.push(new Map),onCodePathEnd(l,p){let c=o.pop();if(c.size===0)return;let f=new Set;function y(g,m){let{cache:S}=y,k=S.get(g.id),R=new Set(m);if(R.has(g.id)){let C=[...R],N=C.slice(C.indexOf(g.id)+1);for(let z of N)f.add(z);return BigInt("0")}if(R.add(g.id),k!==void 0)return k;if(l.thrownSegments.includes(g))k=BigInt("0");else if(g.prevSegments.length===0)k=BigInt("1");else{k=BigInt("0");for(let C of g.prevSegments)k+=y(C,R)}return g.reachable&&k===BigInt("0")?S.delete(g.id):S.set(g.id,k),k}function T(g,m){let{cache:S}=T,k=S.get(g.id),R=new Set(m);if(R.has(g.id)){let C=Array.from(R),N=C.slice(C.indexOf(g.id)+1);for(let z of N)f.add(z);return BigInt("0")}if(R.add(g.id),k!==void 0)return k;if(l.thrownSegments.includes(g))k=BigInt("0");else if(g.nextSegments.length===0)k=BigInt("1");else{k=BigInt("0");for(let C of g.nextSegments)k+=T(C,R)}return S.set(g.id,k),k}function I(g){let{cache:m}=I,S=m.get(g.id);if(S===null)return 1/0;if(S!==void 0)return S;if(m.set(g.id,null),g.prevSegments.length===0)S=1;else{S=1/0;for(let k of g.prevSegments){let R=I(k);R<S&&(S=R)}S+=1}return m.set(g.id,S),S}y.cache=new Map,T.cache=new Map,I.cache=new Map;let b=T(l.initialSegment),E=Kn(p),u=_t(p),A=E?qn(E)||Ze(E):Bn(p)||Xn(p),x=1/0;for(let g of l.finalSegments){if(!g.reachable)continue;let m=I(g);m<x&&(x=m)}for(let[g,m]of c){if(!g.reachable)continue;let S=g.nextSegments.length===0?x<=I(g):x<I(g),k=y(g)*T(g),R=f.has(g.id);for(let C of m)if(R&&!$t(C)&&e.report({node:C,message:`React Hook "${t(C)}" may be executed more than once. Possibly because it is called in a loop. React Hooks must be called in the exact same order in every component render.`}),A){if(p.async&&e.report({node:C,message:`React Hook "${t(C)}" cannot be called in an async function.`}),!R&&k!==b&&!$t(C)){let z=`React Hook "${t(C)}" is called conditionally. React Hooks must be called in the exact same order in every component render.`+(S?" Did you accidentally call a React Hook after an early return?":"");e.report({node:C,message:z})}}else if(p.parent&&(p.parent.type==="MethodDefinition"||p.parent.type==="ClassProperty")&&p.parent.value===p){let N=`React Hook "${t(C)}" cannot be called in a class component. React Hooks must be called in a React function component or a custom React Hook function.`;e.report({node:C,message:N})}else if(E){let N=`React Hook "${t(C)}" is called in function "${t(E)}" that is neither a React function component nor a custom React Hook function. React component names must start with an uppercase letter. React Hook names must start with the word "use".`;e.report({node:C,message:N})}else if(p.type==="Program"){let N=`React Hook "${t(C)}" cannot be called at the top level. React Hooks must be called in a React function component or a custom React Hook function.`;e.report({node:C,message:N})}else if(u&&!$t(C)){if(p.parent.type==="CallExpression"&&p.parent.callee.type==="Identifier"&&p.parent.callee.name==="useCallback"){let z=p.parent;if(z.parent.type==="VariableDeclarator"&&Yn(z.parent.id.name))return}let N=`React Hook "${t(C)}" cannot be called inside a callback. React Hooks must be called in a React function component or a custom React Hook function.`;e.report({node:C,message:N})}}},CallExpression(l){if(Ze(l.callee)){let p=Hn(o),c=Hn(a),f=p.get(c);f||(f=[],p.set(c,f)),f.push(l.callee)}l.callee.type==="Identifier"&&(l.callee.name==="useEffect"||zn(l.callee))&&l.arguments.length>0&&(n=l)},Identifier(l){n==null&&i.has(l)&&l.parent.type!=="CallExpression"&&e.report({node:l,message:`\`${t(l)}\` is a function created with React Hook "useEffectEvent", and can only be called from the same component. They cannot be assigned to variables or passed down.`})},"CallExpression:exit"(l){l===n&&(n=null)},FunctionDeclaration(l){_t(l)&&s(r(l))},ArrowFunctionExpression(l){_t(l)&&s(r(l))}}}};function Kn(e){return e.type==="FunctionDeclaration"||e.type==="FunctionExpression"&&e.id?e.id:e.type==="FunctionExpression"||e.type==="ArrowFunctionExpression"?e.parent.type==="VariableDeclarator"&&e.parent.init===e?e.parent.id:e.parent.type==="AssignmentExpression"&&e.parent.right===e&&e.parent.operator==="="?e.parent.left:e.parent.type==="Property"&&e.parent.value===e&&!e.parent.computed?e.parent.key:e.parent.type==="AssignmentPattern"&&e.parent.right===e&&!e.parent.computed?e.parent.left:void 0:void 0}function Hn(e){return e[e.length-1]}var Q=require("@typescript-eslint/utils"),oe=Re(require("zod/v4"));var Zi=oe.object({indent:oe.union([oe.string().regex(/^\s+$/),oe.number().int().min(1)]).optional(),tags:oe.array(oe.string()).optional(),functions:oe.array(oe.string()).optional(),comments:oe.array(oe.string()).optional()}),Ut=G({name:"template-indent",meta:{type:"suggestion",docs:{description:"Fix whitespace-insensitive template indentation"},fixable:"code",schema:[Ie(Zi)],messages:{improperlyIndented:"Templates should be properly indented."}},defaultOptions:[{}],create(e){let t=e.sourceCode,{comments:r=["HTML","indent"],functions:n=["dedent","stripIndent"],tags:o=["outdent","dedent","gql","sql","html","styled"],indent:a}=e.options[0],i=r.map(u=>u.toLowerCase());function s(u){let A=u.split(/\r?\n/),x=A.filter(m=>m.trim()!=="");if(x.length===0)return u;let g=Number.POSITIVE_INFINITY;for(let m of x){let S=m.match(/^(\s*)/);S&&(g=Math.min(g,S[1]?.length??0))}return!isFinite(g)||g===0?u:A.map(m=>m.slice(g)).join(`
|
|
17
|
-
`)}function l(u,A,
|
|
18
|
-
`)}function p(u){if(u.type===Q.AST_NODE_TYPES.Identifier)return u.name;if(u.type===Q.AST_NODE_TYPES.MemberExpression){let A=u.object.type===Q.AST_NODE_TYPES.Identifier?u.object.name:null,
|
|
15
|
+
Learn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching`});let S=l.acquire(u),k=new Set,R=null;{let d=S.upper;for(;d&&(k.add(d),d.type!=="function");)d=d.upper;if(!d)return;R=d}let C=Array.isArray;function N(d){if(!C(d.defs))return!1;let h=d.defs[0];if(h==null||h.node.type!=="VariableDeclarator")return!1;let v=h.node.init;if(v==null)return!1;for(;v.type==="TSAsExpression";)v=v.expression;let O=h.node.parent;if(O==null&&(lt(R.block,h.node.id),O=h.node.parent,O==null))return!1;if(O.kind==="const"&&v.type==="Literal"&&(typeof v.value=="string"||typeof v.value=="number"||v.value===null))return!0;if(v.type!=="CallExpression")return!1;let F=v.callee;if(F.type==="MemberExpression"&&F.object.name==="React"&&F.property!=null&&!F.computed&&(F=F.property),F.type!=="Identifier")return!1;let P=h.node.id,{name:M}=F;if(M==="useRef"&&P.type==="Identifier")return!0;if(vr(F)&&P.type==="Identifier"){for(let D of d.references)D!==P&&T.add(D.identifier);return!0}else if(M==="useState"||M==="useReducer"){if(P.type==="ArrayPattern"&&P.elements.length===2&&C(d.identifiers)){if(P.elements[1]===d.identifiers[0]){if(M==="useState"){let D=d.references,pe=0;for(let he=0;he<D.length;he++){if(D[he].isWrite()&&pe++,pe>1)return!1;p.set(D[he].identifier,P.elements[0])}}return!0}else if(P.elements[0]===d.identifiers[0]){if(M==="useState"){let D=d.references;for(let pe=0;pe<D.length;pe++)c.add(D[pe].identifier)}return!1}}}else if(M==="useTransition"&&P.type==="ArrayPattern"&&P.elements.length===2&&Array.isArray(d.identifiers)&&P.elements[1]===d.identifiers[0])return!0;return!1}function z(d){if(!C(d.defs))return!1;let h=d.defs[0];if(h==null||h.node==null||h.node.id==null)return!1;let v=h.node,O=R.childScopes,F=null,P;for(P=0;P<O.length;P++){let M=O[P],D=M.block;if(v.type==="FunctionDeclaration"&&D===v||v.type==="VariableDeclarator"&&D.parent===v){F=M;break}}if(F==null)return!1;for(P=0;P<F.through.length;P++){let M=F.through[P];if(M.resolved!=null&&k.has(M.resolved.scope)&&!B(M.resolved))return!1}return!0}let B=I(N,f),ne=I(z,y),ee=new Map;function xe(d){let h=d.from,v=!1;for(;h.block!==u;)h.type==="function"&&(v=h.block.parent!=null&&h.block.parent.type==="ReturnStatement"),h=h.upper;return v}let X=new Map,ye=new Map;fe(S);function fe(d){for(let h of d.references){if(!h.resolved||!k.has(h.resolved.scope))continue;let v=lt(u,h.identifier),O=sn(v),F=Ee(O,ye);if(m&&O.type==="Identifier"&&(O.parent.type==="MemberExpression"||O.parent.type==="OptionalMemberExpression")&&!O.parent.computed&&O.parent.property.type==="Identifier"&&O.parent.property.name==="current"&&xe(h)&&ee.set(F,{reference:h,dependencyNode:O}),O.parent.type==="TSTypeQuery"||O.parent.type==="TSTypeReference")continue;let P=h.resolved.defs[0];if(P!=null&&!(P.node!=null&&P.node.init===u.parent)&&P.type!=="TypeParameter")if(X.has(F))X.get(F).references.push(h);else{let M=h.resolved,D=B(M)||ne(M);X.set(F,{isStable:D,references:[h]})}}for(let h of d.childScopes)fe(h)}ee.forEach(({reference:d,dependencyNode:h},v)=>{let O=d.resolved.references,F=!1;for(let P=0;P<O.length;P++){let{identifier:M}=O[P],{parent:D}=M;if(D!=null&&D.type==="MemberExpression"&&!D.computed&&D.property.type==="Identifier"&&D.property.name==="current"&&D.parent.type==="AssignmentExpression"&&D.parent.left===D){F=!0;break}}F||s({node:h.parent.property,message:`The ref value '${v}.current' will likely have changed by the time this effect cleanup function runs. If this ref points to a node rendered by React, copy '${v}.current' to a variable inside the effect, and use that variable in the cleanup function.`})});let se=new Set;function Te(d,h){se.has(h)||(se.add(h),s({node:d,message:`Assignments to the '${h}' variable from inside React Hook ${r(b)} will be lost after each render. To preserve the value over time, store it in a useRef Hook and keep the mutable value in the '.current' property. Otherwise, you can move this variable directly inside ${r(b)}.`}))}let Fe=new Set;if(X.forEach(({isStable:d,references:h},v)=>{d&&Fe.add(v),h.forEach(O=>{O.writeExpr&&Te(O.writeExpr,v)})}),se.size>0)return;if(!A){let d=null;if(X.forEach(({isStable:h,references:v},O)=>{d||v.forEach(F=>{if(d)return;let P=F.identifier;if(!p.has(P))return;let D=F.from;for(;D.type!=="function";)D=D.upper;D.block===u&&(d=O)})}),d){let{suggestedDependencies:h}=ot({dependencies:X,declaredDependencies:[],stableDependencies:Fe,externalDependencies:new Set,isEffect:!0});s({node:b,message:`React Hook ${g} contains a call to '${d}'. Without a list of dependencies, this can lead to an infinite chain of updates. To fix this, pass [`+h.join(", ")+`] as a second argument to the ${g} Hook.`,suggest:[{desc:`Add dependencies array: [${h.join(", ")}]`,fix(v){return v.insertTextAfter(u,`, [${h.join(", ")}]`)}}]})}return}let Le=[],_e=new Set;A.type!=="ArrayExpression"?s({node:A,message:`React Hook ${r(b)} was passed a dependency list that is not an array literal. This means we can't statically verify whether you've passed the correct dependencies.`}):A.elements.forEach(d=>{if(d===null)return;if(d.type==="SpreadElement"){s({node:d,message:`React Hook ${r(b)} has a spread element in its dependency array. This means we can't statically verify whether you've passed the correct dependencies.`});return}T.has(d)&&s({node:d,message:`Functions returned from \`useEffectEvent\` must not be included in the dependency array. Remove \`${r(d)}\` from the list.`,suggest:[{desc:`Remove the dependency \`${r(d)}\``,fix(F){return F.removeRange(d.range)}}]});let h;try{h=Ee(d,ye)}catch(F){if(/Unsupported node type/.test(F.message)){d.type==="Literal"?X.has(d.value)?s({node:d,message:`The ${d.raw} literal is not a valid dependency because it never changes. Did you mean to include ${d.value} in the array instead?`}):s({node:d,message:`The ${d.raw} literal is not a valid dependency because it never changes. You can safely remove it.`}):s({node:d,message:`React Hook ${r(b)} has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked.`});return}else throw F}let v=d;for(;v.type==="MemberExpression"||v.type==="OptionalMemberExpression"||v.type==="ChainExpression";)v=v.object||v.expression.object;let O=!R.through.some(F=>F.identifier===v);Le.push({key:h,node:d}),O||_e.add(h)});let{suggestedDependencies:Qn,unnecessaryDependencies:We,missingDependencies:Ie,duplicateDependencies:zt}=ot({dependencies:X,declaredDependencies:Le,stableDependencies:Fe,externalDependencies:_e,isEffect:m}),Ve=Qn;if(zt.size+Ie.size+We.size===0){if(t)return;Cr({declaredDependencies:Le,declaredDependenciesNode:A,componentScope:R,scope:S}).forEach(({construction:h,isUsedOutsideOfHook:v,depType:O})=>{let F=O==="function"?"useCallback":"useMemo",P=O==="function"?"definition":"initialization",M=`wrap the ${P} of '${h.name.name}' in its own ${F}() Hook.`,D=v?`To fix this, ${M}`:`Move it inside the ${g} callback. Alternatively, ${M}`,pe=O==="conditional"||O==="logical expression"?"could make":"makes",he=`The '${h.name.name}' ${O} ${pe} the dependencies of ${g} Hook (at line ${A.loc.start.line}) change on every render. ${D}`,Ht;v&&h.type==="Variable"&&O==="function"&&(Ht=[{desc:`Wrap the ${P} of '${h.name.name}' in its own ${F}() Hook.`,fix(Yt){let[tr,nr]=F==="useMemo"?["useMemo(() => { return ","; })"]:["useCallback(",")"];return[Yt.insertTextBefore(h.node.init,tr),Yt.insertTextAfter(h.node.init,nr)]}}]),s({node:h.node,message:he,suggest:Ht})});return}!m&&Ie.size>0&&(Ve=ot({dependencies:X,declaredDependencies:[],stableDependencies:Fe,externalDependencies:_e,isEffect:m}).suggestedDependencies);function er(){if(Le.length===0)return!0;let d=Le.map(v=>v.key),h=d.slice().sort();return d.join(",")===h.join(",")}er()&&Ve.sort();function Qe(d){let h=d.split("."),v="";for(let O=0;O<h.length;O++){if(O!==0){let F=h.slice(0,O+1).join("."),P=ye.get(F)===!0;v+=P?"?.":"."}v+=h[O]}return v}function et(d,h,v,O){return d.size===0?null:(d.size>1?"":h+" ")+v+" "+(d.size>1?"dependencies":"dependency")+": "+Ar(Array.from(d).sort().map(F=>"'"+Qe(F)+"'"))+`. Either ${O} ${d.size>1?"them":"it"} or remove the dependency array.`}let me="";if(We.size>0){let d=null;if(Array.from(We.keys()).forEach(h=>{d===null&&h.endsWith(".current")&&(d=h)}),d!==null)me=` Mutable values like '${d}' aren't valid dependencies because mutating them doesn't re-render the component.`;else if(_e.size>0){let h=Array.from(_e)[0];S.set.has(h)||(me=` Outer scope values like '${h}' aren't valid dependencies because mutating them doesn't re-render the component.`)}}if(!me&&Ie.has("props")){let d=X.get("props");if(d==null)return;let h=d.references;if(!Array.isArray(h))return;let v=!0;for(let O=0;O<h.length;O++){let F=h[O],P=lt(R.block,F.identifier);if(!P){v=!1;break}let M=P.parent;if(M==null){v=!1;break}if(M.type!=="MemberExpression"&&M.type!=="OptionalMemberExpression"){v=!1;break}}v&&(me=` However, 'props' will change when *any* prop changes, so the preferred fix is to destructure the 'props' object outside of the ${g} call and refer to those specific props inside ${r(b)}.`)}if(!me&&Ie.size>0){let d=null;Ie.forEach(h=>{if(d)return;let v=R.set.get(h),O=X.get(h);if(O.references[0].resolved!==v)return;let F=v.defs[0];if(F==null||F.name==null||F.type!=="Parameter")return;let P=!1,M;for(let D=0;D<O.references.length;D++)if(M=O.references[D].identifier,M!=null&&M.parent!=null&&(M.parent.type==="CallExpression"||M.parent.type==="OptionalCallExpression")&&M.parent.callee===M){P=!0;break}P&&(d=h)}),d!==null&&(me=` If '${d}' changes too often, find the parent component that defines it and wrap that definition in useCallback.`)}if(!me&&Ie.size>0){let d=null;if(Ie.forEach(h=>{if(d!==null)return;let O=X.get(h).references,F,P;for(let M=0;M<O.length;M++){for(F=O[M].identifier,P=F.parent;P!=null&&P!==R.block;){if(P.type==="CallExpression"){let D=p.get(P.callee);if(D!=null){if(D.name===h)d={missingDep:h,setter:P.callee.name,form:"updater"};else if(c.has(F))d={missingDep:h,setter:P.callee.name,form:"reducer"};else{let pe=O[M].resolved;if(pe!=null){let he=pe.defs[0];he!=null&&he.type==="Parameter"&&(d={missingDep:h,setter:P.callee.name,form:"inlineReducer"})}}break}}P=P.parent}if(d!==null)break}}),d!==null)switch(d.form){case"reducer":me=` You can also replace multiple useState variables with useReducer if '${d.setter}' needs the current value of '${d.missingDep}'.`;break;case"inlineReducer":me=` If '${d.setter}' needs the current value of '${d.missingDep}', you can also switch to useReducer instead of useState and read '${d.missingDep}' in the reducer.`;break;case"updater":me=` You can also do a functional update '${d.setter}(${d.missingDep.slice(0,1)} => ...)' if you only need '${d.missingDep}' in the '${d.setter}' call.`;break;default:throw new Error("Unknown case.")}}s({node:A,message:`React Hook ${r(b)} has `+(et(Ie,"a","missing","include")||et(We,"an","unnecessary","exclude")||et(zt,"a","duplicate","omit"))+me,suggest:[{desc:`Update the dependencies array to be: [${Ve.map(Qe).join(", ")}]`,fix(d){return d.replaceText(A,`[${Ve.map(Qe).join(", ")}]`)}}]})}function E(u){let A=wr(u.callee,i);if(A===-1)return;let b=u.arguments[A],g=u.callee,m=on(g).name,S=u.arguments[A+1],k=/Effect($|[^a-z])/g.test(m);if(!b){s({node:g,message:`React Hook ${m} requires an effect callback. Did you forget to pass a callback to the hook?`});return}if(!(t&&!k)){if(!S&&!k){(m==="useMemo"||m==="useCallback")&&s({node:g,message:`React Hook ${m} does nothing when called with only one argument. Did you forget to pass an array of dependencies?`});return}switch(b.type){case"FunctionExpression":case"ArrowFunctionExpression":x(b,S,g,m,k);return;case"Identifier":if(!S||S.elements&&S.elements.some(N=>N&&N.type==="Identifier"&&N.name===b.name))return;let R=n(u).set.get(b.name);if(R==null||R.defs==null)return;let C=R.defs[0];if(!C||!C.node||C.type!=="Variable"&&C.type!=="FunctionName")break;switch(C.node.type){case"FunctionDeclaration":x(C.node,S,g,m,k);return;case"VariableDeclarator":let N=C.node.init;if(!N)break;switch(N.type){case"ArrowFunctionExpression":case"FunctionExpression":x(N,S,g,m,k);return}break}break;default:s({node:g,message:`React Hook ${m} received a function whose dependencies are unknown. Pass an inline function instead.`});return}s({node:g,message:`React Hook ${m} has a missing dependency: '${b.name}'. Either include it or remove the dependency array.`,suggest:[{desc:`Update the dependencies array to be: [${b.name}]`,fix(R){return R.replaceText(S,`[${b.name}]`)}}]})}}if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let u of e.sourceCode.getAllComments())if(Ir.test(u.value))return t=!0,{CallExpression:A=>E(A,!0)}}return{CallExpression:u=>E(u)}}};function ot({dependencies:e,declaredDependencies:t,stableDependencies:r,externalDependencies:n,isEffect:o}){let a=i();function i(){return{isUsed:!1,isSatisfiedRecursively:!1,isSubtreeUsed:!1,children:new Map}}e.forEach((x,E)=>{let u=s(a,E);u.isUsed=!0,l(a,E,A=>{A.isSubtreeUsed=!0})}),t.forEach(({key:x})=>{let E=s(a,x);E.isSatisfiedRecursively=!0}),r.forEach(x=>{let E=s(a,x);E.isSatisfiedRecursively=!0});function s(x,E){let u=E.split("."),A=x;for(let b of u){let g=A.children.get(b);g||(g=i(),A.children.set(b,g)),A=g}return A}function l(x,E,u){let A=E.split("."),b=x;for(let g of A){let m=b.children.get(g);if(!m)return;u(m),b=m}}let p=new Set,c=new Set;f(a,p,c,x=>x);function f(x,E,u,A){x.children.forEach((b,g)=>{let m=A(g);if(b.isSatisfiedRecursively){b.isSubtreeUsed&&u.add(m);return}if(b.isUsed){E.add(m);return}f(b,E,u,S=>m+"."+S)})}let y=[],T=new Set,I=new Set;return t.forEach(({key:x})=>{c.has(x)?y.indexOf(x)===-1?y.push(x):I.add(x):T.add(x)}),p.forEach(x=>{y.push(x)}),{suggestedDependencies:y,unnecessaryDependencies:T,duplicateDependencies:I,missingDependencies:p}}function we(e){switch(e.type){case"ObjectExpression":return"object";case"ArrayExpression":return"array";case"ArrowFunctionExpression":case"FunctionExpression":return"function";case"ClassExpression":return"class";case"ConditionalExpression":return we(e.consequent)!=null||we(e.alternate)!=null?"conditional":null;case"LogicalExpression":return we(e.left)!=null||we(e.right)!=null?"logical expression":null;case"JSXFragment":return"JSX fragment";case"JSXElement":return"JSX element";case"AssignmentExpression":return we(e.right)!=null?"assignment expression":null;case"NewExpression":return"object construction";case"Literal":return e.value instanceof RegExp?"regular expression":null;case"TypeCastExpression":return we(e.expression);case"TSAsExpression":return we(e.expression)}return null}function Cr({declaredDependencies:e,declaredDependenciesNode:t,componentScope:r,scope:n}){let o=e.map(({key:i})=>{let s=r.variables.find(p=>p.name===i);if(s==null)return null;let l=s.defs[0];if(l==null)return null;if(l.type==="Variable"&&l.node.type==="VariableDeclarator"&&l.node.id.type==="Identifier"&&l.node.init!=null){let p=we(l.node.init);if(p!=null)return[s,p]}return l.type==="FunctionName"&&l.node.type==="FunctionDeclaration"?[s,"function"]:l.type==="ClassName"&&l.node.type==="ClassDeclaration"?[s,"class"]:null}).filter(Boolean);function a(i){let s=!1;for(let l=0;l<i.references.length;l++){let p=i.references[l];if(p.writeExpr){if(s)return!0;s=!0;continue}let c=p.from;for(;c!==n&&c!=null;)c=c.upper;if(c!==n&&!an(t,p.identifier))return!0}return!1}return o.map(([i,s])=>({construction:i.defs[0],depType:s,isUsedOutsideOfHook:a(i)}))}function sn(e){return(e.parent.type==="MemberExpression"||e.parent.type==="OptionalMemberExpression")&&e.parent.object===e&&e.parent.property.name!=="current"&&!e.parent.computed&&!(e.parent.parent!=null&&(e.parent.parent.type==="CallExpression"||e.parent.parent.type==="OptionalCallExpression")&&e.parent.parent.callee===e.parent)?sn(e.parent):e.type==="MemberExpression"&&e.parent&&e.parent.type==="AssignmentExpression"&&e.parent.left===e?e.object:e}function at(e,t,r){t&&(e.optional?t.has(r)||t.set(r,!0):t.has(r)||t.set(r,!1))}function Ee(e,t){if(e.type==="Identifier"||e.type==="JSXIdentifier"){let r=e.name;return t&&t.set(r,!1),r}else if(e.type==="MemberExpression"&&!e.computed){let r=Ee(e.object,t),n=Ee(e.property,null),o=`${r}.${n}`;return at(e,t,o),o}else if(e.type==="OptionalMemberExpression"&&!e.computed){let r=Ee(e.object,t),n=Ee(e.property,null),o=`${r}.${n}`;return at(e,t,o),o}else if(e.type==="ChainExpression"&&!e.computed){let r=e.expression;if(r.type==="CallExpression")throw new Error(`Unsupported node type: ${r.type}`);let n=Ee(r.object,t),o=Ee(r.property,null),a=`${n}.${o}`;return at(r,t,a),a}else throw new Error(`Unsupported node type: ${e.type}`)}function on(e,t){return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.object.name==="React"&&e.property.type==="Identifier"&&!e.computed?e.property:e}function wr(e,t){let r=on(e);if(r.type!=="Identifier")return-1;switch(r.name){case"useEffect":case"useLayoutEffect":case"useCallback":case"useMemo":return 0;case"useImperativeHandle":return 1;default:if(r===e&&t&&t.additionalHooks){let n;try{n=Ee(r,null)}catch(o){if(/Unsupported node type/.test(o.message))return 0;throw o}return t.additionalHooks.test(n)?0:-1}else return-1}}function lt(e,t){let r=[e],n=null;for(;r.length;){if(n=r.shift(),Rr(n,t))return n;if(an(n,t))for(let[o,a]of Object.entries(n))o!=="parent"&&(nn(a)?(a.parent=n,r.push(a)):Array.isArray(a)&&a.forEach(i=>{nn(i)&&(i.parent=n,r.push(i))}))}return null}function Ar(e){let t="";for(let r=0;r<e.length;r++)t+=e[r],r===0&&e.length===2?t+=" and ":r===e.length-2&&e.length>2?t+=", and ":r<e.length-1&&(t+=", ");return t}function nn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function Rr(e,t){return(e.type==="Identifier"||e.type==="JSXIdentifier")&&e.type===t.type&&e.name===t.name&&e.range[0]===t.range[0]&&e.range[1]===t.range[1]}function an(e,t){return e.range[0]<=t.range[0]&&e.range[1]>=t.range[1]}function vr(e){return!1}var Ae=require("@typescript-eslint/utils");var ie=ve(require("typescript")),kr=Ae.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),ln="improved-no-unnecessary-condition",Or=Y({}),Pr=["string","number","bigint","boolean","symbol","undefined","object","function","never"],Fr=new Set(Pr),pt={name:ln,rule:kr({name:ln,meta:{type:"suggestion",docs:{description:"Extends checks of `no-unnecessary-condition` rule"},messages:{unnecessaryTypeofCondition:'This condition is unnecessary. The type of "{{name}}" is always "{{type}}".',alwaysFalseTypeofCondition:'This condition will always be false. The type of "{{name}}" is "{{actualType}}" so the condition has no overlap with "{{conditionType}}".'},schema:[Or]},defaultOptions:[{}],create(e){let t=Ae.ESLintUtils.getParserServices(e,!0),r=t.program?.getTypeChecker();if(!r||!t.program)throw new Error("TypeScript services or program not available");function n(s){return s.type===Ae.AST_NODE_TYPES.UnaryExpression&&s.operator==="typeof"}function o(s){return s.flags&ie.default.TypeFlags.Any||s.flags&ie.default.TypeFlags.Unknown?null:s.flags&ie.default.TypeFlags.StringLike?["string"]:s.flags&ie.default.TypeFlags.NumberLike?["number"]:s.flags&ie.default.TypeFlags.BigIntLike?["bigint"]:s.flags&ie.default.TypeFlags.BooleanLike?["boolean"]:s.flags&ie.default.TypeFlags.ESSymbolLike?["symbol"]:s.flags&ie.default.TypeFlags.Undefined||s.flags&ie.default.TypeFlags.Void?["undefined"]:s.flags&ie.default.TypeFlags.Null?["object"]:s.getCallSignatures().length>0?["function"]:s.flags&ie.default.TypeFlags.Object?s.getProperties().length===0?["string","number","bigint","boolean","symbol","object","function"]:["object"]:s.flags&ie.default.TypeFlags.NonPrimitive?["object"]:s.flags&ie.default.TypeFlags.Never?["never"]:null}function a(s){if(!r)return null;let l=t.esTreeNodeToTSNodeMap.get(s),p=r.getTypeAtLocation(l.expression);if(p.flags&ie.default.TypeFlags.Any||p.flags&ie.default.TypeFlags.Unknown)return null;let c=[];if(p.isUnion()){for(let y of p.types){let T=o(y);if(T)c.push(...T);else return null}return c}let f=o(p);return f?(c.push(...f),c):null}function i(s){if(!(s.operator==="==="||s.operator==="!=="))return;let p=null,c=null;if(n(s.left)?(p=s.left,c=s.right.type===Ae.AST_NODE_TYPES.Literal&&typeof s.right.value=="string"?s.right.value:null):n(s.right)&&(p=s.right,c=s.left.type===Ae.AST_NODE_TYPES.Literal&&typeof s.left.value=="string"?s.left.value:null),!p||!c||!Nr(c,Fr))return;let f=a(p);if(!f)return;let y=s.operator==="!==",T=f.includes(c);f.length===1?T&&!y?e.report({node:s,messageId:"unnecessaryTypeofCondition",data:{name:je(p,e),type:c}}):!T&&y?e.report({node:s,messageId:"unnecessaryTypeofCondition",data:{name:je(p,e),type:Array.from(f)[0]}}):!T&&!y?e.report({node:s,messageId:"alwaysFalseTypeofCondition",data:{name:je(p,e),actualType:He(f),conditionType:c}}):T&&y&&e.report({node:s,messageId:"alwaysFalseTypeofCondition",data:{name:je(p,e),actualType:He(f),conditionType:c}}):!T&&!y?e.report({node:s,messageId:"alwaysFalseTypeofCondition",data:{name:je(p,e),actualType:He(f),conditionType:c}}):!T&&y&&e.report({node:s,messageId:"unnecessaryTypeofCondition",data:{name:je(p,e),type:He(f)}})}return{BinaryExpression:i}}})};function He(e){return Array.from(new Set(e)).join(" | ")||"never"}function je(e,t){let r=e.argument;return r.type===Ae.AST_NODE_TYPES.Identifier?r.name:t.sourceCode.getText(r)}function Nr(e,t){return t.has(e)}var Ye=require("@typescript-eslint/utils");var jr=Ye.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),pn="no-call-with-explicit-generics",Mr=Y({functions:te(H())}),Dr=jr({name:pn,meta:{type:"problem",docs:{description:"Enforce calling configured functions with inferred generics only"},messages:{noExplicitGenerics:"Function '{{ functionName }}' should be called with inferred generics (remove the explicit type parameters)"},schema:[Mr]},defaultOptions:[{functions:[]}],create(e,[t]){let r=new Set(t.functions);return{CallExpression(n){let{callee:o}=n;o.type===Ye.AST_NODE_TYPES.Identifier&&r.has(o.name)&&n.typeArguments&&e.report({node:n,messageId:"noExplicitGenerics",data:{functionName:o.name}})}}}}),ct={name:pn,rule:Dr};var ke=require("@typescript-eslint/utils"),Lr=ke.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),cn="no-call-with-inferred-generics",_r=Lr({name:cn,meta:{type:"problem",docs:{description:"Disable calling configured functions with infered generics"},messages:{missingGenericDeclaration:"Function '{{ functionName }}' should be called with at least {{ minGenerics }} generic(s) (ex: `fn<Generic>()`) defined",anyUsedInGenerics:"Function '{{ functionName }}' should not be called with 'any' in generics"},schema:[{type:"object",properties:{functions:{type:"array",items:{type:"object",properties:{name:{type:"string"},minGenerics:{type:"number"},allowAny:{type:"boolean"},disallowTypes:{type:"array",items:{type:"string"}}},required:["name"]}},anyAliases:{type:"array",items:{type:"string"}}},required:["functions"]}]},defaultOptions:[{functions:[]}],create(e,[t]){let r=new Map(t.functions.map(n=>[n.name,n]));return{CallExpression(n){let{callee:o}=n;if(o.type!==ke.AST_NODE_TYPES.Identifier)return;let a=r.get(o.name);if(!a)return;let{minGenerics:i=1,allowAny:s,disallowTypes:l=t.disallowTypes}=a;(n.typeArguments?.params.length||0)<(i||0)&&e.report({node:n,messageId:"missingGenericDeclaration",data:{functionName:o.name,minGenerics:i||0}}),!(s&&!l)&&n.typeArguments?.params?.some(c=>!s&&c.type===ke.AST_NODE_TYPES.TSAnyKeyword||l&&c.type===ke.AST_NODE_TYPES.TSTypeReference&&c.typeName.type===ke.AST_NODE_TYPES.Identifier&&l.includes(c.typeName.name))&&e.report({node:n,messageId:"anyUsedInGenerics",data:{functionName:o.name}})}}}}),ut={name:cn,rule:_r};var fn=require("@typescript-eslint/utils"),$r=fn.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),mn="no-commented-out-code",Ur=["function ","class ","interface ","type ","enum ","namespace ","import ","export ","const ","let ","var ","return ","throw ","break","continue","try {","catch (","finally {","async ","await ","case ","switch (","while (","for (","default:"],G={returnStatement:/^\s*return\s+/,stringAssignment:/\w=("|'|`)/,objectPropertyWithQuotes:/\w+:\s*('|"|`)/,computedPropertyAssignment:/\[['"][^'"]*['"]\]:\s*('|"|`|[^'"`\s])/,kebabCaseProperty:/\w+-\w+:/,snakeCaseProperty:/\w+_\w+:/,ternaryOperator:/\?\s+\w/,colonWithWord:/:\s+\w/,quotedString:/^\s*('|"|`)[^'"]*('|"|`),?\s*$/,numberWithComma:/^\s*\d+[,}]/,arrayWithComma:/^\s*\[[^\]]*\][,}]/,objectWithComma:/^\s*\{[^}]*\}[,}]/,methodCall:/\.\w+\(/,arrayAccess:/\[\w+\]/,quotedPropertyKey:/^\s*(['"`]).+?\1\s*:/,jsxSelfClosing:/^<[A-Z]\w*(\s|>|\/)/,jsxElement:/^<[a-z]+(\s|>|\/)/,jsxOpeningTag:/<[A-Z]\w*(\s.*)?>/,jsxClosingTag:/<\/[A-Z]\w*>/,htmlOpeningTag:/<[a-z]+(\s.*)?>/,htmlClosingTag:/<\/[a-z]+>/,colonDescriptiveComment:/^[a-zA-Z]+(\s+[a-zA-Z]+)*:\s+[a-zA-Z]+\s+[a-zA-Z][^{=,'"]*$/,jsdocComment:/^\s*[*\s]*$/},Wr=[") {","return;",G.returnStatement,"if (","else {","else if (","/>","</","< ","},",": {"," } = ","={",G.stringAssignment,");",G.objectPropertyWithQuotes,G.computedPropertyAssignment,G.kebabCaseProperty,G.snakeCaseProperty,"&&","||","()",G.ternaryOperator,G.colonWithWord,G.quotedString,G.numberWithComma,G.arrayWithComma,G.objectWithComma,G.methodCall,G.arrayAccess,"?.(","??","=>",G.quotedPropertyKey],Vr=["/>","</",G.jsxSelfClosing,G.jsxElement,G.jsxOpeningTag,G.jsxClosingTag,G.htmlOpeningTag,G.htmlClosingTag],un=["INFO:","TODO:","DOCS:","FIX:","FIXME:","HACK:","NOTE:","WARNING:","WARN:","BUG:","ISSUE:","TEMP:","TEMPORARY:","XXX:","REVIEW:","eslint"],zr=$r({name:mn,meta:{type:"problem",docs:{description:"Disallow commented code"},messages:{commentedOutCode:"Commented code is not allowed. Detected pattern: `{{ wrongPattern }}` Use a comment starting with one of these prefixes if you want to keep this code commented out: {{ allowedPrefixes }}"},schema:[]},defaultOptions:[],create(e){function t(n,o){if(n.startsWith("/"))return!1;let a=n.trimStart();if(n.startsWith("*")||a.startsWith("eslint-disable")||n.includes("@deprecated")||n.includes("@example")||n.includes("@param")||n.includes("@returns")||n.includes("@throws")||n.includes("typescript-eslint")||n.includes("@ts-")||n.includes("prettier-ignore")||G.jsdocComment.test(n))return!1;for(let i of un)if(a.startsWith(i))return!1;if(n.includes("https://")||a.includes(":")&&G.colonDescriptiveComment.test(a.trim()))return!1;if(o==="Block"){for(let i of Vr)if(typeof i=="string"){if(n.includes(i))return{wrongPattern:i}}else if(i.test(n))return{wrongPattern:`regex(${i.toString()})`};return!1}for(let i of Ur)if(a.startsWith(i))return{wrongPattern:i};for(let i of Wr)if(typeof i=="string"){if(n.includes(i))return{wrongPattern:i}}else if(i.test(n))return{wrongPattern:`regex(${i.toString()})`};return!1}function r(n,o){let a=n,i=a.trim();if(i.startsWith("`")&&(i.endsWith("`,")||i.endsWith("`;")||i.endsWith("`")))return a;if(o==="Block"&&a.includes("```")){let p=a.split(/```[\s\S]*?```/g);p.some(f=>/[a-zA-Z0-9]/.test(f))&&(a=p.join(""))}if(!a.includes("`"))return a;let s=a.split(/`[^`]*`/g);return s.some(p=>/[a-zA-Z0-9]/.test(p))?s.join(""):a}return{Program(){let o=e.sourceCode.getAllComments();for(let a of o){let i=r(a.value,a.type),s=t(i,a.type);s&&e.report({node:a,messageId:"commentedOutCode",data:{wrongPattern:s.wrongPattern,allowedPrefixes:un.join(", ")}})}}}}}),ft={name:mn,rule:zr};var qe=require("@typescript-eslint/utils"),Hr=qe.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),dn="no-default-export",Yr=Hr({name:dn,meta:{type:"problem",docs:{description:"Disallow default exports"},schema:[],messages:{noDefaultExport:"Default exports are not allowed, use named exports instead."}},defaultOptions:[],create(e){return{ExportDefaultDeclaration(t){e.report({node:t,messageId:"noDefaultExport"})},ExportNamedDeclaration(t){for(let r of t.specifiers)r.exported.type===qe.TSESTree.AST_NODE_TYPES.Identifier&&r.exported.name==="default"&&e.report({node:t,messageId:"noDefaultExport"})}}}}),mt={name:dn,rule:Yr};var yn=require("@typescript-eslint/utils"),qr=yn.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),gn="no-leaked-text-in-jsx",Jr=[",",";","[","]","(",")"],Br=qr({name:gn,meta:{type:"problem",docs:{description:"Prevents leaking of text in JSX that should be wrapped in an expression container"},messages:{leakedTextInJSX:'Text "{{ text }}" should be wrapped in a JSX expression container.'},schema:[],fixable:"code"},defaultOptions:[],create(e){return{JSXText(t){let r=t.value.trim();if(!r)return;let n="";Jr.includes(r)?n=r:r.includes("&&")?n="&&":r.includes("||")?n="||":r.endsWith("? (")&&(n="? ("),n&&e.report({node:t,messageId:"leakedTextInJSX",data:{text:n}})}}}}),dt={name:gn,rule:Br};var Re=require("@typescript-eslint/utils"),Xr=Re.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Tn="no-non-camel-case-functions",Gr=/^(\$?[a-z][a-zA-Z0-9]*)$/;function Sn(e){if(e.typeName.type!==Re.AST_NODE_TYPES.TSQualifiedName)return!1;let{left:t,right:r}=e.typeName;return t.type===Re.AST_NODE_TYPES.Identifier&&t.name==="JSX"&&r.name==="Element"}var Kr=Xr({name:Tn,meta:{type:"suggestion",docs:{description:"Enforce camelCase naming convention for function declarations"},schema:[],messages:{nonCamelCaseFunction:'Function name "{{functionName}}" should be in camelCase format. If this fn is a React component and can\'t use the `FC` type, add a explicit "JSX.Element" return type to it'}},defaultOptions:[],create(e){return{FunctionDeclaration(t){if(t.id&&!Gr.test(t.id.name)){let r=t.returnType?.typeAnnotation;if(r&&(r.type===Re.AST_NODE_TYPES.TSTypeReference?Sn(r):r.type===Re.AST_NODE_TYPES.TSUnionType&&r.types.some(o=>o.type===Re.AST_NODE_TYPES.TSTypeReference&&Sn(o))))return;e.report({node:t.id,messageId:"nonCamelCaseFunction",data:{functionName:t.id.name}})}}}}}),yt={name:Tn,rule:Kr};var W=require("@typescript-eslint/utils");var gt=require("@typescript-eslint/utils");function Me(e,t,r=1/0){if(r!==0&&e.parent)return e.type===t?e:Me(e.parent,t,r===1/0?r:r-1)}function*St(e){yield e,e.parent&&(yield*St(e.parent))}function Tt(e,t){for(let r of e){let n=t(r);if(n!=null&&n!==!1)return n}}function hn(e,t,r){let o=r.getDeclaredVariables(e).find(a=>a.name===t||a.identifiers[0]?.parent.type===gt.AST_NODE_TYPES.Property&&a.identifiers[0]?.parent.key.type===gt.AST_NODE_TYPES.Identifier&&a.identifiers[0]?.parent.key.name===t);return o?o.references.filter(a=>!a.init):[]}var Zr=W.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),En="no-optional-root-props",Qr=Zr({name:En,meta:{type:"problem",docs:{description:"Prevents usage of optional properties at the root of a type if that type is a local type alias or interface referenced only once"},messages:{optionalNotAllowed:'Optional property "{{ propertyName }}" is not allowed on a local type used only once. Use `prop: undefined | ...` instead.',suggestion:"Use `prop: undefined | ...` instead."},hasSuggestions:!0,schema:[]},defaultOptions:[],create(e){function t(n){let a=e.sourceCode.getDeclaredVariables(n)[0];if(!a||a.references.length!==1)return!1;let i=a.references[0];if(!i)return!1;for(let s of St(i.identifier)){if("returnType"in s||s.type===W.TSESTree.AST_NODE_TYPES.ExportNamedDeclaration)return!1;let l=s.parent;if(!l)return!1;if(l.type===W.TSESTree.AST_NODE_TYPES.TSTypeParameterInstantiation&&l.parent.type===W.TSESTree.AST_NODE_TYPES.TSTypeReference&&l.parent.typeName.type===W.TSESTree.AST_NODE_TYPES.Identifier&&l.parent.typeName.name==="FC"){let c=Me(l.parent.parent,W.TSESTree.AST_NODE_TYPES.VariableDeclaration,4);if(!c)return!1;let f=Je(c,e.sourceCode);return f?!(f.parent.type===W.TSESTree.AST_NODE_TYPES.CallExpression&&f.parent.callee.type===W.TSESTree.AST_NODE_TYPES.Identifier&&f.parent.callee.name==="memo"):!1}if(s.type===W.TSESTree.AST_NODE_TYPES.AssignmentPattern)return!1;if(l.type===W.TSESTree.AST_NODE_TYPES.ArrowFunctionExpression){let p=Me(l,W.TSESTree.AST_NODE_TYPES.VariableDeclaration);return p?!!Je(p,e.sourceCode):!1}if(l.type===W.TSESTree.AST_NODE_TYPES.FunctionDeclaration)return!!Je(l,e.sourceCode)}return!1}function r(n){n.key.type!==W.TSESTree.AST_NODE_TYPES.Identifier||!n.optional||e.report({node:n.key,messageId:"optionalNotAllowed",data:{propertyName:n.key.name},suggest:[{messageId:"suggestion",fix:o=>{let a=Me(n,W.TSESTree.AST_NODE_TYPES.TSPropertySignature);if(!a)return null;let i=e.sourceCode.getText(a);return o.replaceText(a,i.replace("?:",": undefined |"))}}]})}return{TSTypeAliasDeclaration(n){if(n.typeAnnotation.type===W.TSESTree.AST_NODE_TYPES.TSTypeLiteral&&!(Be(n)||!t(n)))for(let o of n.typeAnnotation.members)o.type===W.TSESTree.AST_NODE_TYPES.TSPropertySignature&&r(o)},TSInterfaceDeclaration(n){if(!(Be(n)||!t(n)))for(let o of n.body.body)o.type===W.TSESTree.AST_NODE_TYPES.TSPropertySignature&&r(o)},TSTypeReference(n){if(n.typeName.type!==W.TSESTree.AST_NODE_TYPES.Identifier||n.typeName.name!=="FC"||!n.typeArguments?.params[0])return;let o=n.typeArguments.params[0];if(o.type!==W.TSESTree.AST_NODE_TYPES.TSTypeLiteral)return;let a=Me(n.parent,W.TSESTree.AST_NODE_TYPES.VariableDeclaration,4);if(!a)return;let i=Je(a,e.sourceCode);if(!(!i||i.parent.type===W.TSESTree.AST_NODE_TYPES.CallExpression&&i.parent.callee.type===W.TSESTree.AST_NODE_TYPES.Identifier&&i.parent.callee.name==="memo"))for(let l of o.members)l.type===W.TSESTree.AST_NODE_TYPES.TSPropertySignature&&r(l)}}}});function Be(e){return e?e.parent?.type===W.TSESTree.AST_NODE_TYPES.ExportNamedDeclaration||e.parent?.type===W.TSESTree.AST_NODE_TYPES.ExportDefaultDeclaration:!1}function Je(e,t){if(Be(e))return;let r;if(e.type===W.TSESTree.AST_NODE_TYPES.VariableDeclaration){if(e.declarations.length!==1)return;e.declarations[0].id.type===W.TSESTree.AST_NODE_TYPES.Identifier&&(r=e.declarations[0].id)}else{if(!e.id)return;r=e.id}if(!r)return;let n=t.getScope(e);e.type===W.TSESTree.AST_NODE_TYPES.FunctionDeclaration&&n.upper&&(n=n.upper);let o=n.variables.find(i=>i.identifiers.includes(r));if(!o)return;let a=o.references.filter(i=>i.identifier!==r);if(!(a.length!==1||!a[0])&&!Be(a[0].identifier.parent.parent))return a[0].identifier}var ht={name:En,rule:Qr};var bn=require("@typescript-eslint/utils"),Xe=ve(require("path"));var ei=bn.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),xn="no-relative-imports",ti=Y({find:H(),replacement:H()}),ni=Y({aliases:te(ti),rootDir:$(H()),allowNotFoundAliases:$(Ne()),_dev_simulateFileName:$(H())}),ri=ei({name:xn,meta:{type:"problem",fixable:"code",docs:{description:"Prevent relative imports and auto-fix them using configured aliases"},messages:{noRelativeImports:"Relative imports are not allowed. Use one of the valid aliases in tsconfig.json instead.",noRelativeImportsWithAlias:'Relative imports are not allowed. Use the "{{ alias }}" alias instead.'},schema:[ni]},defaultOptions:[{aliases:[],rootDir:void 0}],create(e,[t]){let r=t._dev_simulateFileName??e.filename;function n(i){return i.startsWith(".")||i.startsWith("..")}function o(i,s){let l=Xe.default.dirname(s);return Xe.default.resolve(l,i)}function a(i){let s=t.rootDir??process.cwd(),l=Xe.default.relative(s,i);if(l.startsWith("."))return null;l.startsWith("/")||(l=`/${l}`);for(let{find:p,replacement:c}of t.aliases)if(l.startsWith(c)){let f=l.replace(c,p);return{alias:p,newPath:f}}return null}return{ImportDeclaration(i){let s=i.source.value;if(!n(s))return;let l=o(s,r),p=a(l);!p&&t.allowNotFoundAliases||e.report({node:i,messageId:p?"noRelativeImportsWithAlias":"noRelativeImports",data:{alias:p?.alias},fix:p?c=>c.replaceText(i.source,`'${p.newPath}'`):void 0})}}}}),Et={name:xn,rule:ri};var $e=require("@typescript-eslint/utils"),Oe=ve(require("zod/v4"));var ii=Oe.object({alternativeMsgs:Oe.object({inArrayFind:Oe.string().optional(),inArrayFilter:Oe.string().optional()}).optional(),__dev_simulateFileName:Oe.string().optional()});function si(e){return e.typeAnnotation.type!==$e.AST_NODE_TYPES.TSTypePredicate?!1:e.typeAnnotation.asserts===!1}function oi(e){return/\.(typeGuards|type-guards)\.(ts|tsx)$/.test(e)}function ai(e){let t=e.parent;for(;t;){if(t.type===$e.AST_NODE_TYPES.CallExpression&&t.callee.type===$e.AST_NODE_TYPES.MemberExpression&&t.callee.property.type===$e.AST_NODE_TYPES.Identifier){let r=t.callee.property.name;if(r==="filter"||r==="find")return{method:r}}t=t.parent}return null}var bt=K({name:"no-type-guards",meta:{type:"problem",docs:{description:"Disallow type guards unless in *.typeGuards.(ts|tsx) or *.type-guards.(ts|tsx) files"},messages:{typeGuardNotAllowed:"Type guards are only allowed in *.typeGuards.(ts|tsx) or *.type-guards.(ts|tsx) files",useFilterWithTypeCheck:"{{message}}",useFindWithTypeCheck:"{{message}}"},schema:[Ce(ii)],hasSuggestions:!0},defaultOptions:[{}],create(e,[t]){let r=t.__dev_simulateFileName??e.filename;if(oi(r))return{};function n(o){if(!si(o))return;let a=ai(o),i=[];if(t.alternativeMsgs&&a){let s=a.method==="filter"?t.alternativeMsgs.inArrayFilter:t.alternativeMsgs.inArrayFind;if(s){let l=a.method==="filter"?"useFilterWithTypeCheck":"useFindWithTypeCheck";e.report({node:o,messageId:l,data:{message:s}});return}}e.report({node:o,messageId:"typeGuardNotAllowed"})}return{"FunctionDeclaration > :matches(TSTypeAnnotation)":n,"ArrowFunctionExpression > :matches(TSTypeAnnotation)":n,"MethodDefinition > FunctionExpression > :matches(TSTypeAnnotation)":n}}});var Pe=require("@typescript-eslint/utils");var li="no-unnecessary-async-on-jsx-props";function pi(e){if(e.body.type!==Pe.AST_NODE_TYPES.BlockStatement)return!1;let t=e.body.body;if(t.length!==1)return!1;let r=t[0];return!r||r.type!==Pe.AST_NODE_TYPES.ExpressionStatement?!1:r.expression.type===Pe.AST_NODE_TYPES.AwaitExpression}var xt=K({name:li,meta:{type:"suggestion",fixable:"code",docs:{description:"Disallow unnecessary async/await in JSX props where a single await provides no benefit"},messages:{unnecessaryAsyncInJsxProp:"Unnecessary async/await in JSX prop. The single await expression provides no benefit here."},schema:[]},defaultOptions:[],create(e){function t(r){pi(r)&&e.report({node:r,messageId:"unnecessaryAsyncInJsxProp",fix(n){let o=e.sourceCode,a=[],i=o.getFirstToken(r,l=>l.value==="async");if(i){let l=o.getTokenAfter(i);l?a.push(n.replaceTextRange([i.range[0],l.range[0]],"")):a.push(n.remove(i))}function s(l){if(l.type===Pe.AST_NODE_TYPES.AwaitExpression){let p=o.getFirstToken(l);if(p&&p.value==="await"){let c=o.getTokenAfter(p);c?a.push(n.replaceTextRange([p.range[0],c.range[0]],"")):a.push(n.remove(p))}}if(l.type===Pe.AST_NODE_TYPES.BlockStatement)for(let p of l.body)s(p);else l.type===Pe.AST_NODE_TYPES.ExpressionStatement&&s(l.expression)}return s(r.body),a}})}return{"JSXAttribute ArrowFunctionExpression[async=true]":t,"JSXAttribute FunctionExpression[async=true]":t}}});var be=require("@typescript-eslint/utils");var It=ve(require("typescript")),ci=be.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),In="no-unnecessary-casting",ui=Y({additionalCastFunctions:$(te(Y({name:H(),expectedType:Jt(["string","number"])})))}),Ct={name:In,rule:ci({name:In,meta:{type:"suggestion",docs:{description:"Prevents unnecessary Number and String castings"},messages:{unnecessaryNumberCasting:"Unnecessary Number() casting on a value already of number type",unnecessaryStringCasting:"Unnecessary String() casting on a value already of string type",unnecessaryCustomCasting:"Unnecessary {{name}}() casting on a value already of {{type}} type"},schema:[ui],fixable:"code"},defaultOptions:[{}],create(e){let r=e.options[0].additionalCastFunctions||[],n=[{name:"Number",expectedType:"number"},{name:"String",expectedType:"string"},...r],o=be.ESLintUtils.getParserServices(e,!0),a=o.program?.getTypeChecker();if(!a||!o.program)throw new Error("TypeScript services or program not available");function i(c,f){switch(c.type){case be.AST_NODE_TYPES.Literal:return f==="number"?typeof c.value=="number":typeof c.value=="string";case be.AST_NODE_TYPES.TemplateLiteral:return f==="string";case be.AST_NODE_TYPES.UnaryExpression:return f==="number"?c.operator==="+"||c.operator==="-"||c.operator==="~":!1;default:return!1}}function s(c,f){return f==="number"?!!(c.flags&It.TypeFlags.NumberLike):!!(c.flags&It.TypeFlags.StringLike)}function l(c,f){return y=>y.replaceText(c,e.sourceCode.getText(f))}function p(c){if(!a||c.arguments.length!==1)return;let f=c.arguments[0];if(!f||f.type===be.AST_NODE_TYPES.SpreadElement)return;let{callee:y}=c;if(y.type!==be.AST_NODE_TYPES.Identifier)return;let T=y.name,I=n.find(E=>E.name===T);if(!I)return;if(i(f,I.expectedType)||s(a.getTypeAtLocation(o.esTreeNodeToTSNodeMap.get(f)),I.expectedType)){let E,u;T==="Number"?E="unnecessaryNumberCasting":T==="String"?E="unnecessaryStringCasting":(E="unnecessaryCustomCasting",u={name:I.name,type:I.expectedType}),e.report({node:c,messageId:E,...u?{data:u}:{},fix:l(c,f)})}}return{CallExpression:p}}})};var Ue=require("@typescript-eslint/utils"),ce=ve(require("zod/v4"));var fi=ce.object({methods:ce.union([ce.array(ce.string()),ce.literal("array")])}),wt=K({name:"no-unnecessary-typing",meta:{type:"suggestion",docs:{description:"Prevents unnecessary explicit type annotations in callback parameters where TypeScript can infer the type"},messages:{unnecessaryTypeAnnotation:"Unnecessary type annotation. TypeScript can infer this type from context."},fixable:"code",schema:[ce.toJSONSchema(fi)]},defaultOptions:[{methods:"array"}],create(e,[t]){let r=t.methods,n=new Set(["find","filter","map","forEach","some","every","reduce","findIndex","sort"]);function o(s){return Array.isArray(r)?r.includes(s):n.has(s)}function a(s){let{callee:l}=s;if(l.type===Ue.AST_NODE_TYPES.MemberExpression){let p=l.property;if(p.type===Ue.AST_NODE_TYPES.Identifier)return p.name}return null}function i(s,l){if(s.type!==Ue.AST_NODE_TYPES.Identifier||!s.typeAnnotation)return;let p=l.parent;if(p.type===Ue.AST_NODE_TYPES.CallExpression){let c=a(p);c&&o(c)&&p.arguments.indexOf(l)===0&&e.report({node:s.typeAnnotation,messageId:"unnecessaryTypeAnnotation",fix(y){return y.remove(s.typeAnnotation)}})}}return{ArrowFunctionExpression(s){for(let l of s.params)i(l,s)},FunctionExpression(s){for(let l of s.params)i(l,s)}}}});var le=require("@typescript-eslint/utils");var At=K({name:"no-unused-obj-props",meta:{type:"suggestion",docs:{description:"Disallow unused properties when it is safe to remove them"},messages:{unusedObjectProperty:'The object property "{{name}}" is not being used',unusedReturnObjectProperty:'The object property "{{name}}" returned by this function is not being used'},schema:[]},defaultOptions:[],create(e){return{VariableDeclarator(t){if(t.id.type===le.AST_NODE_TYPES.ObjectPattern||!t.init||t.init.type!==le.AST_NODE_TYPES.ObjectExpression||t.id.type===le.AST_NODE_TYPES.Identifier&&t.id.typeAnnotation||t.parent.parent.type===le.AST_NODE_TYPES.ExportNamedDeclaration)return;let r=new Map;for(let i of t.init.properties)i.type===le.AST_NODE_TYPES.Property&&i.key.type===le.AST_NODE_TYPES.Identifier&&r.set(i.key.name,i);if(r.size===0||t.id.type!==le.AST_NODE_TYPES.Identifier)return;let n=mi(t,e.sourceCode);if(n.length===0)return;let o=t.init.properties.some(i=>i.type!==le.AST_NODE_TYPES.Property?!1:i.value.type===le.AST_NODE_TYPES.FunctionExpression),a=new Set;for(let i of n){if(i.identifier.parent.type!==le.AST_NODE_TYPES.MemberExpression)return;let s=i.identifier.parent;if(s.object!==i.identifier)return;if(s.computed)if(s.property.type===le.AST_NODE_TYPES.Literal&&typeof s.property.value=="string")a.add(s.property.value);else return;else{if(s.property.type!==le.AST_NODE_TYPES.Identifier)return;a.add(s.property.name)}if(s.parent.type===le.AST_NODE_TYPES.CallExpression&&o)return}for(let[i,s]of r)a.has(i)||e.report({node:s,messageId:"unusedObjectProperty",data:{name:i}})}}}});function mi(e,t){let r=t.getDeclaredVariables(e);if(r.length!==1)return[];let n=r[0];return n?n.references.filter(o=>o.identifier!==e.id):[]}var V=require("@typescript-eslint/utils");var di=Y({selectors:te(Y({name:H(),selectorProp:$(H()),selectorArgPos:$(ge()),returnProp:$(H())}))}),yi=V.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Cn="no-unused-selected-values",Rt={name:Cn,rule:yi({name:Cn,meta:{type:"suggestion",docs:{description:"Disallow unused values in selector objects"},messages:{unusedSelectedValue:'The selected value "{{name}}" is not being used'},schema:[di]},defaultOptions:[{selectors:[]}],create(e,[t]){let{selectors:r=[]}=t,n=new Map(r.map(o=>[o.name,o]));return{VariableDeclarator(o){let a=null;if(o.init?.type===V.AST_NODE_TYPES.CallExpression&&(a=o.init),!a)return;let i=Si(a);if(!i)return;let s=n.get(i);if(!s)return;let l=gi(a,s.selectorArgPos??0,s.selectorProp);if(!l)return;let p=Ti(l);if(!p)return;let c=wn(p.properties,void 0);if(!c)return;if(o.id.type===V.AST_NODE_TYPES.ObjectPattern){let T=wn(o.id.properties,s.returnProp);if(!T)return;for(let[I,x]of c)T.has(I)||e.report({node:x,messageId:"unusedSelectedValue",data:{name:I}});return}if(o.id.type!==V.AST_NODE_TYPES.Identifier||s.returnProp)return;let f=hi(o,e.sourceCode);if(f.length===0)return;let y=new Set;for(let T of f){if(T.identifier.parent.type!==V.AST_NODE_TYPES.MemberExpression)return;let I=T.identifier.parent.property;if(I.type!==V.AST_NODE_TYPES.Identifier)return;y.add(I.name)}for(let[T,I]of c)y.has(T)||e.report({node:I,messageId:"unusedSelectedValue",data:{name:T}})}}}})};function gi(e,t,r){let n=e.arguments[t];if(!n)return null;if(n.type===V.AST_NODE_TYPES.ArrowFunctionExpression||n.type===V.AST_NODE_TYPES.FunctionExpression)return n;if(r&&n.type===V.AST_NODE_TYPES.ObjectExpression){let o=n.properties.find(i=>i.type===V.AST_NODE_TYPES.Property&&i.key.type===V.AST_NODE_TYPES.Identifier&&i.key.name===r);if(o?.type!==V.AST_NODE_TYPES.Property)return null;let a=o.value;if(a.type===V.AST_NODE_TYPES.ArrowFunctionExpression||a.type===V.AST_NODE_TYPES.FunctionExpression)return a}return null}function Si(e){return e.callee.type===V.AST_NODE_TYPES.Identifier?e.callee.name:e.callee.type===V.AST_NODE_TYPES.MemberExpression&&e.callee.property.type===V.AST_NODE_TYPES.Identifier?e.callee.property.name:null}function Ti(e){if(e.body.type===V.AST_NODE_TYPES.ObjectExpression)return e.body;if(e.body.type===V.AST_NODE_TYPES.BlockStatement){let t=e.body.body.filter(r=>r.type===V.AST_NODE_TYPES.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==V.AST_NODE_TYPES.ObjectExpression?null:t[0].argument}return null}function wn(e,t){let r=e;if(t){let o=e.find(a=>a.type===V.AST_NODE_TYPES.Property&&a.key.type===V.AST_NODE_TYPES.Identifier&&a.key.name===t);if(o?.type!==V.AST_NODE_TYPES.Property||o.value.type!==V.AST_NODE_TYPES.ObjectPattern)return null;r=o.value.properties}let n=new Map;for(let o of r){if(o.type!==V.AST_NODE_TYPES.Property||o.key.type!==V.AST_NODE_TYPES.Identifier)return null;n.set(o.key.name,o)}return n.size>0?n:null}function hi(e,t){let r=t.getDeclaredVariables(e);if(r.length!==1)return[];let n=r[0];return n?n.references.filter(o=>o.identifier!==e.id):[]}var q=require("@typescript-eslint/utils");var vt=K({name:"no-unused-t-state-field",meta:{type:"suggestion",docs:{description:"Prevent declaring unused t-state fields"},messages:{unusedField:'Field "{{name}}" is not being used, you can safely remove it'},schema:[]},defaultOptions:[],create(e){if(!(e.filename.endsWith(".jsx")||e.filename.endsWith(".tsx")))return{};if(!e.sourceCode.ast.body.some(a=>a.type===q.AST_NODE_TYPES.ImportDeclaration&&a.source.value==="t-state-form"))return{};let n=null,o=!1;return{CallExpression(a){if(o)return;if(!n){let s=Ei(a);s&&(n=s);return}let i=bi(a,e.sourceCode);if(i){o=!0;for(let s of i)n.delete(s);if(n.size!==0)for(let[s,l]of n)e.report({node:l,messageId:"unusedField",data:{name:s}})}}}}});function Ei(e){if(!(e.callee.type===q.AST_NODE_TYPES.Identifier&&e.callee.name==="useForm"))return null;let r=e.arguments[0];if(!r||r.type!==q.AST_NODE_TYPES.ObjectExpression)return null;let n=Tt(r.properties,a=>a.type!==q.AST_NODE_TYPES.Property||a.key.type!==q.AST_NODE_TYPES.Identifier||a.key.name!=="initialConfig"?null:a.value.type===q.AST_NODE_TYPES.ObjectExpression?a.value:a.value.type===q.AST_NODE_TYPES.ArrowFunctionExpression||a.value.type===q.AST_NODE_TYPES.FunctionExpression?xi(a.value):null);if(!n)return null;let o=new Map;for(let a of n.properties)a.type===q.AST_NODE_TYPES.Property&&a.key.type===q.AST_NODE_TYPES.Identifier&&o.set(a.key.name,a);return o}function bi(e,t){if(!(e.callee.type===q.AST_NODE_TYPES.Identifier&&e.callee.name==="useFormState")||e.parent.type!==q.AST_NODE_TYPES.VariableDeclarator||e.parent.id.type!==q.AST_NODE_TYPES.ObjectPattern||!Tt(e.parent.id.properties,i=>i.type===q.AST_NODE_TYPES.Property&&i.key.type===q.AST_NODE_TYPES.Identifier&&i.key.name==="formFields"&&i))return null;let o=hn(e.parent,"formFields",t),a=new Set;for(let{identifier:i}of o){if(i.type!==q.AST_NODE_TYPES.Identifier||i.parent.type===q.AST_NODE_TYPES.Property&&i.parent.parent.type===q.AST_NODE_TYPES.ObjectExpression&&i.parent.parent.parent.type===q.AST_NODE_TYPES.ReturnStatement||i.parent.type===q.AST_NODE_TYPES.ReturnStatement)return null;if(i.parent.type===q.AST_NODE_TYPES.MemberExpression){if(i.parent.object.type!==q.AST_NODE_TYPES.Identifier||i.parent.property.type!==q.AST_NODE_TYPES.Identifier)return null;a.add(i.parent.property.name)}}return a}function xi(e){if(e.body.type===q.AST_NODE_TYPES.ObjectExpression)return e.body;if(e.body.type===q.AST_NODE_TYPES.BlockStatement){let t=e.body.body.filter(r=>r.type===q.AST_NODE_TYPES.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==q.AST_NODE_TYPES.ObjectExpression?null:t[0].argument}return null}var U=require("@typescript-eslint/utils");var Ii=U.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function An(e){let t=[];for(let r of e.members)r.type===U.AST_NODE_TYPES.TSPropertySignature&&r.key.type===U.AST_NODE_TYPES.Identifier&&t.push([r.key.name,r]);return t}function Rn(e,...t){for(let r of t)e.set(...r);return e}var Ci=Y({forceCheckOnFCPropTypesWithName:$(te(H()))}),vn="no-unused-type-props-in-args",kt=null,wi=Ii({name:vn,meta:{type:"problem",docs:{description:"Disallow unused undestructured object type properties"},messages:{unusedObjectTypeProperty:"Object type property '{{ propertyName }}' is defined but never used",missingComponentParam:"Component has declared props but no props are used"},schema:[Ci],fixable:"code"},defaultOptions:[{}],create(e,[t]){let{forceCheckOnFCPropTypesWithName:r}=t;r&&!kt&&(kt=r.map(s=>new RegExp(s)));function n(s,l,p,c,f=!0){let y=p.name,T=e.sourceCode.getScope(l).references.find(E=>E.identifier.name===y)?.resolved,I=s&&kt?.some(E=>E.test(y));if(!T||!I&&T.references.filter(E=>E.isTypeReference).length>1)return;let x=T?.defs[0]?.node;if(!(f&&x?.parent?.type===U.AST_NODE_TYPES.ExportNamedDeclaration)){if(x?.type===U.AST_NODE_TYPES.TSTypeAliasDeclaration){o(s,l,c,x.typeAnnotation,!0);return}if(x?.type===U.AST_NODE_TYPES.TSInterfaceDeclaration){o(s,l,c,x.body,!0);return}}}function o(s,l,p,c,f){if(c.type===U.AST_NODE_TYPES.TSInterfaceBody){for(let y of c.body)y.type===U.AST_NODE_TYPES.TSPropertySignature&&y.key.type===U.AST_NODE_TYPES.Identifier&&p.set(y.key.name,y);return}if(c.type===U.AST_NODE_TYPES.TSTypeLiteral){Rn(p,...An(c));return}if(c.type===U.AST_NODE_TYPES.TSIntersectionType){for(let y of c.types)o(s,l,p,y,!0);return}f||c.type===U.AST_NODE_TYPES.TSTypeReference&&c.typeName.type===U.AST_NODE_TYPES.Identifier&&n(s,l,c.typeName,p)}function a(s,l,p){for(let c of p)if(c.type==="ObjectPattern"&&c.typeAnnotation){let f=new Map;if(o(s,l,f,c.typeAnnotation.typeAnnotation,!1),f.size===0)continue;i(c,f)}else c.type===U.AST_NODE_TYPES.AssignmentPattern&&c.left.type===U.AST_NODE_TYPES.ObjectPattern&&a(s,l,[c.left])}function i(s,l){let p=[];if(s.properties.at(-1)?.type===U.AST_NODE_TYPES.RestElement)return;for(let T of s.properties)T.type===U.AST_NODE_TYPES.Property&&T.key.type===U.AST_NODE_TYPES.Identifier&&p.push(T.key.name);let f=[],y=[];for(let[T,I]of l)p.includes(T)||(y.push(T),f.push({node:I,messageId:"unusedObjectTypeProperty",data:{propertyName:T}}));for(let[T,I]of f.entries())e.report({...I,fix:T===f.length-1?x=>{let E=s.properties.at(-1),u=y.join(", ");return E?E?.type===U.AST_NODE_TYPES.RestElement?null:x.insertTextAfter(E,`, ${u}`):x.insertTextBeforeRange([s.range[0]+1,s.range[1]],`${u}`)}:void 0})}return{VariableDeclaration(s){let l=s.declarations[0];if(!l)return;let p=new Map,c=l.id.type===U.AST_NODE_TYPES.Identifier&&l.id.typeAnnotation?.typeAnnotation.type===U.AST_NODE_TYPES.TSTypeReference&&l.id.typeAnnotation.typeAnnotation.typeName.type===U.AST_NODE_TYPES.Identifier&&l.id.typeAnnotation.typeAnnotation.typeName.name==="FC"&&l.id.typeAnnotation.typeAnnotation.typeArguments?.params[0];if(c){if(c.type===U.AST_NODE_TYPES.TSTypeReference&&c.typeName.type===U.AST_NODE_TYPES.Identifier)n(!0,s,c.typeName,p,!1);else if(c.type===U.AST_NODE_TYPES.TSTypeLiteral)Rn(p,...An(c));else if(c.type===U.AST_NODE_TYPES.TSIntersectionType)for(let f of c.types)f.type===U.AST_NODE_TYPES.TSTypeReference&&f.typeName.type===U.AST_NODE_TYPES.Identifier?n(!0,s,f.typeName,p,!1):o(!0,s,p,f,!0);if(p.size!==0&&l.init?.type===U.AST_NODE_TYPES.ArrowFunctionExpression){let f=l.init.params[0];if(!f){e.report({node:l.init,messageId:"missingComponentParam"});return}f.type===U.AST_NODE_TYPES.ObjectPattern&&i(f,p)}}},FunctionDeclaration:function(s){a(!1,s,s.params)},ArrowFunctionExpression(s){a(!1,s,s.params)}}}}),Ot={name:vn,rule:wi};var ue=require("@typescript-eslint/utils");var Pt=K({name:"no-write-only-ref",meta:{type:"problem",docs:{description:"Disallow creating refs that are never read"},messages:{refNotRead:'Ref "{{name}}" is never read. Consider removing it if not needed.'},schema:[]},defaultOptions:[],create(e){let t=new Set;function r(n){return n.callee.type===ue.AST_NODE_TYPES.Identifier?t.has(n.callee.name):n.callee.type===ue.AST_NODE_TYPES.MemberExpression&&n.callee.object.type===ue.AST_NODE_TYPES.Identifier&&n.callee.property.type===ue.AST_NODE_TYPES.Identifier?n.callee.property.name==="useRef":!1}return{ImportDeclaration(n){if(n.source.value==="react")for(let o of n.specifiers)o.type===ue.AST_NODE_TYPES.ImportSpecifier&&o.imported.type===ue.AST_NODE_TYPES.Identifier&&o.imported.name==="useRef"&&t.add(o.local.name)},VariableDeclarator(n){if(n.init&&n.init.type===ue.AST_NODE_TYPES.CallExpression&&r(n.init)&&n.id.type===ue.AST_NODE_TYPES.Identifier){let a=e.sourceCode.getScope(n).set.get(n.id.name);if(a){let i=!1;for(let s of a.references){let p=s.identifier.parent;if(p!==n&&!(p.type===ue.AST_NODE_TYPES.JSXExpressionContainer&&p.parent.type===ue.AST_NODE_TYPES.JSXAttribute&&p.parent.name.type===ue.AST_NODE_TYPES.JSXIdentifier&&p.parent.name.name==="ref")){i=!0;break}}i||e.report({node:n.id,messageId:"refNotRead",data:{name:n.id.name}})}}}}}});var De=require("@typescript-eslint/utils"),Ai=De.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),On="prefer-named-functions",kn=new Map,Ri=Ai({name:On,meta:{hasSuggestions:!0,type:"suggestion",docs:{description:"Prevent using arrow functions when a named function can be used instead"},schema:[{type:"object",properties:{ignoreRegex:{type:"string"},disallowArrowFnWithImplicitReturns:{type:"boolean"}}}],messages:{suggestion:"Convert to named function",default:'Function {{functionName}} should be defined as a named function "function {{functionName}} () {}" instead of an arrow function',withIgnoreRegex:'Function {{functionName}} should be defined as a named function "function {{functionName}} () {}", if not possible to use `function` you can also use a name that matches the rule ignore regex'}},defaultOptions:[{}],create(e,[t]){let r=null;if(t.ignoreRegex){let n=kn.get(t.ignoreRegex);n?r=n:(r=new RegExp(t.ignoreRegex),kn.set(t.ignoreRegex,r))}return{VariableDeclarator(n){if(n.init&&n.init.type===De.AST_NODE_TYPES.ArrowFunctionExpression&&n.id.type===De.AST_NODE_TYPES.Identifier){let o=n.id.name;if(n.id.typeAnnotation||r&&r.test(o)||!t.disallowArrowFnWithImplicitReturns&&n.init.body.type!==De.AST_NODE_TYPES.BlockStatement)return;let a=n.parent,i=n.init.params,s=n.init.body,l=n.init;e.report({node:n.id,messageId:r?"withIgnoreRegex":"default",data:{functionName:o,ignoreRegex:t.ignoreRegex},suggest:[{messageId:"suggestion",fix:p=>p.replaceText(a,`${l.async?"async ":""}function ${o}(${i.map(c=>e.sourceCode.getText(c)).join(", ")||""}) ${e.sourceCode.getText(s)}`)}]})}}}}}),Ft={name:On,rule:Ri};var j=require("@typescript-eslint/utils");var vi=Y({disallowedFunctions:te(Y({name:H(),allowUsingWithArgs:$(Ne()),hookAlternative:$(H()),message:$(H()),allowUseInside:$(te(H()))}))});function Ge(e){return/^use[A-Z]/.test(e)}function Pn(e){return/^[A-Z]/.test(e)}function ki(e){return e.type===j.AST_NODE_TYPES.Identifier?Ge(e.name):e.type===j.AST_NODE_TYPES.MemberExpression&&e.property.type===j.AST_NODE_TYPES.Identifier?Ge(e.property.name):!1}function Fn(e,t){return e.type===j.AST_NODE_TYPES.Identifier?e.name===t:e.type===j.AST_NODE_TYPES.MemberExpression&&e.object.type===j.AST_NODE_TYPES.Identifier&&e.property.type===j.AST_NODE_TYPES.Identifier?e.object.name==="React"&&e.property.name===t:!1}function Nn(e){return!!(e.parent&&e.parent.type===j.AST_NODE_TYPES.CallExpression&&Fn(e.parent.callee,"forwardRef"))}function jn(e){return!!(e.parent&&e.parent.type===j.AST_NODE_TYPES.CallExpression&&Fn(e.parent.callee,"memo"))}function Nt(e){if(e.type===j.AST_NODE_TYPES.FunctionDeclaration||e.type===j.AST_NODE_TYPES.FunctionExpression&&e.id)return e.id||void 0;if(e.type===j.AST_NODE_TYPES.FunctionExpression||e.type===j.AST_NODE_TYPES.ArrowFunctionExpression){if(e.parent.type===j.AST_NODE_TYPES.VariableDeclarator&&e.parent.init===e)return e.parent.id;if(e.parent.type===j.AST_NODE_TYPES.AssignmentExpression&&e.parent.right===e&&e.parent.operator==="=")return e.parent.left;if(e.parent.type===j.AST_NODE_TYPES.Property&&e.parent.value===e&&!e.parent.computed)return e.parent.key;if(e.parent.type===j.AST_NODE_TYPES.AssignmentPattern&&e.parent.right===e)return e.parent.left}}function Oi(e){let t=e.parent,r=!1;for(;t;){if(t.type===j.AST_NODE_TYPES.FunctionDeclaration||t.type===j.AST_NODE_TYPES.FunctionExpression||t.type===j.AST_NODE_TYPES.ArrowFunctionExpression){let n=Nt(t);if(n&&n.type===j.AST_NODE_TYPES.Identifier){if(Pn(n.name)||Ge(n.name))return!r;r=!0}else{if(Nn(t)||jn(t))return!r;if(t.parent.type===j.AST_NODE_TYPES.CallExpression){let o=t.parent;ki(o.callee)||(r=!0)}else t.parent.type===j.AST_NODE_TYPES.JSXExpressionContainer||(r=!0)}}t=t.parent}return!1}function Mn(e){return e.callee.type===j.AST_NODE_TYPES.Identifier?e.callee.name:e.callee.type===j.AST_NODE_TYPES.MemberExpression&&e.callee.property.type===j.AST_NODE_TYPES.Identifier?e.callee.property.name:null}function Pi(e,t){if(!t.length)return!1;let r=e.parent;for(;r;){if(r.type===j.AST_NODE_TYPES.FunctionDeclaration||r.type===j.AST_NODE_TYPES.FunctionExpression||r.type===j.AST_NODE_TYPES.ArrowFunctionExpression){let n=Nt(r);if(n&&n.type===j.AST_NODE_TYPES.Identifier&&t.includes(n.name))return!0}else if(r.type===j.AST_NODE_TYPES.CallExpression){let n=Mn(r);if(n&&t.includes(n))return!0}r=r.parent}return!1}function Fi(e){return e.arguments.length>0&&!e.arguments.every(t=>t.type===j.AST_NODE_TYPES.Identifier&&t.name==="undefined")}function Ni(e,t){let r=!1,n=e.parent;for(;n;){if(n.type===j.AST_NODE_TYPES.FunctionDeclaration||n.type===j.AST_NODE_TYPES.FunctionExpression||n.type===j.AST_NODE_TYPES.ArrowFunctionExpression){let o=Nt(n);if(o&&o.type===j.AST_NODE_TYPES.Identifier){if(Pn(o.name)||Ge(o.name)){r=!0;break}}else if(Nn(n)||jn(n)){r=!0;break}}n=n.parent}return r?t.length===0?Oi(e):!Pi(e,t):!1}var jt=K({name:"prefer-react-hook-alternative",meta:{type:"suggestion",docs:{description:"Prefer hook alternatives for certain functions in React components and hooks"},messages:{preferHookAlternative:"This function should not be used in react{{message}}."},schema:[vi],hasSuggestions:!0},defaultOptions:[{disallowedFunctions:[]}],create(e,[t]){let{disallowedFunctions:r}=t,n=new Map(r.map(o=>[o.name,o]));return{CallExpression(o){let a=Mn(o);if(!a)return;let i=n.get(a);if(!i||i.allowUsingWithArgs&&Fi(o))return;let s=i.allowUseInside||[];Ni(o,s)&&e.report({node:o,messageId:"preferHookAlternative",data:{message:i.message?` ${i.message}`:` use ${i.hookAlternative} instead`},suggest:i.hookAlternative?[{messageId:"preferHookAlternative",data:{message:`Replace with ${i.hookAlternative}`,hookAlternative:i.hookAlternative},fix:l=>{let p=i.hookAlternative;return o.callee.type===j.AST_NODE_TYPES.Identifier?l.replaceText(o.callee,p):o.callee.type===j.AST_NODE_TYPES.MemberExpression&&o.callee.property.type===j.AST_NODE_TYPES.Identifier?l.replaceText(o.callee.property,p):null}}]:[]})}}}});var J=require("@typescript-eslint/utils");var ji=J.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ln="prefer-single-line-if",Mi=Y({maxLineLength:$(ge()),maxNonSimpleConditionLength:$(ge())}),Di=ji({name:Ln,meta:{type:"suggestion",fixable:"code",docs:{description:"Enforce single-line if in simple if statements"},messages:{noSingleLineCurly:"If return statement with single statement body should be written in a single line"},schema:[Mi]},defaultOptions:[{}],create(e,[t]){let r=e.sourceCode;return{IfStatement(n){if(n.consequent.type!==J.AST_NODE_TYPES.BlockStatement||n.loc.start.line===n.loc.end.line||r.getCommentsInside(n.consequent).length>0||n.alternate||n.consequent.body.length!==1)return;let a=n.consequent.body[0];if(a.type===J.AST_NODE_TYPES.ReturnStatement){if(!$n(a))return}else if(!(a.type===J.AST_NODE_TYPES.ContinueStatement||a.type===J.AST_NODE_TYPES.BreakStatement))return;if(n.test.type===J.AST_NODE_TYPES.LogicalExpression||n.test.type===J.AST_NODE_TYPES.ConditionalExpression)return;let i;if(t.maxNonSimpleConditionLength){let f=Dn(n.test);if(!f&&n.test.type===J.AST_NODE_TYPES.UnaryExpression&&n.test.operator==="!"){let y=n.test.argument;Dn(y)&&(f=!0)}if(f&&(i=r.getText(n.test),i.length>t.maxNonSimpleConditionLength))return}i||(i=r.getText(n.test));let s=r.getText(a);if(i.includes(`
|
|
16
|
+
`))return;let l=r.getTokenAfter(n);if(l&&l.type===J.AST_TOKEN_TYPES.Punctuator&&l.value==="}"){let f=r.getTokenAfter(l);if(f&&f.type===J.AST_TOKEN_TYPES.Keyword&&(f.value==="else"||f.value==="catch"))return}let p=Li(r,n),c=`if (${i}) ${s}`;t.maxLineLength&&c.length+p.length>t.maxLineLength||e.report({node:n,messageId:"noSingleLineCurly",fix:f=>f.replaceText(n,c)})}}}});function Dn(e){return e.type===J.AST_NODE_TYPES.CallExpression||e.type===J.AST_NODE_TYPES.BinaryExpression||e.type===J.AST_NODE_TYPES.MemberExpression&&_n(e)}function _n(e){return e.object.type===J.AST_NODE_TYPES.MemberExpression?_n(e.object):e.object.type!==J.AST_NODE_TYPES.Identifier}function Li(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}function $n(e){if(!e.argument)return!0;let t=e.argument;return t.type===J.AST_NODE_TYPES.ArrayExpression&&t.elements.length===0||t.type===J.AST_NODE_TYPES.ObjectExpression&&t.properties.length===0||t.type===J.AST_NODE_TYPES.Literal||t.type===J.AST_NODE_TYPES.Identifier||t.type===J.AST_NODE_TYPES.TemplateLiteral||t.type===J.AST_NODE_TYPES.TaggedTemplateExpression?!0:t.type===J.AST_NODE_TYPES.CallExpression?t.arguments.length===0:t.type===J.AST_NODE_TYPES.UnaryExpression?$n(t):!1}var Mt={name:Ln,rule:Di};var oe=require("@typescript-eslint/utils");var _i=oe.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Un="react-compiler-migration",$i=Y({disallowHooks:$(te(Y({name:H(),replacement:H()}))),disallowMethods:$(te(Y({name:H(),replacement:$(H()),requireTrueProp:$(H())})))}),Ui=/eslint +react-compiler\/react-compiler: +\["error/;function Wi(e){return e.type===oe.AST_NODE_TYPES.Identifier?e.name.startsWith("use"):e.type===oe.AST_NODE_TYPES.MemberExpression&&e.property.type===oe.AST_NODE_TYPES.Identifier?e.property.name.startsWith("use"):!1}var Vi=_i({name:Un,meta:{type:"suggestion",fixable:"code",docs:{description:"Rules to help migrate to the new React compiler"},messages:{disallowedFunctionOrMethod:"{{functionOrMethod}} is not supported in react compiler. Use {{replacement}} instead.",replace:"Replace with safe alternative {{replacement}}",disallowedMethodWithMissingRequireTrueProp:"{{method}} is should have a prop named {{requireTrueProp}} set to true when used in react compiler."},hasSuggestions:!0,schema:[$i]},defaultOptions:[{}],create(e,[t]){let r=!1;for(let n of e.sourceCode.getAllComments())if(Ui.test(n.value)){r=!0;break}return r?{CallExpression(n){if(t.disallowHooks?.length){let o=null,a=null;if(n.callee.type===oe.AST_NODE_TYPES.Identifier?(o=n.callee.name,a=n.callee):n.callee.type===oe.AST_NODE_TYPES.MemberExpression&&n.callee.property.type===oe.AST_NODE_TYPES.Identifier&&(o=n.callee.property.name,a=n.callee.property),o){let i=t.disallowHooks.find(s=>s.name===o);i&&a&&e.report({node:n,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:i.name,replacement:i.replacement},suggest:[{messageId:"replace",data:{replacement:i.replacement},fix:s=>s.replaceText(a,i.replacement)}]})}}if(t.disallowMethods?.length&&Wi(n.callee)){for(let o of n.arguments)if(o.type===oe.AST_NODE_TYPES.ObjectExpression){for(let a of o.properties)if(a.type===oe.AST_NODE_TYPES.Property&&a.key.type===oe.AST_NODE_TYPES.Identifier){let i=a.key.name,s=t.disallowMethods.find(l=>l.name===i);if(s){if(s.requireTrueProp){let l=s.requireTrueProp,p=!1;for(let c of o.properties)if(c.type===oe.AST_NODE_TYPES.Property&&c.key.type===oe.AST_NODE_TYPES.Identifier&&c.key.name===l&&c.value.type===oe.AST_NODE_TYPES.Literal&&c.value.value===!0){p=!0;break}if(!p){e.report({node:a,messageId:"disallowedMethodWithMissingRequireTrueProp",data:{method:s.name,requireTrueProp:l}});continue}}s.replacement&&e.report({node:a,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:s.name,replacement:s.replacement},suggest:[{messageId:"replace",data:{replacement:s.replacement},fix:l=>l.replaceText(a.key,s.replacement)}]})}}}}}}:{}}}),Dt={name:Un,rule:Vi};var Ke=require("@typescript-eslint/utils"),zi=Ke.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Wn="require-description",Hi=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,Yi=/^eslint-disable-(next-)?line$/u,qi=zi({name:Wn,meta:{type:"problem",docs:{description:"Require descriptions for eslint directives."},messages:{missingDescription:"Unexpected undescribed directive comment. Include descriptions to explain why the comment is necessary."},schema:[{type:"object",properties:{ignore:{type:"array",items:{type:"string",enum:["eslint","eslint-disable","eslint-disable-line","eslint-disable-next-line","eslint-enable","eslint-env","exported","global","globals"]},additionalItems:!1,uniqueItems:!0}},additionalProperties:!1}]},defaultOptions:[{ignore:[]}],create(e,[t]){let r=e.sourceCode,n=new Set(t.ignore||[]);return{Program(){for(let o of r.getAllComments()){let a=Ji(o);a!=null&&(n.has(a.kind)||a.description||e.report({loc:Xi(o.loc),messageId:"missingDescription"}))}}}}}),Vn={name:Wn,rule:qi};function Ji(e){let{text:t,description:r}=Bi(e.value);if(!t)return null;let n=Hi.exec(t);if(!n)return null;let o=n[1];if(!o)return null;let a=Yi.test(o);if(e.type===Ke.TSESTree.AST_TOKEN_TYPES.Line&&!a||a&&e.loc.start.line!==e.loc.end.line)return null;let i=t.slice(n.index+o.length);return{kind:o,value:i.trim(),description:r}}function Bi(e){let t=e.split(/\s-{2,}\s/u);return{text:t[0]?.trim(),description:t.length>1?t[1]?.trim()??null:null}}function Xi(e){return{start:{line:e.start.line,column:-1},end:e.end}}var L=require("@typescript-eslint/utils"),Se=require("zod/v4");var Gi=Se.z.object({varsToCheck:Se.z.array(Se.z.object({selector:Se.z.string().optional(),fromFnCall:Se.z.string().optional(),prop:Se.z.string().or(Se.z.array(Se.z.string())),errorMsg:Se.z.string().optional()}))}),Lt=K({name:"require-reads-to-var-prop",meta:{type:"suggestion",docs:{description:"Require specific properties from variables to be read or ensure the variable is passed to functions/components"},messages:{propNotRead:'"{{fnName}}" requires reads to the prop "{{prop}}". {{customMsg}}',propsNotRead:'"{{fnName}}" requires reads to the props {{props}}. {{customMsg}}'},schema:[Ce(Gi)]},defaultOptions:[{varsToCheck:[]}],create(e,[t]){let r=new Map,n=(i,s,l,p)=>{let c=new Set;for(let y of i.properties)y.type===L.AST_NODE_TYPES.Property&&y.key.type===L.AST_NODE_TYPES.Identifier&&c.add(y.key.name);let f=s.filter(y=>!c.has(y));if(f.length>0)if(f.length===1)e.report({node:i,messageId:"propNotRead",data:{prop:f[0],fnName:p,customMsg:l||""}});else{let y=f.map(T=>`"${T}"`).join(", ");e.report({node:i,messageId:"propsNotRead",data:{props:y,fnName:p,customMsg:l||""}})}},o=i=>{if(i.init?.type===L.AST_NODE_TYPES.CallExpression){if(i.init.callee.type===L.AST_NODE_TYPES.Identifier)return i.init.callee.name;if(i.init.callee.type===L.AST_NODE_TYPES.MemberExpression&&i.init.callee.property.type===L.AST_NODE_TYPES.Identifier)return i.init.callee.object.type===L.AST_NODE_TYPES.Identifier?`${i.init.callee.object.name}.${i.init.callee.property.name}`:i.init.callee.property.name}return"unknown function"},a={};for(let i of t.varsToCheck)i.selector&&(a[i.selector]=s=>{if(s.type===L.AST_NODE_TYPES.VariableDeclarator&&s.id.type===L.AST_NODE_TYPES.Identifier&&r.set(s.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:s.id,fnName:o(s)}),s.type===L.AST_NODE_TYPES.VariableDeclarator&&s.id.type===L.AST_NODE_TYPES.ObjectPattern){let l=Array.isArray(i.prop)?i.prop:[i.prop];n(s.id,l,i.errorMsg,o(s))}});for(let i of t.varsToCheck)if(i.fromFnCall){let s=i.fromFnCall;if(s.startsWith("*.")){let p=`VariableDeclarator > CallExpression > MemberExpression[property.name="${s.slice(2)}"]`;a[p]=c=>{if(c.type!==L.AST_NODE_TYPES.MemberExpression||c.parent.type!==L.AST_NODE_TYPES.CallExpression)return;let f=c.parent;if(f.parent.type!==L.AST_NODE_TYPES.VariableDeclarator)return;let y=f.parent;if(y.id.type===L.AST_NODE_TYPES.Identifier)r.set(y.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:y.id,fnName:i.fromFnCall||"unknown function"});else if(y.id.type===L.AST_NODE_TYPES.ObjectPattern){let T=Array.isArray(i.prop)?i.prop:[i.prop];n(y.id,T,i.errorMsg,i.fromFnCall||"unknown function")}}}else if(s.includes(".")){let[l,p]=s.split("."),c=`VariableDeclarator > CallExpression > MemberExpression[object.name="${l}"][property.name="${p}"]`;a[c]=f=>{if(f.type!==L.AST_NODE_TYPES.MemberExpression||f.parent.type!==L.AST_NODE_TYPES.CallExpression)return;let y=f.parent;if(y.parent.type!==L.AST_NODE_TYPES.VariableDeclarator)return;let T=y.parent;if(T.id.type===L.AST_NODE_TYPES.Identifier)r.set(T.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:T.id,fnName:i.fromFnCall||"unknown function"});else if(T.id.type===L.AST_NODE_TYPES.ObjectPattern){let I=Array.isArray(i.prop)?i.prop:[i.prop];n(T.id,I,i.errorMsg,i.fromFnCall||"unknown function")}}}else{let l=`VariableDeclarator > CallExpression > Identifier[name="${s}"]`;a[l]=p=>{if(p.type!==L.AST_NODE_TYPES.Identifier||p.parent.type!==L.AST_NODE_TYPES.CallExpression)return;let c=p.parent;if(c.parent.type!==L.AST_NODE_TYPES.VariableDeclarator)return;let f=c.parent;if(f.id.type===L.AST_NODE_TYPES.Identifier)r.set(f.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:f.id,fnName:i.fromFnCall||"unknown function"});else if(f.id.type===L.AST_NODE_TYPES.ObjectPattern){let y=Array.isArray(i.prop)?i.prop:[i.prop];n(f.id,y,i.errorMsg,i.fromFnCall||"unknown function")}}}}return{...a,"Program:exit"(){for(let[i,{props:s,errorMsg:l,node:p,fnName:c}]of r){let y=e.sourceCode.getScope(p).set.get(i);if(y){let T=new Set(s);for(let I of y.references){let x=I.identifier,E=x.parent;if(!(E.type===L.AST_NODE_TYPES.VariableDeclarator&&E.id===x)){if(E.type===L.AST_NODE_TYPES.MemberExpression&&E.object===x&&E.property.type===L.AST_NODE_TYPES.Identifier&&T.has(E.property.name)){if(T.delete(E.property.name),T.size===0)break;continue}if(E.type===L.AST_NODE_TYPES.VariableDeclarator&&E.init===x&&E.id.type===L.AST_NODE_TYPES.ObjectPattern){for(let u of E.id.properties)u.type===L.AST_NODE_TYPES.Property&&u.key.type===L.AST_NODE_TYPES.Identifier&&T.has(u.key.name)&&T.delete(u.key.name);if(T.size===0)break;continue}if(!(E.type===L.AST_NODE_TYPES.MemberExpression&&E.object===x&&E.property.type===L.AST_NODE_TYPES.Identifier&&!s.includes(E.property.name))){T.clear();break}}}if(T.size>0){let I=Array.from(T);if(I.length===1)e.report({node:p,messageId:"propNotRead",data:{prop:I[0],fnName:c,customMsg:l||""}});else{let x=I.map(E=>`"${E}"`).join(", ");e.report({node:p,messageId:"propsNotRead",data:{props:x,fnName:c,customMsg:l||""}})}}}}}}}});function Yn(e){return/^use[A-Z0-9]/.test(e)}function Ze(e){return e.type==="Identifier"?Yn(e.name):e.type==="MemberExpression"&&!e.computed&&Ze(e.property)?e.object.type==="Identifier":!1}function qn(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function Jn(e,t){return e.name===t||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===t}function Bn(e){return!!(e.parent&&e.parent.callee&&Jn(e.parent.callee,"forwardRef"))}function Xn(e){return!!(e.parent&&e.parent.callee&&Jn(e.parent.callee,"memo"))}function _t(e){for(;e;){let t=Kn(e);if(t&&(qn(t)||Ze(t))||Bn(e)||Xn(e))return!0;e=e.parent}return!1}function zn(e){return!1}function $t(e){return!1}var Ki=/eslint +react-compiler\/react-compiler: +\["error/,Gn={meta:{type:"problem",docs:{description:"enforces the Rules of Hooks",recommended:!0,url:"https://reactjs.org/docs/hooks-rules.html"},schema:[{type:"object",ignoreIfReactCompilerIsEnabled:!1,properties:{ignoreIfReactCompilerIsEnabled:{type:"boolean"}}}]},create(e){if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let l of e.sourceCode.getAllComments())if(Ki.test(l.value))return{CallExpression(p){let c=null;p.callee.name==="useMemo"?c="useMemo":p.callee.name==="useCallback"&&(c="useCallback"),c&&e.report({node:p,message:`"${c}" is not necessary when using React Compiler.`})}}}let t=typeof e.getSource=="function"?l=>t(l):l=>e.sourceCode.getText(l),r=typeof e.getScope=="function"?()=>r():l=>e.sourceCode.getScope(l),n=null,o=[],a=[],i=new WeakSet;function s(l){for(let p of l.references){let c=p.identifier.parent;if(c.type==="VariableDeclarator"&&c.init&&c.init.type==="CallExpression"&&c.init.callee&&zn(c.init.callee))for(let f of p.resolved.references)f!==p&&i.add(f.identifier)}}return{onCodePathSegmentStart:l=>a.push(l),onCodePathSegmentEnd:()=>a.pop(),onCodePathStart:()=>o.push(new Map),onCodePathEnd(l,p){let c=o.pop();if(c.size===0)return;let f=new Set;function y(g,m){let{cache:S}=y,k=S.get(g.id),R=new Set(m);if(R.has(g.id)){let C=[...R],N=C.slice(C.indexOf(g.id)+1);for(let z of N)f.add(z);return BigInt("0")}if(R.add(g.id),k!==void 0)return k;if(l.thrownSegments.includes(g))k=BigInt("0");else if(g.prevSegments.length===0)k=BigInt("1");else{k=BigInt("0");for(let C of g.prevSegments)k+=y(C,R)}return g.reachable&&k===BigInt("0")?S.delete(g.id):S.set(g.id,k),k}function T(g,m){let{cache:S}=T,k=S.get(g.id),R=new Set(m);if(R.has(g.id)){let C=Array.from(R),N=C.slice(C.indexOf(g.id)+1);for(let z of N)f.add(z);return BigInt("0")}if(R.add(g.id),k!==void 0)return k;if(l.thrownSegments.includes(g))k=BigInt("0");else if(g.nextSegments.length===0)k=BigInt("1");else{k=BigInt("0");for(let C of g.nextSegments)k+=T(C,R)}return S.set(g.id,k),k}function I(g){let{cache:m}=I,S=m.get(g.id);if(S===null)return 1/0;if(S!==void 0)return S;if(m.set(g.id,null),g.prevSegments.length===0)S=1;else{S=1/0;for(let k of g.prevSegments){let R=I(k);R<S&&(S=R)}S+=1}return m.set(g.id,S),S}y.cache=new Map,T.cache=new Map,I.cache=new Map;let x=T(l.initialSegment),E=Kn(p),u=_t(p),A=E?qn(E)||Ze(E):Bn(p)||Xn(p),b=1/0;for(let g of l.finalSegments){if(!g.reachable)continue;let m=I(g);m<b&&(b=m)}for(let[g,m]of c){if(!g.reachable)continue;let S=g.nextSegments.length===0?b<=I(g):b<I(g),k=y(g)*T(g),R=f.has(g.id);for(let C of m)if(R&&!$t(C)&&e.report({node:C,message:`React Hook "${t(C)}" may be executed more than once. Possibly because it is called in a loop. React Hooks must be called in the exact same order in every component render.`}),A){if(p.async&&e.report({node:C,message:`React Hook "${t(C)}" cannot be called in an async function.`}),!R&&k!==x&&!$t(C)){let z=`React Hook "${t(C)}" is called conditionally. React Hooks must be called in the exact same order in every component render.`+(S?" Did you accidentally call a React Hook after an early return?":"");e.report({node:C,message:z})}}else if(p.parent&&(p.parent.type==="MethodDefinition"||p.parent.type==="ClassProperty")&&p.parent.value===p){let N=`React Hook "${t(C)}" cannot be called in a class component. React Hooks must be called in a React function component or a custom React Hook function.`;e.report({node:C,message:N})}else if(E){let N=`React Hook "${t(C)}" is called in function "${t(E)}" that is neither a React function component nor a custom React Hook function. React component names must start with an uppercase letter. React Hook names must start with the word "use".`;e.report({node:C,message:N})}else if(p.type==="Program"){let N=`React Hook "${t(C)}" cannot be called at the top level. React Hooks must be called in a React function component or a custom React Hook function.`;e.report({node:C,message:N})}else if(u&&!$t(C)){if(p.parent.type==="CallExpression"&&p.parent.callee.type==="Identifier"&&p.parent.callee.name==="useCallback"){let z=p.parent;if(z.parent.type==="VariableDeclarator"&&Yn(z.parent.id.name))return}let N=`React Hook "${t(C)}" cannot be called inside a callback. React Hooks must be called in a React function component or a custom React Hook function.`;e.report({node:C,message:N})}}},CallExpression(l){if(Ze(l.callee)){let p=Hn(o),c=Hn(a),f=p.get(c);f||(f=[],p.set(c,f)),f.push(l.callee)}l.callee.type==="Identifier"&&(l.callee.name==="useEffect"||zn(l.callee))&&l.arguments.length>0&&(n=l)},Identifier(l){n==null&&i.has(l)&&l.parent.type!=="CallExpression"&&e.report({node:l,message:`\`${t(l)}\` is a function created with React Hook "useEffectEvent", and can only be called from the same component. They cannot be assigned to variables or passed down.`})},"CallExpression:exit"(l){l===n&&(n=null)},FunctionDeclaration(l){_t(l)&&s(r(l))},ArrowFunctionExpression(l){_t(l)&&s(r(l))}}}};function Kn(e){return e.type==="FunctionDeclaration"||e.type==="FunctionExpression"&&e.id?e.id:e.type==="FunctionExpression"||e.type==="ArrowFunctionExpression"?e.parent.type==="VariableDeclarator"&&e.parent.init===e?e.parent.id:e.parent.type==="AssignmentExpression"&&e.parent.right===e&&e.parent.operator==="="?e.parent.left:e.parent.type==="Property"&&e.parent.value===e&&!e.parent.computed?e.parent.key:e.parent.type==="AssignmentPattern"&&e.parent.right===e&&!e.parent.computed?e.parent.left:void 0:void 0}function Hn(e){return e[e.length-1]}var Q=require("@typescript-eslint/utils"),ae=ve(require("zod/v4"));var Zi=ae.object({indent:ae.union([ae.string().regex(/^\s+$/),ae.number().int().min(1)]).optional(),tags:ae.array(ae.string()).optional(),functions:ae.array(ae.string()).optional(),comments:ae.array(ae.string()).optional()}),Ut=K({name:"template-indent",meta:{type:"suggestion",docs:{description:"Fix whitespace-insensitive template indentation"},fixable:"code",schema:[Ce(Zi)],messages:{improperlyIndented:"Templates should be properly indented."}},defaultOptions:[{}],create(e){let t=e.sourceCode,{comments:r=["HTML","indent"],functions:n=["dedent","stripIndent"],tags:o=["outdent","dedent","gql","sql","html","styled"],indent:a}=e.options[0],i=r.map(u=>u.toLowerCase());function s(u){let A=u.split(/\r?\n/),b=A.filter(m=>m.trim()!=="");if(b.length===0)return u;let g=Number.POSITIVE_INFINITY;for(let m of b){let S=m.match(/^(\s*)/);S&&(g=Math.min(g,S[1]?.length??0))}return!isFinite(g)||g===0?u:A.map(m=>m.slice(g)).join(`
|
|
17
|
+
`)}function l(u,A,b){return u.split(/\r?\n/).map(m=>m.trim()===""?m:b.repeat(A)+m).join(`
|
|
18
|
+
`)}function p(u){if(u.type===Q.AST_NODE_TYPES.Identifier)return u.name;if(u.type===Q.AST_NODE_TYPES.MemberExpression){let A=u.object.type===Q.AST_NODE_TYPES.Identifier?u.object.name:null,b=u.property.type===Q.AST_NODE_TYPES.Identifier?u.property.name:null;return A&&b?`${A}.${b}`:b}return null}function c(u,A){if(!u)return!1;for(let b of A)if(b.includes(".")){let g=b.split(".");if(u.type===Q.AST_NODE_TYPES.MemberExpression&&u.object.type===Q.AST_NODE_TYPES.Identifier&&u.property.type===Q.AST_NODE_TYPES.Identifier&&u.object.name===g[0]&&u.property.name===g[1])return!0}else if(u.type===Q.AST_NODE_TYPES.Identifier&&u.name===b)return!0;return!1}function f(u,A){let b=u.parent;if(b.type!==Q.AST_NODE_TYPES.TaggedTemplateExpression)return!1;let g=p(b.tag);return g?A.includes(g):!1}function y(u,A){if(!u||u.type!==Q.AST_NODE_TYPES.CallExpression)return!1;let{method:b,argumentsLength:g,optionalCall:m=!0,optionalMember:S=!0}=A;return g!==void 0&&u.arguments.length!==g||!m&&u.optional||u.callee.type!==Q.AST_NODE_TYPES.MemberExpression||!S&&u.callee.optional||u.callee.property.type!==Q.AST_NODE_TYPES.Identifier?!1:u.callee.property.name===b}function T(u,A){if(!u||u.type!==Q.AST_NODE_TYPES.CallExpression)return!1;let{name:b,argumentsLength:g,optionalCall:m=!0}=A;return g!==void 0&&u.arguments.length!==g||!m&&u.optional||u.callee.type!==Q.AST_NODE_TYPES.Identifier?!1:u.callee.name===b}function I(u){return y(u.parent,{method:"toMatchInlineSnapshot",argumentsLength:1,optionalCall:!1,optionalMember:!1})&&u.parent.type===Q.AST_NODE_TYPES.CallExpression&&u.parent.arguments[0]===u&&T(u.parent.callee.type===Q.AST_NODE_TYPES.MemberExpression?u.parent.callee.object:null,{name:"expect",argumentsLength:1,optionalCall:!1,optionalMember:!1})}function x(u){if(i.length>0){let A=t.getTokenBefore(u,{includeComments:!0});if(A?.type===Q.AST_TOKEN_TYPES.Block&&i.includes(A.value.trim().toLowerCase()))return!0}return!!(I(u)||o.length>0&&f(u,o)||n.length>0&&u.parent.type===Q.AST_NODE_TYPES.CallExpression&&u.parent.arguments.includes(u)&&c(u.parent.callee,n))}function E(u){let A=`__PLACEHOLDER__${Math.random()}`,b=u.quasis.map(X=>t.getText(X).slice(1,X.tail?-1:-2)).join(A),g=b.match(/\r?\n/);if(!g)return;let m=g[0],S=t.lines[t.getLocFromIndex(u.range[0]).line-1];if(!S)return;let R=S.match(/^(\s*)\S/)?.[1]??"",C;typeof a=="string"?C=a:typeof a=="number"?C=" ".repeat(a):C=R.startsWith(" ")?" ":" ";let z=s(b).replace(new RegExp(`^${m}|${m}[ ]*$`,"g"),""),B=m+l(z,1,R+C)+m+R,ne=b.includes(`\r
|
|
19
|
+
`)?`\r
|
|
20
|
+
`:`
|
|
21
|
+
`,ee=b.split(/\r?\n/),xe=ee.map((X,ye)=>ye!==ee.length-1&&X===C?"":X).join(ne);if(B!==xe)return{node:u,messageId:"improperlyIndented",fix:X=>B.split(A).map((ye,fe)=>{let se=u.quasis[fe];return se?X.replaceTextRange([se.range[0]+1,se.range[1]-(se.tail?1:2)],ye):[]}).flat()}}return{TemplateLiteral(u){if(!x(u))return;let A=E(u);if(A)return e.report(A)}}}});var Wt=require("@typescript-eslint/utils");function Qi(e){if(!("regex"in e))return!1;let t=e.regex.flags;return t.includes("g")||t.includes("y")}function es(e){let t=e.parent;return t?.type===Wt.AST_NODE_TYPES.NewExpression&&t.callee.type===Wt.AST_NODE_TYPES.Identifier&&t.callee.name==="RegExp"}var Vt=K({name:"use-top-level-regex",meta:{type:"suggestion",docs:{description:"Require regex literals to be declared at the top level to avoid performance issues"},messages:{regexShouldBeTopLevel:"Move this regex literal to the top level to avoid creating new RegExp objects on each function call."},schema:[],hasSuggestions:!1},defaultOptions:[],create(e){function t(r){Qi(r)||es(r)||e.report({node:r,messageId:"regexShouldBeTopLevel"})}return{"FunctionDeclaration Literal[regex], FunctionExpression Literal[regex], ArrowFunctionExpression Literal[regex], MethodDefinition Literal[regex]":t}}});var Zn={[Ot.name]:Ot.rule,[ft.name]:ft.rule,[ut.name]:ut.rule,"rules-of-hooks":Gn,"exhaustive-deps":rn,"require-description":Vn.rule,[mt.name]:mt.rule,[yt.name]:yt.rule,[Ft.name]:Ft.rule,[rt.name]:rt.rule,[ct.name]:ct.rule,[Et.name]:Et.rule,[Mt.name]:Mt.rule,[ht.name]:ht.rule,[dt.name]:dt.rule,[st.name]:st.rule,[Dt.name]:Dt.rule,[nt.name]:nt.rule,[pt.name]:pt.rule,[Ct.name]:Ct.rule,[wt.name]:wt.rule,[Rt.name]:Rt.rule,[vt.name]:vt.rule,[At.name]:At.rule,[jt.name]:jt.rule,[xt.name]:xt.rule,[bt.name]:bt.rule,[Vt.name]:Vt.rule,[Pt.name]:Pt.rule,[Lt.name]:Lt.rule,[Ut.name]:Ut.rule};var ts={rules:Zn};0&&(module.exports={extendedLintPlugin});
|
package/dist/extended-lint.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{AST_NODE_TYPES as te,ESLintUtils as Kn}from"@typescript-eslint/utils";var Be=Symbol.for("optional");function _(e){return{...e,[Be]:!0}}function $t(e,t){return{enum:e,...t}}function Ae(e){return{...e,type:"boolean"}}function V(e){return{...e,type:"string"}}function de(e){return{...e,type:"number"}}function ee(e,t){return{...t,type:"array",items:e}}function z(e,t){let r={...t,type:"object",properties:e};if(e&&(r.additionalProperties||=!1,!r.required)){let n,a=[];for(n in e)e[n][Be]?e[n][Be]=void 0:a.push(n);a.length>0&&(r.required=a)}return r}var Zn=Kn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Wt="react-compiler-extra",Qn=z({runOnlyWithEnableCompilerDirective:_(Ae())}),er=/eslint +react-compiler\/react-compiler: +\["error/;function tr(e){return e.type===te.Identifier?e.name.startsWith("use"):e.type===te.MemberExpression&&e.property.type===te.Identifier?e.property.name.startsWith("use"):!1}var nr=/\bthis[.[]/;function Ut(e){return nr.test(e)}var rr=Zn({name:Wt,meta:{type:"suggestion",fixable:"code",docs:{description:"Extra rules to enforce best practices when using the React compiler"},messages:{objectMethodIsNotSupported:"Object methods such as `{ method() {} }` have limited support to optimizations in the React compiler, use a function expression `{ method: () => {} }` instead.",replaceWithFunctionExpression:"Replace with function expression",thisKeywordInMethod:"Object method uses `this` keyword which would have different behavior if converted to an arrow function. Fix this manually."},hasSuggestions:!0,schema:[Qn]},defaultOptions:[{}],create(e,[t]){let r=!1;if(t.runOnlyWithEnableCompilerDirective){for(let o of e.sourceCode.getAllComments())if(er.test(o.value)){r=!0;break}if(!r)return{}}function n(o){for(let i of o.properties)if(i.type===te.Property&&i.method&&i.value.type===te.FunctionExpression){let s=e.sourceCode,l=s.getText(i.key),p=i.value,c=s.getText(p.body);if(Ut(c))e.report({node:i,messageId:"thisKeywordInMethod"});else{let f=p.params.map(T=>s.getText(T)).join(", "),y="";p.generator?y=`${l}: function* (${f}) ${c}`:y=`${l}: (${f}) => ${c}`,e.report({node:i,messageId:"objectMethodIsNotSupported",fix:T=>T.replaceText(i,y)})}}}function a(o){for(let i of o.properties)if(i.type===te.Property&&i.value.type===te.ObjectExpression){for(let s of i.value.properties)if(s.type===te.Property&&s.method&&s.value.type===te.FunctionExpression){let p=e.sourceCode.getText(s.value.body);Ut(p)&&e.report({node:s,messageId:"thisKeywordInMethod"})}}}return{CallExpression(o){if(tr(o.callee))for(let i of o.arguments){if(i.type===te.ObjectExpression&&(n(i),a(i)),i.type===te.ArrowFunctionExpression&&(i.body.type===te.ObjectExpression&&(n(i.body),a(i.body)),i.body.type===te.BlockStatement))for(let s of i.body.body)s.type===te.ReturnStatement&&s.argument?.type===te.ObjectExpression&&(n(s.argument),a(s.argument));if(i.type===te.FunctionExpression)for(let s of i.body.body)s.type===te.ReturnStatement&&s.argument?.type===te.ObjectExpression&&(n(s.argument),a(s.argument))}}}}}),Xe={name:Wt,rule:rr};import{AST_NODE_TYPES as re}from"@typescript-eslint/utils";import{z as w}from"zod/v4";import{ESLintUtils as ir}from"@typescript-eslint/utils";import*as Vt from"zod/v4";function X(e){let r=ir.RuleCreator(n=>`https://github.com/lucasols/extended-lint#${n}`)(e);return{name:e.name,rule:r}}function xe(e){return Vt.toJSONSchema(e)}var sr=w.object({disallow:w.array(w.object({selector:w.string(),message:w.string(),replace:w.optional(w.union([w.string(),w.object({regex:w.string(),with:w.string()})])),replaceType:w.optional(w.enum(["suggestion","autofix"]))})).optional(),disallowFnCalls:w.optional(w.array(w.object({fn:w.string(),withArgs:w.optional(w.array(w.object({atIndex:w.number(),value:w.union([w.string(),w.number(),w.boolean()])}))),message:w.string(),replaceWith:w.optional(w.string()),ignoreRegex:w.optional(w.string())}))),__dev_simulateFileName:w.optional(w.string()),mustMatchSyntax:w.optional(w.array(w.object({includeRegex:w.string(),mustCallFn:w.optional(w.array(w.object({anyCall:w.array(w.object({fn:w.string(),withArgs:w.array(w.object({atIndex:w.number(),literal:w.union([w.string(),w.number(),w.boolean()])}))})),message:w.optional(w.string())}))),mustMatchSelector:w.optional(w.array(w.object({selector:w.string(),message:w.string()}))),mustHaveExport:w.optional(w.array(w.object({name:w.string(),type:w.enum(["function","variable","any"]).default("any"),message:w.string()})))})))}),Ge=X({name:"advanced-no-restricted-syntax",meta:{type:"suggestion",docs:{description:"Disallow specific syntax patterns"},schema:[xe(sr)],messages:{default:"{{message}}"},fixable:"code",hasSuggestions:!0},defaultOptions:[{disallow:[]}],create(e,[t]){let r={},{mustMatchSyntax:n,__dev_simulateFileName:a,disallow:o,disallowFnCalls:i}=t,s=a??e.filename,l=[],p=new Map,c=new Set,f=new Map,y=new Set,T=new Map;function I(m){for(let S of m.specifiers)S.type===re.ImportSpecifier&&S.imported.type===re.Identifier&&S.imported.name!==S.local.name&&T.set(S.local.name,S.imported.name)}function b(m){if(m.declaration){if(m.declaration.type===re.FunctionDeclaration&&m.declaration.id){let S=m.declaration.id.name;for(let k of Array.from(y)){let[R,C]=k.split(":");R===S&&(C==="function"||C==="any")&&y.delete(k)}}else if(m.declaration.type===re.VariableDeclaration){for(let S of m.declaration.declarations)if(S.id.type===re.Identifier){let k=S.id.name;for(let R of Array.from(y)){let[C,N]=R.split(":");C===k&&(N==="variable"||N==="any")&&y.delete(R)}}}}for(let S of m.specifiers)if(S.exported.type===re.Identifier){let k=S.exported.name;for(let R of Array.from(y)){let[C,N]=R.split(":");C===k&&N==="any"&&y.delete(R)}}}function E(m){m.id.type===re.Identifier&&m.init?.type===re.Identifier&&T.set(m.id.name,m.init.name)}function u(m){return T.get(m)??m}function A(m,S){return u(m)===S||m===S}for(let{includeRegex:m,mustCallFn:S,mustMatchSelector:k,mustHaveExport:R}of n??[]){let C=or(s,new RegExp(m));if(!C)continue;let N=W=>{let J=W;for(let{name:G,value:Z}of C)J=J.replaceAll(G,Z);return J};for(let{anyCall:W,message:J}of S??[]){let G=`Expected file to call the function: ${W.map(({fn:Z})=>Z).join(" or ")}`;c.add(G),l.push(Z=>{let{callee:Ee}=Z;if(Ee.type===re.Identifier){for(let{fn:Q,withArgs:Oe}of W)if(Ee.name===Q){c.delete(G);for(let ye of Oe){let me=Z.arguments[ye.atIndex],ge=typeof ye.literal=="string"?N(ye.literal):ye.literal;if(!me){e.report({node:Z,messageId:"default",data:{message:`Missing argument with value "${ge}" at index ${ye.atIndex}${J?`: ${N(J)}`:""}`}});continue}if(me.type!==re.Literal){e.report({node:me,messageId:"default",data:{message:`Argument at position ${ye.atIndex} should the literal "${ge}"${J?`: ${N(J)}`:""}`}});continue}me.value!==ge&&e.report({node:me,messageId:"default",data:{message:`Argument should have the value "${ge}"${J?`: ${N(J)}`:""}`},fix:we=>we.replaceText(me,typeof ge=="string"?`'${ge}'`:String(ge))})}break}}})}for(let{selector:W,message:J}of k??[])f.set(W,N(J)),p.set(N(W),()=>{f.delete(W)});for(let{name:W,type:J,message:G}of R??[]){let Z=N(W),Ee=N(G);y.add(`${Z}:${J}:${Ee}`)}}for(let{fn:m,withArgs:S,message:k,replaceWith:R,ignoreRegex:C}of i??[])C&&new RegExp(C).test(s)||l.push(N=>{let{callee:W}=N;if(W.type!==re.Identifier||!A(W.name,m))return;if(S)for(let G of S){let Z=N.arguments[G.atIndex];if(!Z){e.report({node:N,messageId:"default",data:{message:`Missing argument with value "${G.value}" at index ${G.atIndex}: ${k}`}});return}if(Z.type!==re.Literal||Z.value!==G.value)return}let J=G=>R?G.replaceText(N,R):null;e.report({node:N,messageId:"default",data:{message:k},suggest:R?[{messageId:"default",data:{message:`Replace with "${R}"`},fix:J}]:void 0})});function x(m,S){let k=r[m];k?r[m]=R=>{k(R),S(R)}:r[m]=S}for(let{selector:m,message:S,replace:k,replaceType:R="suggestion"}of o??[]){if(m==="CallExpression"){l.push(C=>{g(k,C,S,R)});continue}r[m]=C=>{g(k,C,S,R)}}if(p.size>0)for(let[m,S]of p)x(m,S);return l.length>0&&(r.CallExpression=m=>{if(m.type===re.CallExpression)for(let S of l)S(m)}),r.ImportDeclaration=m=>{m.type===re.ImportDeclaration&&I(m)},r.ExportNamedDeclaration=m=>{m.type===re.ExportNamedDeclaration&&b(m)},r.VariableDeclarator=m=>{m.type===re.VariableDeclarator&&E(m)},r["Program:exit"]=m=>{for(let S of c)e.report({node:m,messageId:"default",data:{message:S}});for(let[,S]of f)e.report({node:m,messageId:"default",data:{message:S}});for(let S of y){let[k,R,C]=S.split(":");e.report({node:m,messageId:"default",data:{message:`Missing required export "${k}" of type ${R}: ${C}`}})}},r;function g(m,S,k,R){let C=N=>{if(!m)return null;if(typeof m=="string")return N.replaceText(S,m);{let W=new RegExp(m.regex),J=e.sourceCode.getText(S);return N.replaceText(S,J.replace(W,m.with))}};e.report({node:S,messageId:"default",data:{message:k},fix:m&&R==="autofix"?C:void 0,suggest:m&&R==="suggestion"?[{messageId:"default",data:{message:`Replace with "${typeof m=="string"?m:m.with}"`},fix:C}]:void 0})}}});function or(e,t){let r=[],n=t.exec(e);if(!n)return null;let[a,...o]=n;r.push({name:"$0_lowercase",value:a.toLowerCase()}),r.push({name:"$0_capitalize",value:zt(a)}),r.push({name:"$0_uncapitalize",value:Ht(a)}),r.push({name:"$0",value:a});for(let i=0;i<o.length;i++){let s=`$${i+1}`,l=o[i];r.push({name:`${s}_lowercase`,value:l.toLowerCase()}),r.push({name:`${s}_capitalize`,value:zt(l)}),r.push({name:`${s}_uncapitalize`,value:Ht(l)}),r.push({name:s,value:l})}return r}function zt(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Ht(e){return e.charAt(0).toLowerCase()+e.slice(1)}import{AST_NODE_TYPES as $,AST_TOKEN_TYPES as Yt,ESLintUtils as ar}from"@typescript-eslint/utils";var lr=ar.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Jt="collapse-simple-objs-in-one-line",pr=z({maxLineLength:_(de()),maxProperties:_(de()),nestedObjMaxLineLength:_(de()),nestedObjMaxProperties:_(de()),ignoreTypesWithSuffix:_(ee(V()))}),cr=lr({name:Jt,meta:{type:"suggestion",fixable:"code",docs:{description:"Format simple objects and types in one line"},messages:{singleLineProp:"Object/type should be written in a single line"},schema:[pr]},defaultOptions:[{}],create(e,[t]){let r=e.sourceCode,n=t.ignoreTypesWithSuffix??[],a=t.maxProperties??2,o=t.nestedObjMaxLineLength??t.maxLineLength,i=t.nestedObjMaxProperties??3;function s(p){if(p.type===$.ObjectExpression){let c=p.parent.type===$.Property,f=c?i:a,y=p.properties.length;if(y>f)return!1;if(y===1){let I=p.properties[0];return I.type===$.Property&&I.value.type===$.ObjectExpression||I.type===$.Property&&I.value.type===$.ArrayExpression&&!I.value.elements.every(E=>E&&Ke(E))?!1:{text:r.getText(I),isNested:c,propsSize:y}}let T=[];for(let I of p.properties){if(I.type===$.Property&&!Ke(I.value))return!1;T.push(r.getText(I))}return{text:T.join(", "),isNested:c,propsSize:y}}else{let c=p.parent.parent?.type===$.TSPropertySignature,f=c?i:a,y=p.members.length;if(y>f)return!1;if(n.length>0&&p.parent.type===$.TSTypeAliasDeclaration){let I=p.parent.id.name;if(n.some(b=>I.endsWith(b)))return!1}if(y===1){let I=p.members[0];return I.type===$.TSPropertySignature&&I.typeAnnotation?.typeAnnotation.type===$.TSTypeLiteral?!1:{text:r.getText(I),isNested:c,propsSize:1}}if(p.parent.type===$.TSIntersectionType||p.parent.type===$.TSUnionType&&p.parent.types[0]!==p)return!1;let T=[];for(let I of p.members){if(I.type!==$.TSPropertySignature)return!1;let b=I.typeAnnotation?.typeAnnotation;if(!b||b.type===$.TSTypeLiteral||!qt(b))return!1;if(b.type===$.TSTypeReference&&b.typeArguments){if(b.typeArguments.params.length>1)return!1;let u=b.typeArguments.params[0];if(!qt(u))return!1}let E=r.getText(I).trim();(E.endsWith(";")||E.endsWith(","))&&(E=E.slice(0,-1)),T.push(E)}return{text:T.join("; "),isNested:c,propsSize:y}}}function l(p){if(p.loc.start.line===p.loc.end.line)return;if(p.parent.type!==$.JSXExpressionContainer){let b=0,E=!1,u=r.getTokenAfter(p,{filter:x=>x.type!==Yt.Punctuator||E?!0:x.value===","?(b++,!1):x.value===";"?(b++,E=!0,!1):x.value===")"||x.value==="}"?(b++,!1):!0});if(b>4)return;let A=u?.type===Yt.Template&&u.value.startsWith(`}
|
|
1
|
+
import{AST_NODE_TYPES as ee,ESLintUtils as Kn}from"@typescript-eslint/utils";var Be=Symbol.for("optional");function _(e){return{...e,[Be]:!0}}function $t(e,t){return{enum:e,...t}}function Re(e){return{...e,type:"boolean"}}function V(e){return{...e,type:"string"}}function ge(e){return{...e,type:"number"}}function Q(e,t){return{...t,type:"array",items:e}}function z(e,t){let r={...t,type:"object",properties:e};if(e&&(r.additionalProperties||=!1,!r.required)){let n,a=[];for(n in e)e[n][Be]?e[n][Be]=void 0:a.push(n);a.length>0&&(r.required=a)}return r}var Zn=Kn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Wt="react-compiler-extra",Qn=z({runOnlyWithEnableCompilerDirective:_(Re())}),er=/eslint +react-compiler\/react-compiler: +\["error/;function tr(e){return e.type===ee.Identifier?e.name.startsWith("use"):e.type===ee.MemberExpression&&e.property.type===ee.Identifier?e.property.name.startsWith("use"):!1}var nr=/\bthis[.[]/;function Ut(e){return nr.test(e)}var rr=Zn({name:Wt,meta:{type:"suggestion",fixable:"code",docs:{description:"Extra rules to enforce best practices when using the React compiler"},messages:{objectMethodIsNotSupported:"Object methods such as `{ method() {} }` have limited support to optimizations in the React compiler, use a function expression `{ method: () => {} }` instead.",replaceWithFunctionExpression:"Replace with function expression",thisKeywordInMethod:"Object method uses `this` keyword which would have different behavior if converted to an arrow function. Fix this manually."},hasSuggestions:!0,schema:[Qn]},defaultOptions:[{}],create(e,[t]){let r=!1;if(t.runOnlyWithEnableCompilerDirective){for(let o of e.sourceCode.getAllComments())if(er.test(o.value)){r=!0;break}if(!r)return{}}function n(o){for(let i of o.properties)if(i.type===ee.Property&&i.method&&i.value.type===ee.FunctionExpression){let s=e.sourceCode,l=s.getText(i.key),p=i.value,c=s.getText(p.body);if(Ut(c))e.report({node:i,messageId:"thisKeywordInMethod"});else{let f=p.params.map(T=>s.getText(T)).join(", "),y="";p.generator?y=`${l}: function* (${f}) ${c}`:y=`${l}: (${f}) => ${c}`,e.report({node:i,messageId:"objectMethodIsNotSupported",fix:T=>T.replaceText(i,y)})}}}function a(o){for(let i of o.properties)if(i.type===ee.Property&&i.value.type===ee.ObjectExpression){for(let s of i.value.properties)if(s.type===ee.Property&&s.method&&s.value.type===ee.FunctionExpression){let p=e.sourceCode.getText(s.value.body);Ut(p)&&e.report({node:s,messageId:"thisKeywordInMethod"})}}}return{CallExpression(o){if(tr(o.callee))for(let i of o.arguments){if(i.type===ee.ObjectExpression&&(n(i),a(i)),i.type===ee.ArrowFunctionExpression&&(i.body.type===ee.ObjectExpression&&(n(i.body),a(i.body)),i.body.type===ee.BlockStatement))for(let s of i.body.body)s.type===ee.ReturnStatement&&s.argument?.type===ee.ObjectExpression&&(n(s.argument),a(s.argument));if(i.type===ee.FunctionExpression)for(let s of i.body.body)s.type===ee.ReturnStatement&&s.argument?.type===ee.ObjectExpression&&(n(s.argument),a(s.argument))}}}}}),Xe={name:Wt,rule:rr};import{AST_NODE_TYPES as re}from"@typescript-eslint/utils";import{z as w}from"zod/v4";import{ESLintUtils as ir}from"@typescript-eslint/utils";import*as Vt from"zod/v4";function G(e){let r=ir.RuleCreator(n=>`https://github.com/lucasols/extended-lint#${n}`)(e);return{name:e.name,rule:r}}function Ie(e){return Vt.toJSONSchema(e)}var sr=w.object({disallow:w.array(w.object({selector:w.string(),message:w.string(),replace:w.optional(w.union([w.string(),w.object({regex:w.string(),with:w.string()})])),replaceType:w.optional(w.enum(["suggestion","autofix"]))})).optional(),disallowFnCalls:w.optional(w.array(w.object({fn:w.string(),withArgs:w.optional(w.array(w.object({atIndex:w.number(),value:w.union([w.string(),w.number(),w.boolean()])}))),message:w.string(),replaceWith:w.optional(w.string()),ignoreRegex:w.optional(w.string())}))),__dev_simulateFileName:w.optional(w.string()),mustMatchSyntax:w.optional(w.array(w.object({includeRegex:w.string(),mustCallFn:w.optional(w.array(w.object({anyCall:w.array(w.object({fn:w.string(),withArgs:w.array(w.object({atIndex:w.number(),literal:w.union([w.string(),w.number(),w.boolean()])}))})),message:w.optional(w.string())}))),mustMatchSelector:w.optional(w.array(w.object({selector:w.string(),message:w.string()}))),mustHaveExport:w.optional(w.array(w.object({name:w.string(),type:w.enum(["function","variable","any"]).default("any"),message:w.string()})))})))}),Ge=G({name:"advanced-no-restricted-syntax",meta:{type:"suggestion",docs:{description:"Disallow specific syntax patterns"},schema:[Ie(sr)],messages:{default:"{{message}}"},fixable:"code",hasSuggestions:!0},defaultOptions:[{disallow:[]}],create(e,[t]){let r={},{mustMatchSyntax:n,__dev_simulateFileName:a,disallow:o,disallowFnCalls:i}=t,s=a??e.filename,l=[],p=new Map,c=new Set,f=new Map,y=new Set,T=new Map;function I(m){for(let S of m.specifiers)S.type===re.ImportSpecifier&&S.imported.type===re.Identifier&&S.imported.name!==S.local.name&&T.set(S.local.name,S.imported.name)}function x(m){if(m.declaration){if(m.declaration.type===re.FunctionDeclaration&&m.declaration.id){let S=m.declaration.id.name;for(let k of Array.from(y)){let[R,C]=k.split(":");R===S&&(C==="function"||C==="any")&&y.delete(k)}}else if(m.declaration.type===re.VariableDeclaration){for(let S of m.declaration.declarations)if(S.id.type===re.Identifier){let k=S.id.name;for(let R of Array.from(y)){let[C,N]=R.split(":");C===k&&(N==="variable"||N==="any")&&y.delete(R)}}}}for(let S of m.specifiers)if(S.exported.type===re.Identifier){let k=S.exported.name;for(let R of Array.from(y)){let[C,N]=R.split(":");C===k&&N==="any"&&y.delete(R)}}}function E(m){m.id.type===re.Identifier&&m.init?.type===re.Identifier&&T.set(m.id.name,m.init.name)}function u(m){return T.get(m)??m}function A(m,S){return u(m)===S||m===S}for(let{includeRegex:m,mustCallFn:S,mustMatchSelector:k,mustHaveExport:R}of n??[]){let C=or(s,new RegExp(m));if(!C)continue;let N=W=>{let J=W;for(let{name:te,value:Z}of C)J=J.replaceAll(te,Z);return J};for(let{anyCall:W,message:J}of S??[]){let te=`Expected file to call the function: ${W.map(({fn:Z})=>Z).join(" or ")}`;c.add(te),l.push(Z=>{let{callee:be}=Z;if(be.type===re.Identifier){for(let{fn:B,withArgs:ye}of W)if(be.name===B){c.delete(te);for(let ue of ye){let ie=Z.arguments[ue.atIndex],Se=typeof ue.literal=="string"?N(ue.literal):ue.literal;if(!ie){e.report({node:Z,messageId:"default",data:{message:`Missing argument with value "${Se}" at index ${ue.atIndex}${J?`: ${N(J)}`:""}`}});continue}if(ie.type!==re.Literal){e.report({node:ie,messageId:"default",data:{message:`Argument at position ${ue.atIndex} should the literal "${Se}"${J?`: ${N(J)}`:""}`}});continue}ie.value!==Se&&e.report({node:ie,messageId:"default",data:{message:`Argument should have the value "${Se}"${J?`: ${N(J)}`:""}`},fix:Ae=>Ae.replaceText(ie,typeof Se=="string"?`'${Se}'`:String(Se))})}break}}})}for(let{selector:W,message:J}of k??[])f.set(W,N(J)),p.set(N(W),()=>{f.delete(W)});for(let{name:W,type:J,message:te}of R??[]){let Z=N(W),be=N(te);y.add(`${Z}:${J}:${be}`)}}for(let{fn:m,withArgs:S,message:k,replaceWith:R,ignoreRegex:C}of i??[])C&&new RegExp(C).test(s)||l.push(N=>{let{callee:W}=N;if(W.type!==re.Identifier||!A(W.name,m))return;if(S)for(let te of S){let Z=N.arguments[te.atIndex];if(!Z){e.report({node:N,messageId:"default",data:{message:`Missing argument with value "${te.value}" at index ${te.atIndex}: ${k}`}});return}if(Z.type!==re.Literal||Z.value!==te.value)return}let J=te=>R?te.replaceText(N,R):null;e.report({node:N,messageId:"default",data:{message:k},suggest:R?[{messageId:"default",data:{message:`Replace with "${R}"`},fix:J}]:void 0})});function b(m,S){let k=r[m];k?r[m]=R=>{k(R),S(R)}:r[m]=S}for(let{selector:m,message:S,replace:k,replaceType:R="suggestion"}of o??[]){if(m==="CallExpression"){l.push(C=>{g(k,C,S,R)});continue}r[m]=C=>{g(k,C,S,R)}}if(p.size>0)for(let[m,S]of p)b(m,S);return l.length>0&&(r.CallExpression=m=>{if(m.type===re.CallExpression)for(let S of l)S(m)}),r.ImportDeclaration=m=>{m.type===re.ImportDeclaration&&I(m)},r.ExportNamedDeclaration=m=>{m.type===re.ExportNamedDeclaration&&x(m)},r.VariableDeclarator=m=>{m.type===re.VariableDeclarator&&E(m)},r["Program:exit"]=m=>{for(let S of c)e.report({node:m,messageId:"default",data:{message:S}});for(let[,S]of f)e.report({node:m,messageId:"default",data:{message:S}});for(let S of y){let[k,R,C]=S.split(":");e.report({node:m,messageId:"default",data:{message:`Missing required export "${k}" of type ${R}: ${C}`}})}},r;function g(m,S,k,R){let C=N=>{if(!m)return null;if(typeof m=="string")return N.replaceText(S,m);{let W=new RegExp(m.regex),J=e.sourceCode.getText(S);return N.replaceText(S,J.replace(W,m.with))}};e.report({node:S,messageId:"default",data:{message:k},fix:m&&R==="autofix"?C:void 0,suggest:m&&R==="suggestion"?[{messageId:"default",data:{message:`Replace with "${typeof m=="string"?m:m.with}"`},fix:C}]:void 0})}}});function or(e,t){let r=[],n=t.exec(e);if(!n)return null;let[a,...o]=n;r.push({name:"$0_lowercase",value:a.toLowerCase()}),r.push({name:"$0_capitalize",value:zt(a)}),r.push({name:"$0_uncapitalize",value:Ht(a)}),r.push({name:"$0",value:a});for(let i=0;i<o.length;i++){let s=`$${i+1}`,l=o[i];r.push({name:`${s}_lowercase`,value:l.toLowerCase()}),r.push({name:`${s}_capitalize`,value:zt(l)}),r.push({name:`${s}_uncapitalize`,value:Ht(l)}),r.push({name:s,value:l})}return r}function zt(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Ht(e){return e.charAt(0).toLowerCase()+e.slice(1)}import{AST_NODE_TYPES as $,AST_TOKEN_TYPES as Yt,ESLintUtils as ar}from"@typescript-eslint/utils";var lr=ar.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Jt="collapse-simple-objs-in-one-line",pr=z({maxLineLength:_(ge()),maxProperties:_(ge()),nestedObjMaxLineLength:_(ge()),nestedObjMaxProperties:_(ge()),ignoreTypesWithSuffix:_(Q(V()))}),cr=lr({name:Jt,meta:{type:"suggestion",fixable:"code",docs:{description:"Format simple objects and types in one line"},messages:{singleLineProp:"Object/type should be written in a single line"},schema:[pr]},defaultOptions:[{}],create(e,[t]){let r=e.sourceCode,n=t.ignoreTypesWithSuffix??[],a=t.maxProperties??2,o=t.nestedObjMaxLineLength??t.maxLineLength,i=t.nestedObjMaxProperties??3;function s(p){if(p.type===$.ObjectExpression){let c=p.parent.type===$.Property,f=c?i:a,y=p.properties.length;if(y>f)return!1;if(y===1){let I=p.properties[0];return I.type===$.Property&&I.value.type===$.ObjectExpression||I.type===$.Property&&I.value.type===$.ArrayExpression&&!I.value.elements.every(E=>E&&Ke(E))?!1:{text:r.getText(I),isNested:c,propsSize:y}}let T=[];for(let I of p.properties){if(I.type===$.Property&&!Ke(I.value))return!1;T.push(r.getText(I))}return{text:T.join(", "),isNested:c,propsSize:y}}else{let c=p.parent.parent?.type===$.TSPropertySignature,f=c?i:a,y=p.members.length;if(y>f)return!1;if(n.length>0&&p.parent.type===$.TSTypeAliasDeclaration){let I=p.parent.id.name;if(n.some(x=>I.endsWith(x)))return!1}if(y===1){let I=p.members[0];return I.type===$.TSPropertySignature&&I.typeAnnotation?.typeAnnotation.type===$.TSTypeLiteral?!1:{text:r.getText(I),isNested:c,propsSize:1}}if(p.parent.type===$.TSIntersectionType||p.parent.type===$.TSUnionType&&p.parent.types[0]!==p)return!1;let T=[];for(let I of p.members){if(I.type!==$.TSPropertySignature)return!1;let x=I.typeAnnotation?.typeAnnotation;if(!x||x.type===$.TSTypeLiteral||!qt(x))return!1;if(x.type===$.TSTypeReference&&x.typeArguments){if(x.typeArguments.params.length>1)return!1;let u=x.typeArguments.params[0];if(!qt(u))return!1}let E=r.getText(I).trim();(E.endsWith(";")||E.endsWith(","))&&(E=E.slice(0,-1)),T.push(E)}return{text:T.join("; "),isNested:c,propsSize:y}}}function l(p){if(p.loc.start.line===p.loc.end.line)return;if(p.parent.type!==$.JSXExpressionContainer){let x=0,E=!1,u=r.getTokenAfter(p,{filter:b=>b.type!==Yt.Punctuator||E?!0:b.value===","?(x++,!1):b.value===";"?(x++,E=!0,!1):b.value===")"||b.value==="}"?(x++,!1):!0});if(x>4)return;let A=u?.type===Yt.Template&&u.value.startsWith(`}
|
|
2
2
|
`);if(u?.loc.start.line===p.loc.end.line&&!A)return}let c=s(p);if(!c)return;let f=c.text;if(f.includes(`
|
|
3
|
-
`)||r.getCommentsInside(p).length>0)return;f.endsWith(";")&&(f=f.slice(0,-1));let y=`{ ${f} }`,T=fr(r,p),I=c.isNested&&c.propsSize>2?o:t.maxLineLength;I&&y.length+T.length+ur(p,r)>I||e.report({node:p,messageId:"singleLineProp",fix:
|
|
4
|
-
`,r.range[1]);return(n!==-1?n:t.text.length)-r.range[1]}function fr(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}var Ze={name:Jt,rule:cr};var mr=/eslint +react-compiler\/react-compiler: +\["error/,Xt={meta:{type:"suggestion",docs:{description:"verifies the list of dependencies for Hooks like useEffect and similar",recommended:!0,url:"https://github.com/facebook/react/issues/14920"},fixable:"code",hasSuggestions:!0,schema:[{type:"object",additionalProperties:!1,ignoreIfReactCompilerIsEnabled:!1,enableDangerousAutofixThisMayCauseInfiniteLoops:!1,properties:{additionalHooks:{type:"string"},ignoreIfReactCompilerIsEnabled:{type:"boolean"},enableDangerousAutofixThisMayCauseInfiniteLoops:{type:"boolean"}}}]},create(e){let t=!1,r=typeof e.getSource=="function"?u=>r(u):u=>e.sourceCode.getText(u),n=typeof e.getScope=="function"?()=>n():u=>e.sourceCode.getScope(u),a=e.options&&e.options[0]&&e.options[0].additionalHooks?new RegExp(e.options[0].additionalHooks):void 0,o=e.options&&e.options[0]&&e.options[0].enableDangerousAutofixThisMayCauseInfiniteLoops||!1,i={additionalHooks:a,enableDangerousAutofixThisMayCauseInfiniteLoops:o};function s(u){o&&Array.isArray(u.suggest)&&u.suggest.length>0&&(u.fix=u.suggest[0].fix),e.report(u)}let l=e.getSourceCode().scopeManager,p=new WeakMap,c=new WeakSet,f=new WeakMap,y=new WeakMap,T=new WeakSet;function I(u,A){return function(
|
|
3
|
+
`)||r.getCommentsInside(p).length>0)return;f.endsWith(";")&&(f=f.slice(0,-1));let y=`{ ${f} }`,T=fr(r,p),I=c.isNested&&c.propsSize>2?o:t.maxLineLength;I&&y.length+T.length+ur(p,r)>I||e.report({node:p,messageId:"singleLineProp",fix:x=>x.replaceText(p,y)})}return{TSTypeLiteral:l,ObjectExpression:l}}});function qt(e){return e.type===$.TSLiteralType||e.type===$.TSTypeReference||e.type===$.TSNumberKeyword||e.type===$.TSStringKeyword||e.type===$.TSBooleanKeyword||e.type===$.TSNullKeyword||e.type===$.TSUndefinedKeyword}function Ke(e,t){return!!(e.type===$.Literal||e.type===$.Identifier||e.type===$.TemplateLiteral||e.type===$.TaggedTemplateExpression||!t&&e.type===$.ArrayExpression&&e.elements.every(r=>r&&Ke(r,!0)))}function ur(e,t){let r=t.getLastToken(e);if(!r)return 0;let n=t.text.indexOf(`
|
|
4
|
+
`,r.range[1]);return(n!==-1?n:t.text.length)-r.range[1]}function fr(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}var Ze={name:Jt,rule:cr};var mr=/eslint +react-compiler\/react-compiler: +\["error/,Xt={meta:{type:"suggestion",docs:{description:"verifies the list of dependencies for Hooks like useEffect and similar",recommended:!0,url:"https://github.com/facebook/react/issues/14920"},fixable:"code",hasSuggestions:!0,schema:[{type:"object",additionalProperties:!1,ignoreIfReactCompilerIsEnabled:!1,enableDangerousAutofixThisMayCauseInfiniteLoops:!1,properties:{additionalHooks:{type:"string"},ignoreIfReactCompilerIsEnabled:{type:"boolean"},enableDangerousAutofixThisMayCauseInfiniteLoops:{type:"boolean"}}}]},create(e){let t=!1,r=typeof e.getSource=="function"?u=>r(u):u=>e.sourceCode.getText(u),n=typeof e.getScope=="function"?()=>n():u=>e.sourceCode.getScope(u),a=e.options&&e.options[0]&&e.options[0].additionalHooks?new RegExp(e.options[0].additionalHooks):void 0,o=e.options&&e.options[0]&&e.options[0].enableDangerousAutofixThisMayCauseInfiniteLoops||!1,i={additionalHooks:a,enableDangerousAutofixThisMayCauseInfiniteLoops:o};function s(u){o&&Array.isArray(u.suggest)&&u.suggest.length>0&&(u.fix=u.suggest[0].fix),e.report(u)}let l=e.getSourceCode().scopeManager,p=new WeakMap,c=new WeakSet,f=new WeakMap,y=new WeakMap,T=new WeakSet;function I(u,A){return function(b){if(A.has(b))return A.get(b);let g=u(b);return A.set(b,g),g}}function x(u,A,b,g,m){m&&u.async&&s({node:u,message:`Effect callbacks are synchronous to prevent race conditions. Put the async function inside:
|
|
5
5
|
|
|
6
6
|
useEffect(() => {
|
|
7
7
|
async function fetchData() {
|
|
@@ -12,7 +12,10 @@ useEffect(() => {
|
|
|
12
12
|
fetchData();
|
|
13
13
|
}, [someId]); // Or [] if effect doesn't need props or state
|
|
14
14
|
|
|
15
|
-
Learn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching`});let S=l.acquire(u),k=new Set,R=null;{let d=S.upper;for(;d&&(k.add(d),d.type!=="function");)d=d.upper;if(!d)return;R=d}let C=Array.isArray;function N(d){if(!C(d.defs))return!1;let h=d.defs[0];if(h==null||h.node.type!=="VariableDeclarator")return!1;let v=h.node.init;if(v==null)return!1;for(;v.type==="TSAsExpression";)v=v.expression;let O=h.node.parent;if(O==null&&(tt(R.block,h.node.id),O=h.node.parent,O==null))return!1;if(O.kind==="const"&&v.type==="Literal"&&(typeof v.value=="string"||typeof v.value=="number"||v.value===null))return!0;if(v.type!=="CallExpression")return!1;let F=v.callee;if(F.type==="MemberExpression"&&F.object.name==="React"&&F.property!=null&&!F.computed&&(F=F.property),F.type!=="Identifier")return!1;let P=h.node.id,{name:M}=F;if(M==="useRef"&&P.type==="Identifier")return!0;if(Tr(F)&&P.type==="Identifier"){for(let D of d.references)D!==P&&T.add(D.identifier);return!0}else if(M==="useState"||M==="useReducer"){if(P.type==="ArrayPattern"&&P.elements.length===2&&C(d.identifiers)){if(P.elements[1]===d.identifiers[0]){if(M==="useState"){let D=d.references,ae=0;for(let Se=0;Se<D.length;Se++){if(D[Se].isWrite()&&ae++,ae>1)return!1;p.set(D[Se].identifier,P.elements[0])}}return!0}else if(P.elements[0]===d.identifiers[0]){if(M==="useState"){let D=d.references;for(let ae=0;ae<D.length;ae++)c.add(D[ae].identifier)}return!1}}}else if(M==="useTransition"&&P.type==="ArrayPattern"&&P.elements.length===2&&Array.isArray(d.identifiers)&&P.elements[1]===d.identifiers[0])return!0;return!1}function W(d){if(!C(d.defs))return!1;let h=d.defs[0];if(h==null||h.node==null||h.node.id==null)return!1;let v=h.node,O=R.childScopes,F=null,P;for(P=0;P<O.length;P++){let M=O[P],D=M.block;if(v.type==="FunctionDeclaration"&&D===v||v.type==="VariableDeclarator"&&D.parent===v){F=M;break}}if(F==null)return!1;for(P=0;P<F.through.length;P++){let M=F.through[P];if(M.resolved!=null&&k.has(M.resolved.scope)&&!J(M.resolved))return!1}return!0}let J=I(N,f),G=I(W,y),Z=new Map;function Ee(d){let h=d.from,v=!1;for(;h.block!==u;)h.type==="function"&&(v=h.block.parent!=null&&h.block.parent.type==="ReturnStatement"),h=h.upper;return v}let Q=new Map,Oe=new Map;ye(S);function ye(d){for(let h of d.references){if(!h.resolved||!k.has(h.resolved.scope))continue;let v=tt(u,h.identifier),O=Gt(v),F=Te(O,Oe);if(m&&O.type==="Identifier"&&(O.parent.type==="MemberExpression"||O.parent.type==="OptionalMemberExpression")&&!O.parent.computed&&O.parent.property.type==="Identifier"&&O.parent.property.name==="current"&&Ee(h)&&Z.set(F,{reference:h,dependencyNode:O}),O.parent.type==="TSTypeQuery"||O.parent.type==="TSTypeReference")continue;let P=h.resolved.defs[0];if(P!=null&&!(P.node!=null&&P.node.init===u.parent)&&P.type!=="TypeParameter")if(Q.has(F))Q.get(F).references.push(h);else{let M=h.resolved,D=J(M)||G(M);Q.set(F,{isStable:D,references:[h]})}}for(let h of d.childScopes)ye(h)}Z.forEach(({reference:d,dependencyNode:h},v)=>{let O=d.resolved.references,F=!1;for(let P=0;P<O.length;P++){let{identifier:M}=O[P],{parent:D}=M;if(D!=null&&D.type==="MemberExpression"&&!D.computed&&D.property.type==="Identifier"&&D.property.name==="current"&&D.parent.type==="AssignmentExpression"&&D.parent.left===D){F=!0;break}}F||s({node:h.parent.property,message:`The ref value '${v}.current' will likely have changed by the time this effect cleanup function runs. If this ref points to a node rendered by React, copy '${v}.current' to a variable inside the effect, and use that variable in the cleanup function.`})});let me=new Set;function ge(d,h){me.has(h)||(me.add(h),s({node:d,message:`Assignments to the '${h}' variable from inside React Hook ${r(x)} 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(x)}.`}))}let we=new Set;if(Q.forEach(({isStable:d,references:h},v)=>{d&&we.add(v),h.forEach(O=>{O.writeExpr&&ge(O.writeExpr,v)})}),me.size>0)return;if(!A){let d=null;if(Q.forEach(({isStable:h,references:v},O)=>{d||v.forEach(F=>{if(d)return;let P=F.identifier;if(!p.has(P))return;let D=F.from;for(;D.type!=="function";)D=D.upper;D.block===u&&(d=O)})}),d){let{suggestedDependencies:h}=Qe({dependencies:Q,declaredDependencies:[],stableDependencies:we,externalDependencies:new Set,isEffect:!0});s({node:x,message:`React Hook ${g} contains a call to '${d}'. Without a list of dependencies, this can lead to an infinite chain of updates. To fix this, pass [`+h.join(", ")+`] as a second argument to the ${g} Hook.`,suggest:[{desc:`Add dependencies array: [${h.join(", ")}]`,fix(v){return v.insertTextAfter(u,`, [${h.join(", ")}]`)}}]})}return}let Pe=[],Fe=new Set;A.type!=="ArrayExpression"?s({node:A,message:`React Hook ${r(x)} was passed a dependency list that is not an array literal. This means we can't statically verify whether you've passed the correct dependencies.`}):A.elements.forEach(d=>{if(d===null)return;if(d.type==="SpreadElement"){s({node:d,message:`React Hook ${r(x)} has a spread element in its dependency array. This means we can't statically verify whether you've passed the correct dependencies.`});return}T.has(d)&&s({node:d,message:`Functions returned from \`useEffectEvent\` must not be included in the dependency array. Remove \`${r(d)}\` from the list.`,suggest:[{desc:`Remove the dependency \`${r(d)}\``,fix(F){return F.removeRange(d.range)}}]});let h;try{h=Te(d,Oe)}catch(F){if(/Unsupported node type/.test(F.message)){d.type==="Literal"?Q.has(d.value)?s({node:d,message:`The ${d.raw} literal is not a valid dependency because it never changes. Did you mean to include ${d.value} in the array instead?`}):s({node:d,message:`The ${d.raw} literal is not a valid dependency because it never changes. You can safely remove it.`}):s({node:d,message:`React Hook ${r(x)} has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked.`});return}else throw F}let v=d;for(;v.type==="MemberExpression"||v.type==="OptionalMemberExpression"||v.type==="ChainExpression";)v=v.object||v.expression.object;let O=!R.through.some(F=>F.identifier===v);Pe.push({key:h,node:d}),O||Fe.add(h)});let{suggestedDependencies:Jn,unnecessaryDependencies:je,missingDependencies:be,duplicateDependencies:Dt}=Qe({dependencies:Q,declaredDependencies:Pe,stableDependencies:we,externalDependencies:Fe,isEffect:m}),De=Jn;if(Dt.size+be.size+je.size===0){if(t)return;dr({declaredDependencies:Pe,declaredDependenciesNode:A,componentScope:R,scope:S}).forEach(({construction:h,isUsedOutsideOfHook:v,depType:O})=>{let F=O==="function"?"useCallback":"useMemo",P=O==="function"?"definition":"initialization",M=`wrap the ${P} of '${h.name.name}' in its own ${F}() Hook.`,D=v?`To fix this, ${M}`:`Move it inside the ${g} callback. Alternatively, ${M}`,ae=O==="conditional"||O==="logical expression"?"could make":"makes",Se=`The '${h.name.name}' ${O} ${ae} the dependencies of ${g} Hook (at line ${A.loc.start.line}) change on every render. ${D}`,Lt;v&&h.type==="Variable"&&O==="function"&&(Lt=[{desc:`Wrap the ${P} of '${h.name.name}' in its own ${F}() Hook.`,fix(_t){let[Xn,Gn]=F==="useMemo"?["useMemo(() => { return ","; })"]:["useCallback(",")"];return[_t.insertTextBefore(h.node.init,Xn),_t.insertTextAfter(h.node.init,Gn)]}}]),s({node:h.node,message:Se,suggest:Lt})});return}!m&&be.size>0&&(De=Qe({dependencies:Q,declaredDependencies:[],stableDependencies:we,externalDependencies:Fe,isEffect:m}).suggestedDependencies);function Bn(){if(Pe.length===0)return!0;let d=Pe.map(v=>v.key),h=d.slice().sort();return d.join(",")===h.join(",")}Bn()&&De.sort();function qe(d){let h=d.split("."),v="";for(let O=0;O<h.length;O++){if(O!==0){let F=h.slice(0,O+1).join("."),P=Oe.get(F)===!0;v+=P?"?.":"."}v+=h[O]}return v}function Je(d,h,v,O){return d.size===0?null:(d.size>1?"":h+" ")+v+" "+(d.size>1?"dependencies":"dependency")+": "+gr(Array.from(d).sort().map(F=>"'"+qe(F)+"'"))+`. Either ${O} ${d.size>1?"them":"it"} or remove the dependency array.`}let ce="";if(je.size>0){let d=null;if(Array.from(je.keys()).forEach(h=>{d===null&&h.endsWith(".current")&&(d=h)}),d!==null)ce=` Mutable values like '${d}' aren't valid dependencies because mutating them doesn't re-render the component.`;else if(Fe.size>0){let h=Array.from(Fe)[0];S.set.has(h)||(ce=` Outer scope values like '${h}' aren't valid dependencies because mutating them doesn't re-render the component.`)}}if(!ce&&be.has("props")){let d=Q.get("props");if(d==null)return;let h=d.references;if(!Array.isArray(h))return;let v=!0;for(let O=0;O<h.length;O++){let F=h[O],P=tt(R.block,F.identifier);if(!P){v=!1;break}let M=P.parent;if(M==null){v=!1;break}if(M.type!=="MemberExpression"&&M.type!=="OptionalMemberExpression"){v=!1;break}}v&&(ce=` However, 'props' will change when *any* prop changes, so the preferred fix is to destructure the 'props' object outside of the ${g} call and refer to those specific props inside ${r(x)}.`)}if(!ce&&be.size>0){let d=null;be.forEach(h=>{if(d)return;let v=R.set.get(h),O=Q.get(h);if(O.references[0].resolved!==v)return;let F=v.defs[0];if(F==null||F.name==null||F.type!=="Parameter")return;let P=!1,M;for(let D=0;D<O.references.length;D++)if(M=O.references[D].identifier,M!=null&&M.parent!=null&&(M.parent.type==="CallExpression"||M.parent.type==="OptionalCallExpression")&&M.parent.callee===M){P=!0;break}P&&(d=h)}),d!==null&&(ce=` If '${d}' changes too often, find the parent component that defines it and wrap that definition in useCallback.`)}if(!ce&&be.size>0){let d=null;if(be.forEach(h=>{if(d!==null)return;let O=Q.get(h).references,F,P;for(let M=0;M<O.length;M++){for(F=O[M].identifier,P=F.parent;P!=null&&P!==R.block;){if(P.type==="CallExpression"){let D=p.get(P.callee);if(D!=null){if(D.name===h)d={missingDep:h,setter:P.callee.name,form:"updater"};else if(c.has(F))d={missingDep:h,setter:P.callee.name,form:"reducer"};else{let ae=O[M].resolved;if(ae!=null){let Se=ae.defs[0];Se!=null&&Se.type==="Parameter"&&(d={missingDep:h,setter:P.callee.name,form:"inlineReducer"})}}break}}P=P.parent}if(d!==null)break}}),d!==null)switch(d.form){case"reducer":ce=` You can also replace multiple useState variables with useReducer if '${d.setter}' needs the current value of '${d.missingDep}'.`;break;case"inlineReducer":ce=` If '${d.setter}' needs the current value of '${d.missingDep}', you can also switch to useReducer instead of useState and read '${d.missingDep}' in the reducer.`;break;case"updater":ce=` You can also do a functional update '${d.setter}(${d.missingDep.slice(0,1)} => ...)' if you only need '${d.missingDep}' in the '${d.setter}' call.`;break;default:throw new Error("Unknown case.")}}s({node:A,message:`React Hook ${r(x)} has `+(Je(be,"a","missing","include")||Je(je,"an","unnecessary","exclude")||Je(Dt,"a","duplicate","omit"))+ce,suggest:[{desc:`Update the dependencies array to be: [${De.map(qe).join(", ")}]`,fix(d){return d.replaceText(A,`[${De.map(qe).join(", ")}]`)}}]})}function E(u){let A=yr(u.callee,i);if(A===-1)return;let x=u.arguments[A],g=u.callee,m=Kt(g).name,S=u.arguments[A+1],k=/Effect($|[^a-z])/g.test(m);if(!x){s({node:g,message:`React Hook ${m} requires an effect callback. Did you forget to pass a callback to the hook?`});return}if(!(t&&!k)){if(!S&&!k){(m==="useMemo"||m==="useCallback")&&s({node:g,message:`React Hook ${m} does nothing when called with only one argument. Did you forget to pass an array of dependencies?`});return}switch(x.type){case"FunctionExpression":case"ArrowFunctionExpression":b(x,S,g,m,k);return;case"Identifier":if(!S||S.elements&&S.elements.some(N=>N&&N.type==="Identifier"&&N.name===x.name))return;let R=n(u).set.get(x.name);if(R==null||R.defs==null)return;let C=R.defs[0];if(!C||!C.node||C.type!=="Variable"&&C.type!=="FunctionName")break;switch(C.node.type){case"FunctionDeclaration":b(C.node,S,g,m,k);return;case"VariableDeclarator":let N=C.node.init;if(!N)break;switch(N.type){case"ArrowFunctionExpression":case"FunctionExpression":b(N,S,g,m,k);return}break}break;default:s({node:g,message:`React Hook ${m} received a function whose dependencies are unknown. Pass an inline function instead.`});return}s({node:g,message:`React Hook ${m} has a missing dependency: '${x.name}'. Either include it or remove the dependency array.`,suggest:[{desc:`Update the dependencies array to be: [${x.name}]`,fix(R){return R.replaceText(S,`[${x.name}]`)}}]})}}if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let u of e.sourceCode.getAllComments())if(mr.test(u.value))return t=!0,{CallExpression:A=>E(A,!0)}}return{CallExpression:u=>E(u)}}};function Qe({dependencies:e,declaredDependencies:t,stableDependencies:r,externalDependencies:n,isEffect:a}){let o=i();function i(){return{isUsed:!1,isSatisfiedRecursively:!1,isSubtreeUsed:!1,children:new Map}}e.forEach((b,E)=>{let u=s(o,E);u.isUsed=!0,l(o,E,A=>{A.isSubtreeUsed=!0})}),t.forEach(({key:b})=>{let E=s(o,b);E.isSatisfiedRecursively=!0}),r.forEach(b=>{let E=s(o,b);E.isSatisfiedRecursively=!0});function s(b,E){let u=E.split("."),A=b;for(let x of u){let g=A.children.get(x);g||(g=i(),A.children.set(x,g)),A=g}return A}function l(b,E,u){let A=E.split("."),x=b;for(let g of A){let m=x.children.get(g);if(!m)return;u(m),x=m}}let p=new Set,c=new Set;f(o,p,c,b=>b);function f(b,E,u,A){b.children.forEach((x,g)=>{let m=A(g);if(x.isSatisfiedRecursively){x.isSubtreeUsed&&u.add(m);return}if(x.isUsed){E.add(m);return}f(x,E,u,S=>m+"."+S)})}let y=[],T=new Set,I=new Set;return t.forEach(({key:b})=>{c.has(b)?y.indexOf(b)===-1?y.push(b):I.add(b):T.add(b)}),p.forEach(b=>{y.push(b)}),{suggestedDependencies:y,unnecessaryDependencies:T,duplicateDependencies:I,missingDependencies:p}}function Ie(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 Ie(e.consequent)!=null||Ie(e.alternate)!=null?"conditional":null;case"LogicalExpression":return Ie(e.left)!=null||Ie(e.right)!=null?"logical expression":null;case"JSXFragment":return"JSX fragment";case"JSXElement":return"JSX element";case"AssignmentExpression":return Ie(e.right)!=null?"assignment expression":null;case"NewExpression":return"object construction";case"Literal":return e.value instanceof RegExp?"regular expression":null;case"TypeCastExpression":return Ie(e.expression);case"TSAsExpression":return Ie(e.expression)}return null}function dr({declaredDependencies:e,declaredDependenciesNode:t,componentScope:r,scope:n}){let a=e.map(({key:i})=>{let s=r.variables.find(p=>p.name===i);if(s==null)return null;let l=s.defs[0];if(l==null)return null;if(l.type==="Variable"&&l.node.type==="VariableDeclarator"&&l.node.id.type==="Identifier"&&l.node.init!=null){let p=Ie(l.node.init);if(p!=null)return[s,p]}return l.type==="FunctionName"&&l.node.type==="FunctionDeclaration"?[s,"function"]:l.type==="ClassName"&&l.node.type==="ClassDeclaration"?[s,"class"]:null}).filter(Boolean);function o(i){let s=!1;for(let l=0;l<i.references.length;l++){let p=i.references[l];if(p.writeExpr){if(s)return!0;s=!0;continue}let c=p.from;for(;c!==n&&c!=null;)c=c.upper;if(c!==n&&!Zt(t,p.identifier))return!0}return!1}return a.map(([i,s])=>({construction:i.defs[0],depType:s,isUsedOutsideOfHook:o(i)}))}function Gt(e){return(e.parent.type==="MemberExpression"||e.parent.type==="OptionalMemberExpression")&&e.parent.object===e&&e.parent.property.name!=="current"&&!e.parent.computed&&!(e.parent.parent!=null&&(e.parent.parent.type==="CallExpression"||e.parent.parent.type==="OptionalCallExpression")&&e.parent.parent.callee===e.parent)?Gt(e.parent):e.type==="MemberExpression"&&e.parent&&e.parent.type==="AssignmentExpression"&&e.parent.left===e?e.object:e}function et(e,t,r){t&&(e.optional?t.has(r)||t.set(r,!0):t.has(r)||t.set(r,!1))}function Te(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=Te(e.object,t),n=Te(e.property,null),a=`${r}.${n}`;return et(e,t,a),a}else if(e.type==="OptionalMemberExpression"&&!e.computed){let r=Te(e.object,t),n=Te(e.property,null),a=`${r}.${n}`;return et(e,t,a),a}else if(e.type==="ChainExpression"&&!e.computed){let r=e.expression;if(r.type==="CallExpression")throw new Error(`Unsupported node type: ${r.type}`);let n=Te(r.object,t),a=Te(r.property,null),o=`${n}.${a}`;return et(r,t,o),o}else throw new Error(`Unsupported node type: ${e.type}`)}function Kt(e,t){return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.object.name==="React"&&e.property.type==="Identifier"&&!e.computed?e.property:e}function yr(e,t){let r=Kt(e);if(r.type!=="Identifier")return-1;switch(r.name){case"useEffect":case"useLayoutEffect":case"useCallback":case"useMemo":return 0;case"useImperativeHandle":return 1;default:if(r===e&&t&&t.additionalHooks){let n;try{n=Te(r,null)}catch(a){if(/Unsupported node type/.test(a.message))return 0;throw a}return t.additionalHooks.test(n)?0:-1}else return-1}}function tt(e,t){let r=[e],n=null;for(;r.length;){if(n=r.shift(),Sr(n,t))return n;if(Zt(n,t))for(let[a,o]of Object.entries(n))a!=="parent"&&(Bt(o)?(o.parent=n,r.push(o)):Array.isArray(o)&&o.forEach(i=>{Bt(i)&&(i.parent=n,r.push(i))}))}return null}function gr(e){let t="";for(let r=0;r<e.length;r++)t+=e[r],r===0&&e.length===2?t+=" and ":r===e.length-2&&e.length>2?t+=", and ":r<e.length-1&&(t+=", ");return t}function Bt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function Sr(e,t){return(e.type==="Identifier"||e.type==="JSXIdentifier")&&e.type===t.type&&e.name===t.name&&e.range[0]===t.range[0]&&e.range[1]===t.range[1]}function Zt(e,t){return e.range[0]<=t.range[0]&&e.range[1]>=t.range[1]}function Tr(e){return!1}import{AST_NODE_TYPES as _e,ESLintUtils as en}from"@typescript-eslint/utils";import ie from"typescript";var hr=en.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Qt="improved-no-unnecessary-condition",Er=z({}),br=["string","number","bigint","boolean","symbol","undefined","object","function","never"],xr=new Set(br),nt={name:Qt,rule:hr({name:Qt,meta:{type:"suggestion",docs:{description:"Extends checks of `no-unnecessary-condition` rule"},messages:{unnecessaryTypeofCondition:'This condition is unnecessary. The type of "{{name}}" is always "{{type}}".',alwaysFalseTypeofCondition:'This condition will always be false. The type of "{{name}}" is "{{actualType}}" so the condition has no overlap with "{{conditionType}}".'},schema:[Er]},defaultOptions:[{}],create(e){let t=en.getParserServices(e,!0),r=t.program?.getTypeChecker();if(!r||!t.program)throw new Error("TypeScript services or program not available");function n(s){return s.type===_e.UnaryExpression&&s.operator==="typeof"}function a(s){return s.flags&ie.TypeFlags.Any||s.flags&ie.TypeFlags.Unknown?null:s.flags&ie.TypeFlags.StringLike?["string"]:s.flags&ie.TypeFlags.NumberLike?["number"]:s.flags&ie.TypeFlags.BigIntLike?["bigint"]:s.flags&ie.TypeFlags.BooleanLike?["boolean"]:s.flags&ie.TypeFlags.ESSymbolLike?["symbol"]:s.flags&ie.TypeFlags.Undefined||s.flags&ie.TypeFlags.Void?["undefined"]:s.flags&ie.TypeFlags.Null?["object"]:s.getCallSignatures().length>0?["function"]:s.flags&ie.TypeFlags.Object?s.getProperties().length===0?["string","number","bigint","boolean","symbol","object","function"]:["object"]:s.flags&ie.TypeFlags.NonPrimitive?["object"]:s.flags&ie.TypeFlags.Never?["never"]:null}function o(s){if(!r)return null;let l=t.esTreeNodeToTSNodeMap.get(s),p=r.getTypeAtLocation(l.expression);if(p.flags&ie.TypeFlags.Any||p.flags&ie.TypeFlags.Unknown)return null;let c=[];if(p.isUnion()){for(let y of p.types){let T=a(y);if(T)c.push(...T);else return null}return c}let f=a(p);return f?(c.push(...f),c):null}function i(s){if(!(s.operator==="==="||s.operator==="!=="))return;let p=null,c=null;if(n(s.left)?(p=s.left,c=s.right.type===_e.Literal&&typeof s.right.value=="string"?s.right.value:null):n(s.right)&&(p=s.right,c=s.left.type===_e.Literal&&typeof s.left.value=="string"?s.left.value:null),!p||!c||!Ir(c,xr))return;let f=o(p);if(!f)return;let y=s.operator==="!==",T=f.includes(c);f.length===1?T&&!y?e.report({node:s,messageId:"unnecessaryTypeofCondition",data:{name:Re(p,e),type:c}}):!T&&y?e.report({node:s,messageId:"unnecessaryTypeofCondition",data:{name:Re(p,e),type:Array.from(f)[0]}}):!T&&!y?e.report({node:s,messageId:"alwaysFalseTypeofCondition",data:{name:Re(p,e),actualType:Le(f),conditionType:c}}):T&&y&&e.report({node:s,messageId:"alwaysFalseTypeofCondition",data:{name:Re(p,e),actualType:Le(f),conditionType:c}}):!T&&!y?e.report({node:s,messageId:"alwaysFalseTypeofCondition",data:{name:Re(p,e),actualType:Le(f),conditionType:c}}):!T&&y&&e.report({node:s,messageId:"unnecessaryTypeofCondition",data:{name:Re(p,e),type:Le(f)}})}return{BinaryExpression:i}}})};function Le(e){return Array.from(new Set(e)).join(" | ")||"never"}function Re(e,t){let r=e.argument;return r.type===_e.Identifier?r.name:t.sourceCode.getText(r)}function Ir(e,t){return t.has(e)}import{AST_NODE_TYPES as Cr,ESLintUtils as wr}from"@typescript-eslint/utils";var Ar=wr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),tn="no-call-with-explicit-generics",Rr=z({functions:ee(V())}),vr=Ar({name:tn,meta:{type:"problem",docs:{description:"Enforce calling configured functions with inferred generics only"},messages:{noExplicitGenerics:"Function '{{ functionName }}' should be called with inferred generics (remove the explicit type parameters)"},schema:[Rr]},defaultOptions:[{functions:[]}],create(e,[t]){let r=new Set(t.functions);return{CallExpression(n){let{callee:a}=n;a.type===Cr.Identifier&&r.has(a.name)&&n.typeArguments&&e.report({node:n,messageId:"noExplicitGenerics",data:{functionName:a.name}})}}}}),rt={name:tn,rule:vr};import{AST_NODE_TYPES as $e,ESLintUtils as kr}from"@typescript-eslint/utils";var Or=kr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),nn="no-call-with-inferred-generics",Pr=Or({name:nn,meta:{type:"problem",docs:{description:"Disable calling configured functions with infered generics"},messages:{missingGenericDeclaration:"Function '{{ functionName }}' should be called with at least {{ minGenerics }} generic(s) (ex: `fn<Generic>()`) defined",anyUsedInGenerics:"Function '{{ functionName }}' should not be called with 'any' in generics"},schema:[{type:"object",properties:{functions:{type:"array",items:{type:"object",properties:{name:{type:"string"},minGenerics:{type:"number"},allowAny:{type:"boolean"},disallowTypes:{type:"array",items:{type:"string"}}},required:["name"]}},anyAliases:{type:"array",items:{type:"string"}}},required:["functions"]}]},defaultOptions:[{functions:[]}],create(e,[t]){let r=new Map(t.functions.map(n=>[n.name,n]));return{CallExpression(n){let{callee:a}=n;if(a.type!==$e.Identifier)return;let o=r.get(a.name);if(!o)return;let{minGenerics:i=1,allowAny:s,disallowTypes:l=t.disallowTypes}=o;(n.typeArguments?.params.length||0)<(i||0)&&e.report({node:n,messageId:"missingGenericDeclaration",data:{functionName:a.name,minGenerics:i||0}}),!(s&&!l)&&n.typeArguments?.params?.some(c=>!s&&c.type===$e.TSAnyKeyword||l&&c.type===$e.TSTypeReference&&c.typeName.type===$e.Identifier&&l.includes(c.typeName.name))&&e.report({node:n,messageId:"anyUsedInGenerics",data:{functionName:a.name}})}}}}),it={name:nn,rule:Pr};import{ESLintUtils as Fr}from"@typescript-eslint/utils";var Nr=Fr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),sn="no-commented-out-code",Mr=["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]*$/},jr=[") {","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],Dr=["/>","</",B.jsxSelfClosing,B.jsxElement,B.jsxOpeningTag,B.jsxClosingTag,B.htmlOpeningTag,B.htmlClosingTag],rn=["INFO:","TODO:","DOCS:","FIX:","FIXME:","HACK:","NOTE:","WARNING:","WARN:","BUG:","ISSUE:","TEMP:","TEMPORARY:","XXX:","REVIEW:","eslint"],Lr=Nr({name:sn,meta:{type:"problem",docs:{description:"Disallow commented code"},messages:{commentedOutCode:"Commented code is not allowed. Detected pattern: `{{ wrongPattern }}` Use a comment starting with one of these prefixes if you want to keep this code commented out: {{ allowedPrefixes }}"},schema:[]},defaultOptions:[],create(e){function t(n,a){if(n.startsWith("/"))return!1;let o=n.trimStart();if(n.startsWith("*")||o.startsWith("eslint-disable")||n.includes("@deprecated")||n.includes("@example")||n.includes("@param")||n.includes("@returns")||n.includes("@throws")||n.includes("typescript-eslint")||n.includes("@ts-")||n.includes("prettier-ignore")||B.jsdocComment.test(n))return!1;for(let i of rn)if(o.startsWith(i))return!1;if(n.includes("https://")||o.includes(":")&&B.colonDescriptiveComment.test(o.trim()))return!1;if(a==="Block"){for(let i of Dr)if(typeof i=="string"){if(n.includes(i))return{wrongPattern:i}}else if(i.test(n))return{wrongPattern:`regex(${i.toString()})`};return!1}for(let i of Mr)if(o.startsWith(i))return{wrongPattern:i};for(let i of jr)if(typeof i=="string"){if(n.includes(i))return{wrongPattern:i}}else if(i.test(n))return{wrongPattern:`regex(${i.toString()})`};return!1}function r(n,a){let o=n,i=o.trim();if(i.startsWith("`")&&(i.endsWith("`,")||i.endsWith("`;")||i.endsWith("`")))return o;if(a==="Block"&&o.includes("```")){let p=o.split(/```[\s\S]*?```/g);p.some(f=>/[a-zA-Z0-9]/.test(f))&&(o=p.join(""))}if(!o.includes("`"))return o;let s=o.split(/`[^`]*`/g);return s.some(p=>/[a-zA-Z0-9]/.test(p))?s.join(""):o}return{Program(){let a=e.sourceCode.getAllComments();for(let o of a){let i=r(o.value,o.type),s=t(i,o.type);s&&e.report({node:o,messageId:"commentedOutCode",data:{wrongPattern:s.wrongPattern,allowedPrefixes:rn.join(", ")}})}}}}}),st={name:sn,rule:Lr};import{ESLintUtils as _r,TSESTree as $r}from"@typescript-eslint/utils";var Ur=_r.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),on="no-default-export",Wr=Ur({name:on,meta:{type:"problem",docs:{description:"Disallow default exports"},schema:[],messages:{noDefaultExport:"Default exports are not allowed, use named exports instead."}},defaultOptions:[],create(e){return{ExportDefaultDeclaration(t){e.report({node:t,messageId:"noDefaultExport"})},ExportNamedDeclaration(t){for(let r of t.specifiers)r.exported.type===$r.AST_NODE_TYPES.Identifier&&r.exported.name==="default"&&e.report({node:t,messageId:"noDefaultExport"})}}}}),ot={name:on,rule:Wr};import{ESLintUtils as Vr}from"@typescript-eslint/utils";var zr=Vr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),an="no-leaked-text-in-jsx",Hr=[",",";","[","]","(",")"],Yr=zr({name:an,meta:{type:"problem",docs:{description:"Prevents leaking of text in JSX that should be wrapped in an expression container"},messages:{leakedTextInJSX:'Text "{{ text }}" should be wrapped in a JSX expression container.'},schema:[],fixable:"code"},defaultOptions:[],create(e){return{JSXText(t){let r=t.value.trim();if(!r)return;let n="";Hr.includes(r)?n=r:r.includes("&&")?n="&&":r.includes("||")?n="||":r.endsWith("? (")&&(n="? ("),n&&e.report({node:t,messageId:"leakedTextInJSX",data:{text:n}})}}}}),at={name:an,rule:Yr};import{AST_NODE_TYPES as Ne,ESLintUtils as qr}from"@typescript-eslint/utils";var Jr=qr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),pn="no-non-camel-case-functions",Br=/^(\$?[a-z][a-zA-Z0-9]*)$/;function ln(e){if(e.typeName.type!==Ne.TSQualifiedName)return!1;let{left:t,right:r}=e.typeName;return t.type===Ne.Identifier&&t.name==="JSX"&&r.name==="Element"}var Xr=Jr({name:pn,meta:{type:"suggestion",docs:{description:"Enforce camelCase naming convention for function declarations"},schema:[],messages:{nonCamelCaseFunction:'Function name "{{functionName}}" should be in camelCase format. If this fn is a React component and can\'t use the `FC` type, add a explicit "JSX.Element" return type to it'}},defaultOptions:[],create(e){return{FunctionDeclaration(t){if(t.id&&!Br.test(t.id.name)){let r=t.returnType?.typeAnnotation;if(r&&(r.type===Ne.TSTypeReference?ln(r):r.type===Ne.TSUnionType&&r.types.some(a=>a.type===Ne.TSTypeReference&&ln(a))))return;e.report({node:t.id,messageId:"nonCamelCaseFunction",data:{functionName:t.id.name}})}}}}}),lt={name:pn,rule:Xr};import{ESLintUtils as Gr,TSESTree as H}from"@typescript-eslint/utils";import{AST_NODE_TYPES as cn}from"@typescript-eslint/utils";function ve(e,t,r=1/0){if(r!==0&&e.parent)return e.type===t?e:ve(e.parent,t,r===1/0?r:r-1)}function*pt(e){yield e,e.parent&&(yield*pt(e.parent))}function ct(e,t){for(let r of e){let n=t(r);if(n!=null&&n!==!1)return n}}function un(e,t,r){let a=r.getDeclaredVariables(e).find(o=>o.name===t||o.identifiers[0]?.parent.type===cn.Property&&o.identifiers[0]?.parent.key.type===cn.Identifier&&o.identifiers[0]?.parent.key.name===t);return a?a.references.filter(o=>!o.init):[]}var Kr=Gr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),fn="no-optional-root-props",Zr=Kr({name:fn,meta:{type:"problem",docs:{description:"Prevents usage of optional properties at the root of a type if that type is a local type alias or interface referenced only once"},messages:{optionalNotAllowed:'Optional property "{{ propertyName }}" is not allowed on a local type used only once. Use `prop: undefined | ...` instead.',suggestion:"Use `prop: undefined | ...` instead."},hasSuggestions:!0,schema:[]},defaultOptions:[],create(e){function t(n){let o=e.sourceCode.getDeclaredVariables(n)[0];if(!o||o.references.length!==1)return!1;let i=o.references[0];if(!i)return!1;for(let s of pt(i.identifier)){if("returnType"in s||s.type===H.AST_NODE_TYPES.ExportNamedDeclaration)return!1;let l=s.parent;if(!l)return!1;if(l.type===H.AST_NODE_TYPES.TSTypeParameterInstantiation&&l.parent.type===H.AST_NODE_TYPES.TSTypeReference&&l.parent.typeName.type===H.AST_NODE_TYPES.Identifier&&l.parent.typeName.name==="FC"){let c=ve(l.parent.parent,H.AST_NODE_TYPES.VariableDeclaration,4);if(!c)return!1;let f=Ue(c,e.sourceCode);return f?!(f.parent.type===H.AST_NODE_TYPES.CallExpression&&f.parent.callee.type===H.AST_NODE_TYPES.Identifier&&f.parent.callee.name==="memo"):!1}if(s.type===H.AST_NODE_TYPES.AssignmentPattern)return!1;if(l.type===H.AST_NODE_TYPES.ArrowFunctionExpression){let p=ve(l,H.AST_NODE_TYPES.VariableDeclaration);return p?!!Ue(p,e.sourceCode):!1}if(l.type===H.AST_NODE_TYPES.FunctionDeclaration)return!!Ue(l,e.sourceCode)}return!1}function r(n){n.key.type!==H.AST_NODE_TYPES.Identifier||!n.optional||e.report({node:n.key,messageId:"optionalNotAllowed",data:{propertyName:n.key.name},suggest:[{messageId:"suggestion",fix:a=>{let o=ve(n,H.AST_NODE_TYPES.TSPropertySignature);if(!o)return null;let i=e.sourceCode.getText(o);return a.replaceText(o,i.replace("?:",": undefined |"))}}]})}return{TSTypeAliasDeclaration(n){if(n.typeAnnotation.type===H.AST_NODE_TYPES.TSTypeLiteral&&!(We(n)||!t(n)))for(let a of n.typeAnnotation.members)a.type===H.AST_NODE_TYPES.TSPropertySignature&&r(a)},TSInterfaceDeclaration(n){if(!(We(n)||!t(n)))for(let a of n.body.body)a.type===H.AST_NODE_TYPES.TSPropertySignature&&r(a)},TSTypeReference(n){if(n.typeName.type!==H.AST_NODE_TYPES.Identifier||n.typeName.name!=="FC"||!n.typeArguments?.params[0])return;let a=n.typeArguments.params[0];if(a.type!==H.AST_NODE_TYPES.TSTypeLiteral)return;let o=ve(n.parent,H.AST_NODE_TYPES.VariableDeclaration,4);if(!o)return;let i=Ue(o,e.sourceCode);if(!(!i||i.parent.type===H.AST_NODE_TYPES.CallExpression&&i.parent.callee.type===H.AST_NODE_TYPES.Identifier&&i.parent.callee.name==="memo"))for(let l of a.members)l.type===H.AST_NODE_TYPES.TSPropertySignature&&r(l)}}}});function We(e){return e?e.parent?.type===H.AST_NODE_TYPES.ExportNamedDeclaration||e.parent?.type===H.AST_NODE_TYPES.ExportDefaultDeclaration:!1}function Ue(e,t){if(We(e))return;let r;if(e.type===H.AST_NODE_TYPES.VariableDeclaration){if(e.declarations.length!==1)return;e.declarations[0].id.type===H.AST_NODE_TYPES.Identifier&&(r=e.declarations[0].id)}else{if(!e.id)return;r=e.id}if(!r)return;let n=t.getScope(e);e.type===H.AST_NODE_TYPES.FunctionDeclaration&&n.upper&&(n=n.upper);let a=n.variables.find(i=>i.identifiers.includes(r));if(!a)return;let o=a.references.filter(i=>i.identifier!==r);if(!(o.length!==1||!o[0])&&!We(o[0].identifier.parent.parent))return o[0].identifier}var ut={name:fn,rule:Zr};import{ESLintUtils as Qr}from"@typescript-eslint/utils";import ft from"node:path";var ei=Qr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),mn="no-relative-imports",ti=z({find:V(),replacement:V()}),ni=z({aliases:ee(ti),rootDir:_(V()),allowNotFoundAliases:_(Ae()),_dev_simulateFileName:_(V())}),ri=ei({name:mn,meta:{type:"problem",fixable:"code",docs:{description:"Prevent relative imports and auto-fix them using configured aliases"},messages:{noRelativeImports:"Relative imports are not allowed. Use one of the valid aliases in tsconfig.json instead.",noRelativeImportsWithAlias:'Relative imports are not allowed. Use the "{{ alias }}" alias instead.'},schema:[ni]},defaultOptions:[{aliases:[],rootDir:void 0}],create(e,[t]){let r=t._dev_simulateFileName??e.filename;function n(i){return i.startsWith(".")||i.startsWith("..")}function a(i,s){let l=ft.dirname(s);return ft.resolve(l,i)}function o(i){let s=t.rootDir??process.cwd(),l=ft.relative(s,i);if(l.startsWith("."))return null;l.startsWith("/")||(l=`/${l}`);for(let{find:p,replacement:c}of t.aliases)if(l.startsWith(c)){let f=l.replace(c,p);return{alias:p,newPath:f}}return null}return{ImportDeclaration(i){let s=i.source.value;if(!n(s))return;let l=a(s,r),p=o(l);!p&&t.allowNotFoundAliases||e.report({node:i,messageId:p?"noRelativeImportsWithAlias":"noRelativeImports",data:{alias:p?.alias},fix:p?c=>c.replaceText(i.source,`'${p.newPath}'`):void 0})}}}}),mt={name:mn,rule:ri};import{AST_NODE_TYPES as Ve}from"@typescript-eslint/utils";import*as Ce from"zod/v4";var ii=Ce.object({alternativeMsgs:Ce.object({inArrayFind:Ce.string().optional(),inArrayFilter:Ce.string().optional()}).optional(),__dev_simulateFileName:Ce.string().optional()});function si(e){return e.typeAnnotation.type!==Ve.TSTypePredicate?!1:e.typeAnnotation.asserts===!1}function oi(e){return/\.(typeGuards|type-guards)\.(ts|tsx)$/.test(e)}function ai(e){let t=e.parent;for(;t;){if(t.type===Ve.CallExpression&&t.callee.type===Ve.MemberExpression&&t.callee.property.type===Ve.Identifier){let r=t.callee.property.name;if(r==="filter"||r==="find")return{method:r}}t=t.parent}return null}var dt=X({name:"no-type-guards",meta:{type:"problem",docs:{description:"Disallow type guards unless in *.typeGuards.(ts|tsx) or *.type-guards.(ts|tsx) files"},messages:{typeGuardNotAllowed:"Type guards are only allowed in *.typeGuards.(ts|tsx) or *.type-guards.(ts|tsx) files",useFilterWithTypeCheck:"{{message}}",useFindWithTypeCheck:"{{message}}"},schema:[xe(ii)],hasSuggestions:!0},defaultOptions:[{}],create(e,[t]){let r=t.__dev_simulateFileName??e.filename;if(oi(r))return{};function n(a){if(!si(a))return;let o=ai(a),i=[];if(t.alternativeMsgs&&o){let s=o.method==="filter"?t.alternativeMsgs.inArrayFilter:t.alternativeMsgs.inArrayFind;if(s){let l=o.method==="filter"?"useFilterWithTypeCheck":"useFindWithTypeCheck";e.report({node:a,messageId:l,data:{message:s}});return}}e.report({node:a,messageId:"typeGuardNotAllowed"})}return{"FunctionDeclaration > :matches(TSTypeAnnotation)":n,"ArrowFunctionExpression > :matches(TSTypeAnnotation)":n,"MethodDefinition > FunctionExpression > :matches(TSTypeAnnotation)":n}}});import{AST_NODE_TYPES as ke}from"@typescript-eslint/utils";var li="no-unnecessary-async-on-jsx-props";function pi(e){if(e.body.type!==ke.BlockStatement)return!1;let t=e.body.body;if(t.length!==1)return!1;let r=t[0];return!r||r.type!==ke.ExpressionStatement?!1:r.expression.type===ke.AwaitExpression}var yt=X({name:li,meta:{type:"suggestion",fixable:"code",docs:{description:"Disallow unnecessary async/await in JSX props where a single await provides no benefit"},messages:{unnecessaryAsyncInJsxProp:"Unnecessary async/await in JSX prop. The single await expression provides no benefit here."},schema:[]},defaultOptions:[],create(e){function t(r){pi(r)&&e.report({node:r,messageId:"unnecessaryAsyncInJsxProp",fix(n){let a=e.sourceCode,o=[],i=a.getFirstToken(r,l=>l.value==="async");if(i){let l=a.getTokenAfter(i);l?o.push(n.replaceTextRange([i.range[0],l.range[0]],"")):o.push(n.remove(i))}function s(l){if(l.type===ke.AwaitExpression){let p=a.getFirstToken(l);if(p&&p.value==="await"){let c=a.getTokenAfter(p);c?o.push(n.replaceTextRange([p.range[0],c.range[0]],"")):o.push(n.remove(p))}}if(l.type===ke.BlockStatement)for(let p of l.body)s(p);else l.type===ke.ExpressionStatement&&s(l.expression)}return s(r.body),o}})}return{"JSXAttribute ArrowFunctionExpression[async=true]":t,"JSXAttribute FunctionExpression[async=true]":t}}});import{AST_NODE_TYPES as Me,ESLintUtils as yn}from"@typescript-eslint/utils";import*as gt from"typescript";var ci=yn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),dn="no-unnecessary-casting",ui=z({additionalCastFunctions:_(ee(z({name:V(),expectedType:$t(["string","number"])})))}),St={name:dn,rule:ci({name:dn,meta:{type:"suggestion",docs:{description:"Prevents unnecessary Number and String castings"},messages:{unnecessaryNumberCasting:"Unnecessary Number() casting on a value already of number type",unnecessaryStringCasting:"Unnecessary String() casting on a value already of string type",unnecessaryCustomCasting:"Unnecessary {{name}}() casting on a value already of {{type}} type"},schema:[ui],fixable:"code"},defaultOptions:[{}],create(e){let r=e.options[0].additionalCastFunctions||[],n=[{name:"Number",expectedType:"number"},{name:"String",expectedType:"string"},...r],a=yn.getParserServices(e,!0),o=a.program?.getTypeChecker();if(!o||!a.program)throw new Error("TypeScript services or program not available");function i(c,f){switch(c.type){case Me.Literal:return f==="number"?typeof c.value=="number":typeof c.value=="string";case Me.TemplateLiteral:return f==="string";case Me.UnaryExpression:return f==="number"?c.operator==="+"||c.operator==="-"||c.operator==="~":!1;default:return!1}}function s(c,f){return f==="number"?!!(c.flags>.TypeFlags.NumberLike):!!(c.flags>.TypeFlags.StringLike)}function l(c,f){return y=>y.replaceText(c,e.sourceCode.getText(f))}function p(c){if(!o||c.arguments.length!==1)return;let f=c.arguments[0];if(!f||f.type===Me.SpreadElement)return;let{callee:y}=c;if(y.type!==Me.Identifier)return;let T=y.name,I=n.find(E=>E.name===T);if(!I)return;if(i(f,I.expectedType)||s(o.getTypeAtLocation(a.esTreeNodeToTSNodeMap.get(f)),I.expectedType)){let E,u;T==="Number"?E="unnecessaryNumberCasting":T==="String"?E="unnecessaryStringCasting":(E="unnecessaryCustomCasting",u={name:I.name,type:I.expectedType}),e.report({node:c,messageId:E,...u?{data:u}:{},fix:l(c,f)})}}return{CallExpression:p}}})};import{AST_NODE_TYPES as ze}from"@typescript-eslint/utils";import*as le from"zod/v4";var fi=le.object({methods:le.union([le.array(le.string()),le.literal("array")])}),Tt=X({name:"no-unnecessary-typing",meta:{type:"suggestion",docs:{description:"Prevents unnecessary explicit type annotations in callback parameters where TypeScript can infer the type"},messages:{unnecessaryTypeAnnotation:"Unnecessary type annotation. TypeScript can infer this type from context."},fixable:"code",schema:[le.toJSONSchema(fi)]},defaultOptions:[{methods:"array"}],create(e,[t]){let r=t.methods,n=new Set(["find","filter","map","forEach","some","every","reduce","findIndex","sort"]);function a(s){return Array.isArray(r)?r.includes(s):n.has(s)}function o(s){let{callee:l}=s;if(l.type===ze.MemberExpression){let p=l.property;if(p.type===ze.Identifier)return p.name}return null}function i(s,l){if(s.type!==ze.Identifier||!s.typeAnnotation)return;let p=l.parent;if(p.type===ze.CallExpression){let c=o(p);c&&a(c)&&p.arguments.indexOf(l)===0&&e.report({node:s.typeAnnotation,messageId:"unnecessaryTypeAnnotation",fix(y){return y.remove(s.typeAnnotation)}})}}return{ArrowFunctionExpression(s){for(let l of s.params)i(l,s)},FunctionExpression(s){for(let l of s.params)i(l,s)}}}});import{AST_NODE_TYPES as oe}from"@typescript-eslint/utils";var ht=X({name:"no-unused-obj-props",meta:{type:"suggestion",docs:{description:"Disallow unused properties when it is safe to remove them"},messages:{unusedObjectProperty:'The object property "{{name}}" is not being used',unusedReturnObjectProperty:'The object property "{{name}}" returned by this function is not being used'},schema:[]},defaultOptions:[],create(e){return{VariableDeclarator(t){if(t.id.type===oe.ObjectPattern||!t.init||t.init.type!==oe.ObjectExpression||t.id.type===oe.Identifier&&t.id.typeAnnotation||t.parent.parent.type===oe.ExportNamedDeclaration)return;let r=new Map;for(let i of t.init.properties)i.type===oe.Property&&i.key.type===oe.Identifier&&r.set(i.key.name,i);if(r.size===0||t.id.type!==oe.Identifier)return;let n=mi(t,e.sourceCode);if(n.length===0)return;let a=t.init.properties.some(i=>i.type!==oe.Property?!1:i.value.type===oe.FunctionExpression),o=new Set;for(let i of n){if(i.identifier.parent.type!==oe.MemberExpression)return;let s=i.identifier.parent;if(s.object!==i.identifier)return;if(s.computed)if(s.property.type===oe.Literal&&typeof s.property.value=="string")o.add(s.property.value);else return;else{if(s.property.type!==oe.Identifier)return;o.add(s.property.name)}if(s.parent.type===oe.CallExpression&&a)return}for(let[i,s]of r)o.has(i)||e.report({node:s,messageId:"unusedObjectProperty",data:{name:i}})}}}});function mi(e,t){let r=t.getDeclaredVariables(e);if(r.length!==1)return[];let n=r[0];return n?n.references.filter(a=>a.identifier!==e.id):[]}import{AST_NODE_TYPES as q,ESLintUtils as di}from"@typescript-eslint/utils";var yi=z({selectors:ee(z({name:V(),selectorProp:_(V()),selectorArgPos:_(de()),returnProp:_(V())}))}),gi=di.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),gn="no-unused-selected-values",Et={name:gn,rule:gi({name:gn,meta:{type:"suggestion",docs:{description:"Disallow unused values in selector objects"},messages:{unusedSelectedValue:'The selected value "{{name}}" is not being used'},schema:[yi]},defaultOptions:[{selectors:[]}],create(e,[t]){let{selectors:r=[]}=t,n=new Map(r.map(a=>[a.name,a]));return{VariableDeclarator(a){let o=null;if(a.init?.type===q.CallExpression&&(o=a.init),!o)return;let i=Ti(o);if(!i)return;let s=n.get(i);if(!s)return;let l=Si(o,s.selectorArgPos??0,s.selectorProp);if(!l)return;let p=hi(l);if(!p)return;let c=Sn(p.properties,void 0);if(!c)return;if(a.id.type===q.ObjectPattern){let T=Sn(a.id.properties,s.returnProp);if(!T)return;for(let[I,b]of c)T.has(I)||e.report({node:b,messageId:"unusedSelectedValue",data:{name:I}});return}if(a.id.type!==q.Identifier||s.returnProp)return;let f=Ei(a,e.sourceCode);if(f.length===0)return;let y=new Set;for(let T of f){if(T.identifier.parent.type!==q.MemberExpression)return;let I=T.identifier.parent.property;if(I.type!==q.Identifier)return;y.add(I.name)}for(let[T,I]of c)y.has(T)||e.report({node:I,messageId:"unusedSelectedValue",data:{name:T}})}}}})};function Si(e,t,r){let n=e.arguments[t];if(!n)return null;if(n.type===q.ArrowFunctionExpression||n.type===q.FunctionExpression)return n;if(r&&n.type===q.ObjectExpression){let a=n.properties.find(i=>i.type===q.Property&&i.key.type===q.Identifier&&i.key.name===r);if(a?.type!==q.Property)return null;let o=a.value;if(o.type===q.ArrowFunctionExpression||o.type===q.FunctionExpression)return o}return null}function Ti(e){return e.callee.type===q.Identifier?e.callee.name:e.callee.type===q.MemberExpression&&e.callee.property.type===q.Identifier?e.callee.property.name:null}function hi(e){if(e.body.type===q.ObjectExpression)return e.body;if(e.body.type===q.BlockStatement){let t=e.body.body.filter(r=>r.type===q.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==q.ObjectExpression?null:t[0].argument}return null}function Sn(e,t){let r=e;if(t){let a=e.find(o=>o.type===q.Property&&o.key.type===q.Identifier&&o.key.name===t);if(a?.type!==q.Property||a.value.type!==q.ObjectPattern)return null;r=a.value.properties}let n=new Map;for(let a of r){if(a.type!==q.Property||a.key.type!==q.Identifier)return null;n.set(a.key.name,a)}return n.size>0?n:null}function Ei(e,t){let r=t.getDeclaredVariables(e);if(r.length!==1)return[];let n=r[0];return n?n.references.filter(a=>a.identifier!==e.id):[]}import{AST_NODE_TYPES as Y}from"@typescript-eslint/utils";var bt=X({name:"no-unused-t-state-field",meta:{type:"suggestion",docs:{description:"Prevent declaring unused t-state fields"},messages:{unusedField:'Field "{{name}}" is not being used, you can safely remove it'},schema:[]},defaultOptions:[],create(e){if(!(e.filename.endsWith(".jsx")||e.filename.endsWith(".tsx")))return{};if(!e.sourceCode.ast.body.some(o=>o.type===Y.ImportDeclaration&&o.source.value==="t-state-form"))return{};let n=null,a=!1;return{CallExpression(o){if(a)return;if(!n){let s=bi(o);s&&(n=s);return}let i=xi(o,e.sourceCode);if(i){a=!0;for(let s of i)n.delete(s);if(n.size!==0)for(let[s,l]of n)e.report({node:l,messageId:"unusedField",data:{name:s}})}}}}});function bi(e){if(!(e.callee.type===Y.Identifier&&e.callee.name==="useForm"))return null;let r=e.arguments[0];if(!r||r.type!==Y.ObjectExpression)return null;let n=ct(r.properties,o=>o.type!==Y.Property||o.key.type!==Y.Identifier||o.key.name!=="initialConfig"?null:o.value.type===Y.ObjectExpression?o.value:o.value.type===Y.ArrowFunctionExpression||o.value.type===Y.FunctionExpression?Ii(o.value):null);if(!n)return null;let a=new Map;for(let o of n.properties)o.type===Y.Property&&o.key.type===Y.Identifier&&a.set(o.key.name,o);return a}function xi(e,t){if(!(e.callee.type===Y.Identifier&&e.callee.name==="useFormState")||e.parent.type!==Y.VariableDeclarator||e.parent.id.type!==Y.ObjectPattern||!ct(e.parent.id.properties,i=>i.type===Y.Property&&i.key.type===Y.Identifier&&i.key.name==="formFields"&&i))return null;let a=un(e.parent,"formFields",t),o=new Set;for(let{identifier:i}of a){if(i.type!==Y.Identifier||i.parent.type===Y.Property&&i.parent.parent.type===Y.ObjectExpression&&i.parent.parent.parent.type===Y.ReturnStatement||i.parent.type===Y.ReturnStatement)return null;if(i.parent.type===Y.MemberExpression){if(i.parent.object.type!==Y.Identifier||i.parent.property.type!==Y.Identifier)return null;o.add(i.parent.property.name)}}return o}function Ii(e){if(e.body.type===Y.ObjectExpression)return e.body;if(e.body.type===Y.BlockStatement){let t=e.body.body.filter(r=>r.type===Y.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==Y.ObjectExpression?null:t[0].argument}return null}import{AST_NODE_TYPES as U,ESLintUtils as Ci}from"@typescript-eslint/utils";var wi=Ci.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function Tn(e){let t=[];for(let r of e.members)r.type===U.TSPropertySignature&&r.key.type===U.Identifier&&t.push([r.key.name,r]);return t}function hn(e,...t){for(let r of t)e.set(...r);return e}var Ai=z({forceCheckOnFCPropTypesWithName:_(ee(V()))}),En="no-unused-type-props-in-args",xt=null,Ri=wi({name:En,meta:{type:"problem",docs:{description:"Disallow unused undestructured object type properties"},messages:{unusedObjectTypeProperty:"Object type property '{{ propertyName }}' is defined but never used",missingComponentParam:"Component has declared props but no props are used"},schema:[Ai],fixable:"code"},defaultOptions:[{}],create(e,[t]){let{forceCheckOnFCPropTypesWithName:r}=t;r&&!xt&&(xt=r.map(s=>new RegExp(s)));function n(s,l,p,c,f=!0){let y=p.name,T=e.sourceCode.getScope(l).references.find(E=>E.identifier.name===y)?.resolved,I=s&&xt?.some(E=>E.test(y));if(!T||!I&&T.references.filter(E=>E.isTypeReference).length>1)return;let b=T?.defs[0]?.node;if(!(f&&b?.parent?.type===U.ExportNamedDeclaration)){if(b?.type===U.TSTypeAliasDeclaration){a(s,l,c,b.typeAnnotation,!0);return}if(b?.type===U.TSInterfaceDeclaration){a(s,l,c,b.body,!0);return}}}function a(s,l,p,c,f){if(c.type===U.TSInterfaceBody){for(let y of c.body)y.type===U.TSPropertySignature&&y.key.type===U.Identifier&&p.set(y.key.name,y);return}if(c.type===U.TSTypeLiteral){hn(p,...Tn(c));return}if(c.type===U.TSIntersectionType){for(let y of c.types)a(s,l,p,y,!0);return}f||c.type===U.TSTypeReference&&c.typeName.type===U.Identifier&&n(s,l,c.typeName,p)}function o(s,l,p){for(let c of p)if(c.type==="ObjectPattern"&&c.typeAnnotation){let f=new Map;if(a(s,l,f,c.typeAnnotation.typeAnnotation,!1),f.size===0)continue;i(c,f)}else c.type===U.AssignmentPattern&&c.left.type===U.ObjectPattern&&o(s,l,[c.left])}function i(s,l){let p=[];if(s.properties.at(-1)?.type===U.RestElement)return;for(let T of s.properties)T.type===U.Property&&T.key.type===U.Identifier&&p.push(T.key.name);let f=[],y=[];for(let[T,I]of l)p.includes(T)||(y.push(T),f.push({node:I,messageId:"unusedObjectTypeProperty",data:{propertyName:T}}));for(let[T,I]of f.entries())e.report({...I,fix:T===f.length-1?b=>{let E=s.properties.at(-1),u=y.join(", ");return E?E?.type===U.RestElement?null:b.insertTextAfter(E,`, ${u}`):b.insertTextBeforeRange([s.range[0]+1,s.range[1]],`${u}`)}:void 0})}return{VariableDeclaration(s){let l=s.declarations[0];if(!l)return;let p=new Map,c=l.id.type===U.Identifier&&l.id.typeAnnotation?.typeAnnotation.type===U.TSTypeReference&&l.id.typeAnnotation.typeAnnotation.typeName.type===U.Identifier&&l.id.typeAnnotation.typeAnnotation.typeName.name==="FC"&&l.id.typeAnnotation.typeAnnotation.typeArguments?.params[0];if(c){if(c.type===U.TSTypeReference&&c.typeName.type===U.Identifier)n(!0,s,c.typeName,p,!1);else if(c.type===U.TSTypeLiteral)hn(p,...Tn(c));else if(c.type===U.TSIntersectionType)for(let f of c.types)f.type===U.TSTypeReference&&f.typeName.type===U.Identifier?n(!0,s,f.typeName,p,!1):a(!0,s,p,f,!0);if(p.size!==0&&l.init?.type===U.ArrowFunctionExpression){let f=l.init.params[0];if(!f){e.report({node:l.init,messageId:"missingComponentParam"});return}f.type===U.ObjectPattern&&i(f,p)}}},FunctionDeclaration:function(s){o(!1,s,s.params)},ArrowFunctionExpression(s){o(!1,s,s.params)}}}}),It={name:En,rule:Ri};import{AST_NODE_TYPES as fe}from"@typescript-eslint/utils";var Ct=X({name:"no-write-only-ref",meta:{type:"problem",docs:{description:"Disallow creating refs that are never read"},messages:{refNotRead:'Ref "{{name}}" is never read. Consider removing it if not needed.'},schema:[]},defaultOptions:[],create(e){let t=new Set;function r(n){return n.callee.type===fe.Identifier?t.has(n.callee.name):n.callee.type===fe.MemberExpression&&n.callee.object.type===fe.Identifier&&n.callee.property.type===fe.Identifier?n.callee.property.name==="useRef":!1}return{ImportDeclaration(n){if(n.source.value==="react")for(let a of n.specifiers)a.type===fe.ImportSpecifier&&a.imported.type===fe.Identifier&&a.imported.name==="useRef"&&t.add(a.local.name)},VariableDeclarator(n){if(n.init&&n.init.type===fe.CallExpression&&r(n.init)&&n.id.type===fe.Identifier){let o=e.sourceCode.getScope(n).set.get(n.id.name);if(o){let i=!1;for(let s of o.references){let p=s.identifier.parent;if(p!==n&&!(p.type===fe.JSXExpressionContainer&&p.parent.type===fe.JSXAttribute&&p.parent.name.type===fe.JSXIdentifier&&p.parent.name.name==="ref")){i=!0;break}}i||e.report({node:n.id,messageId:"refNotRead",data:{name:n.id.name}})}}}}}});import{AST_NODE_TYPES as wt,ESLintUtils as vi}from"@typescript-eslint/utils";var ki=vi.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),xn="prefer-named-functions",bn=new Map,Oi=ki({name:xn,meta:{hasSuggestions:!0,type:"suggestion",docs:{description:"Prevent using arrow functions when a named function can be used instead"},schema:[{type:"object",properties:{ignoreRegex:{type:"string"},disallowArrowFnWithImplicitReturns:{type:"boolean"}}}],messages:{suggestion:"Convert to named function",default:'Function {{functionName}} should be defined as a named function "function {{functionName}} () {}" instead of an arrow function',withIgnoreRegex:'Function {{functionName}} should be defined as a named function "function {{functionName}} () {}", if not possible to use `function` you can also use a name that matches the rule ignore regex'}},defaultOptions:[{}],create(e,[t]){let r=null;if(t.ignoreRegex){let n=bn.get(t.ignoreRegex);n?r=n:(r=new RegExp(t.ignoreRegex),bn.set(t.ignoreRegex,r))}return{VariableDeclarator(n){if(n.init&&n.init.type===wt.ArrowFunctionExpression&&n.id.type===wt.Identifier){let a=n.id.name;if(n.id.typeAnnotation||r&&r.test(a)||!t.disallowArrowFnWithImplicitReturns&&n.init.body.type!==wt.BlockStatement)return;let o=n.parent,i=n.init.params,s=n.init.body,l=n.init;e.report({node:n.id,messageId:r?"withIgnoreRegex":"default",data:{functionName:a,ignoreRegex:t.ignoreRegex},suggest:[{messageId:"suggestion",fix:p=>p.replaceText(o,`${l.async?"async ":""}function ${a}(${i.map(c=>e.sourceCode.getText(c)).join(", ")||""}) ${e.sourceCode.getText(s)}`)}]})}}}}}),At={name:xn,rule:Oi};import{AST_NODE_TYPES as j}from"@typescript-eslint/utils";var Pi=z({disallowedFunctions:ee(z({name:V(),allowUsingWithArgs:_(Ae()),hookAlternative:_(V()),message:_(V()),allowUseInside:_(ee(V()))}))});function He(e){return/^use[A-Z]/.test(e)}function In(e){return/^[A-Z]/.test(e)}function Fi(e){return e.type===j.Identifier?He(e.name):e.type===j.MemberExpression&&e.property.type===j.Identifier?He(e.property.name):!1}function Cn(e,t){return e.type===j.Identifier?e.name===t:e.type===j.MemberExpression&&e.object.type===j.Identifier&&e.property.type===j.Identifier?e.object.name==="React"&&e.property.name===t:!1}function wn(e){return!!(e.parent&&e.parent.type===j.CallExpression&&Cn(e.parent.callee,"forwardRef"))}function An(e){return!!(e.parent&&e.parent.type===j.CallExpression&&Cn(e.parent.callee,"memo"))}function Rt(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 Ni(e){let t=e.parent,r=!1;for(;t;){if(t.type===j.FunctionDeclaration||t.type===j.FunctionExpression||t.type===j.ArrowFunctionExpression){let n=Rt(t);if(n&&n.type===j.Identifier){if(In(n.name)||He(n.name))return!r;r=!0}else{if(wn(t)||An(t))return!r;if(t.parent.type===j.CallExpression){let a=t.parent;Fi(a.callee)||(r=!0)}else t.parent.type===j.JSXExpressionContainer||(r=!0)}}t=t.parent}return!1}function Rn(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 Mi(e,t){if(!t.length)return!1;let r=e.parent;for(;r;){if(r.type===j.FunctionDeclaration||r.type===j.FunctionExpression||r.type===j.ArrowFunctionExpression){let n=Rt(r);if(n&&n.type===j.Identifier&&t.includes(n.name))return!0}else if(r.type===j.CallExpression){let n=Rn(r);if(n&&t.includes(n))return!0}r=r.parent}return!1}function ji(e){return e.arguments.length>0&&!e.arguments.every(t=>t.type===j.Identifier&&t.name==="undefined")}function Di(e,t){let r=!1,n=e.parent;for(;n;){if(n.type===j.FunctionDeclaration||n.type===j.FunctionExpression||n.type===j.ArrowFunctionExpression){let a=Rt(n);if(a&&a.type===j.Identifier){if(In(a.name)||He(a.name)){r=!0;break}}else if(wn(n)||An(n)){r=!0;break}}n=n.parent}return r?t.length===0?Ni(e):!Mi(e,t):!1}var vt=X({name:"prefer-react-hook-alternative",meta:{type:"suggestion",docs:{description:"Prefer hook alternatives for certain functions in React components and hooks"},messages:{preferHookAlternative:"This function should not be used in react{{message}}."},schema:[Pi],hasSuggestions:!0},defaultOptions:[{disallowedFunctions:[]}],create(e,[t]){let{disallowedFunctions:r}=t,n=new Map(r.map(a=>[a.name,a]));return{CallExpression(a){let o=Rn(a);if(!o)return;let i=n.get(o);if(!i||i.allowUsingWithArgs&&ji(a))return;let s=i.allowUseInside||[];Di(a,s)&&e.report({node:a,messageId:"preferHookAlternative",data:{message:i.message?` ${i.message}`:` use ${i.hookAlternative} instead`},suggest:i.hookAlternative?[{messageId:"preferHookAlternative",data:{message:`Replace with ${i.hookAlternative}`,hookAlternative:i.hookAlternative},fix:l=>{let p=i.hookAlternative;return a.callee.type===j.Identifier?l.replaceText(a.callee,p):a.callee.type===j.MemberExpression&&a.callee.property.type===j.Identifier?l.replaceText(a.callee.property,p):null}}]:[]})}}}});import{AST_NODE_TYPES as K,AST_TOKEN_TYPES as vn,ESLintUtils as Li}from"@typescript-eslint/utils";var _i=Li.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),On="prefer-single-line-if",$i=z({maxLineLength:_(de()),maxNonSimpleConditionLength:_(de())}),Ui=_i({name:On,meta:{type:"suggestion",fixable:"code",docs:{description:"Enforce single-line if in simple if statements"},messages:{noSingleLineCurly:"If return statement with single statement body should be written in a single line"},schema:[$i]},defaultOptions:[{}],create(e,[t]){let r=e.sourceCode;return{IfStatement(n){if(n.consequent.type!==K.BlockStatement||n.loc.start.line===n.loc.end.line||r.getCommentsInside(n.consequent).length>0||n.alternate||n.consequent.body.length!==1)return;let o=n.consequent.body[0];if(o.type===K.ReturnStatement){if(!Fn(o))return}else if(!(o.type===K.ContinueStatement||o.type===K.BreakStatement))return;if(n.test.type===K.LogicalExpression||n.test.type===K.ConditionalExpression)return;let i;if(t.maxNonSimpleConditionLength){let f=kn(n.test);if(!f&&n.test.type===K.UnaryExpression&&n.test.operator==="!"){let y=n.test.argument;kn(y)&&(f=!0)}if(f&&(i=r.getText(n.test),i.length>t.maxNonSimpleConditionLength))return}i||(i=r.getText(n.test));let s=r.getText(o);if(i.includes(`
|
|
16
|
-
`))return;let l=r.getTokenAfter(n);if(l&&l.type===vn.Punctuator&&l.value==="}"){let f=r.getTokenAfter(l);if(f&&f.type===vn.Keyword&&(f.value==="else"||f.value==="catch"))return}let p=Wi(r,n),c=`if (${i}) ${s}`;t.maxLineLength&&c.length+p.length>t.maxLineLength||e.report({node:n,messageId:"noSingleLineCurly",fix:f=>f.replaceText(n,c)})}}}});function kn(e){return e.type===K.CallExpression||e.type===K.BinaryExpression||e.type===K.MemberExpression&&Pn(e)}function Pn(e){return e.object.type===K.MemberExpression?Pn(e.object):e.object.type!==K.Identifier}function Wi(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}function Fn(e){if(!e.argument)return!0;let t=e.argument;return t.type===K.ArrayExpression&&t.elements.length===0||t.type===K.ObjectExpression&&t.properties.length===0||t.type===K.Literal||t.type===K.Identifier||t.type===K.TemplateLiteral||t.type===K.TaggedTemplateExpression?!0:t.type===K.CallExpression?t.arguments.length===0:t.type===K.UnaryExpression?Fn(t):!1}var kt={name:On,rule:Ui};import{AST_NODE_TYPES as pe,ESLintUtils as Vi}from"@typescript-eslint/utils";var zi=Vi.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Nn="react-compiler-migration",Hi=z({disallowHooks:_(ee(z({name:V(),replacement:V()}))),disallowMethods:_(ee(z({name:V(),replacement:_(V()),requireTrueProp:_(V())})))}),Yi=/eslint +react-compiler\/react-compiler: +\["error/;function qi(e){return e.type===pe.Identifier?e.name.startsWith("use"):e.type===pe.MemberExpression&&e.property.type===pe.Identifier?e.property.name.startsWith("use"):!1}var Ji=zi({name:Nn,meta:{type:"suggestion",fixable:"code",docs:{description:"Rules to help migrate to the new React compiler"},messages:{disallowedFunctionOrMethod:"{{functionOrMethod}} is not supported in react compiler. Use {{replacement}} instead.",replace:"Replace with safe alternative {{replacement}}",disallowedMethodWithMissingRequireTrueProp:"{{method}} is should have a prop named {{requireTrueProp}} set to true when used in react compiler."},hasSuggestions:!0,schema:[Hi]},defaultOptions:[{}],create(e,[t]){let r=!1;for(let n of e.sourceCode.getAllComments())if(Yi.test(n.value)){r=!0;break}return r?{CallExpression(n){if(t.disallowHooks?.length){let a=null,o=null;if(n.callee.type===pe.Identifier?(a=n.callee.name,o=n.callee):n.callee.type===pe.MemberExpression&&n.callee.property.type===pe.Identifier&&(a=n.callee.property.name,o=n.callee.property),a){let i=t.disallowHooks.find(s=>s.name===a);i&&o&&e.report({node:n,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:i.name,replacement:i.replacement},suggest:[{messageId:"replace",data:{replacement:i.replacement},fix:s=>s.replaceText(o,i.replacement)}]})}}if(t.disallowMethods?.length&&qi(n.callee)){for(let a of n.arguments)if(a.type===pe.ObjectExpression){for(let o of a.properties)if(o.type===pe.Property&&o.key.type===pe.Identifier){let i=o.key.name,s=t.disallowMethods.find(l=>l.name===i);if(s){if(s.requireTrueProp){let l=s.requireTrueProp,p=!1;for(let c of a.properties)if(c.type===pe.Property&&c.key.type===pe.Identifier&&c.key.name===l&&c.value.type===pe.Literal&&c.value.value===!0){p=!0;break}if(!p){e.report({node:o,messageId:"disallowedMethodWithMissingRequireTrueProp",data:{method:s.name,requireTrueProp:l}});continue}}s.replacement&&e.report({node:o,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:s.name,replacement:s.replacement},suggest:[{messageId:"replace",data:{replacement:s.replacement},fix:l=>l.replaceText(o.key,s.replacement)}]})}}}}}}:{}}}),Ot={name:Nn,rule:Ji};import{ESLintUtils as Bi,TSESTree as Xi}from"@typescript-eslint/utils";var Gi=Bi.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Mn="require-description",Ki=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,Zi=/^eslint-disable-(next-)?line$/u,Qi=Gi({name:Mn,meta:{type:"problem",docs:{description:"Require descriptions for eslint directives."},messages:{missingDescription:"Unexpected undescribed directive comment. Include descriptions to explain why the comment is necessary."},schema:[{type:"object",properties:{ignore:{type:"array",items:{type:"string",enum:["eslint","eslint-disable","eslint-disable-line","eslint-disable-next-line","eslint-enable","eslint-env","exported","global","globals"]},additionalItems:!1,uniqueItems:!0}},additionalProperties:!1}]},defaultOptions:[{ignore:[]}],create(e,[t]){let r=e.sourceCode,n=new Set(t.ignore||[]);return{Program(){for(let a of r.getAllComments()){let o=es(a);o!=null&&(n.has(o.kind)||o.description||e.report({loc:ns(a.loc),messageId:"missingDescription"}))}}}}}),jn={name:Mn,rule:Qi};function es(e){let{text:t,description:r}=ts(e.value);if(!t)return null;let n=Ki.exec(t);if(!n)return null;let a=n[1];if(!a)return null;let o=Zi.test(a);if(e.type===Xi.AST_TOKEN_TYPES.Line&&!o||o&&e.loc.start.line!==e.loc.end.line)return null;let i=t.slice(n.index+a.length);return{kind:a,value:i.trim(),description:r}}function ts(e){let t=e.split(/\s-{2,}\s/u);return{text:t[0]?.trim(),description:t.length>1?t[1]?.trim()??null:null}}function ns(e){return{start:{line:e.start.line,column:-1},end:e.end}}import{AST_NODE_TYPES as L}from"@typescript-eslint/utils";import{z as he}from"zod/v4";var rs=he.object({varsToCheck:he.array(he.object({selector:he.string().optional(),fromFnCall:he.string().optional(),prop:he.string().or(he.array(he.string())),errorMsg:he.string().optional()}))}),Pt=X({name:"require-reads-to-var-prop",meta:{type:"suggestion",docs:{description:"Require specific properties from variables to be read or ensure the variable is passed to functions/components"},messages:{propNotRead:'"{{fnName}}" requires reads to the prop "{{prop}}". {{customMsg}}',propsNotRead:'"{{fnName}}" requires reads to the props {{props}}. {{customMsg}}'},schema:[xe(rs)]},defaultOptions:[{varsToCheck:[]}],create(e,[t]){let r=new Map,n=(i,s,l,p)=>{let c=new Set;for(let y of i.properties)y.type===L.Property&&y.key.type===L.Identifier&&c.add(y.key.name);let f=s.filter(y=>!c.has(y));if(f.length>0)if(f.length===1)e.report({node:i,messageId:"propNotRead",data:{prop:f[0],fnName:p,customMsg:l||""}});else{let y=f.map(T=>`"${T}"`).join(", ");e.report({node:i,messageId:"propsNotRead",data:{props:y,fnName:p,customMsg:l||""}})}},a=i=>{if(i.init?.type===L.CallExpression){if(i.init.callee.type===L.Identifier)return i.init.callee.name;if(i.init.callee.type===L.MemberExpression&&i.init.callee.property.type===L.Identifier)return i.init.callee.object.type===L.Identifier?`${i.init.callee.object.name}.${i.init.callee.property.name}`:i.init.callee.property.name}return"unknown function"},o={};for(let i of t.varsToCheck)i.selector&&(o[i.selector]=s=>{if(s.type===L.VariableDeclarator&&s.id.type===L.Identifier&&r.set(s.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:s.id,fnName:a(s)}),s.type===L.VariableDeclarator&&s.id.type===L.ObjectPattern){let l=Array.isArray(i.prop)?i.prop:[i.prop];n(s.id,l,i.errorMsg,a(s))}});for(let i of t.varsToCheck)if(i.fromFnCall){let s=i.fromFnCall;if(s.startsWith("*.")){let p=`VariableDeclarator > CallExpression > MemberExpression[property.name="${s.slice(2)}"]`;o[p]=c=>{if(c.type!==L.MemberExpression||c.parent.type!==L.CallExpression)return;let f=c.parent;if(f.parent.type!==L.VariableDeclarator)return;let y=f.parent;if(y.id.type===L.Identifier)r.set(y.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:y.id,fnName:i.fromFnCall||"unknown function"});else if(y.id.type===L.ObjectPattern){let T=Array.isArray(i.prop)?i.prop:[i.prop];n(y.id,T,i.errorMsg,i.fromFnCall||"unknown function")}}}else if(s.includes(".")){let[l,p]=s.split("."),c=`VariableDeclarator > CallExpression > MemberExpression[object.name="${l}"][property.name="${p}"]`;o[c]=f=>{if(f.type!==L.MemberExpression||f.parent.type!==L.CallExpression)return;let y=f.parent;if(y.parent.type!==L.VariableDeclarator)return;let T=y.parent;if(T.id.type===L.Identifier)r.set(T.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:T.id,fnName:i.fromFnCall||"unknown function"});else if(T.id.type===L.ObjectPattern){let I=Array.isArray(i.prop)?i.prop:[i.prop];n(T.id,I,i.errorMsg,i.fromFnCall||"unknown function")}}}else{let l=`VariableDeclarator > CallExpression > Identifier[name="${s}"]`;o[l]=p=>{if(p.type!==L.Identifier||p.parent.type!==L.CallExpression)return;let c=p.parent;if(c.parent.type!==L.VariableDeclarator)return;let f=c.parent;if(f.id.type===L.Identifier)r.set(f.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:f.id,fnName:i.fromFnCall||"unknown function"});else if(f.id.type===L.ObjectPattern){let y=Array.isArray(i.prop)?i.prop:[i.prop];n(f.id,y,i.errorMsg,i.fromFnCall||"unknown function")}}}}return{...o,"Program:exit"(){for(let[i,{props:s,errorMsg:l,node:p,fnName:c}]of r){let y=e.sourceCode.getScope(p).set.get(i);if(y){let T=new Set(s);for(let I of y.references){let b=I.identifier,E=b.parent;if(!(E.type===L.VariableDeclarator&&E.id===b)){if(E.type===L.MemberExpression&&E.object===b&&E.property.type===L.Identifier&&T.has(E.property.name)){if(T.delete(E.property.name),T.size===0)break;continue}if(E.type===L.VariableDeclarator&&E.init===b&&E.id.type===L.ObjectPattern){for(let u of E.id.properties)u.type===L.Property&&u.key.type===L.Identifier&&T.has(u.key.name)&&T.delete(u.key.name);if(T.size===0)break;continue}if(!(E.type===L.MemberExpression&&E.object===b&&E.property.type===L.Identifier&&!s.includes(E.property.name))){T.clear();break}}}if(T.size>0){let I=Array.from(T);if(I.length===1)e.report({node:p,messageId:"propNotRead",data:{prop:I[0],fnName:c,customMsg:l||""}});else{let b=I.map(E=>`"${E}"`).join(", ");e.report({node:p,messageId:"propsNotRead",data:{props:b,fnName:c,customMsg:l||""}})}}}}}}}});function _n(e){return/^use[A-Z0-9]/.test(e)}function Ye(e){return e.type==="Identifier"?_n(e.name):e.type==="MemberExpression"&&!e.computed&&Ye(e.property)?e.object.type==="Identifier":!1}function $n(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function Un(e,t){return e.name===t||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===t}function Wn(e){return!!(e.parent&&e.parent.callee&&Un(e.parent.callee,"forwardRef"))}function Vn(e){return!!(e.parent&&e.parent.callee&&Un(e.parent.callee,"memo"))}function Ft(e){for(;e;){let t=Hn(e);if(t&&($n(t)||Ye(t))||Wn(e)||Vn(e))return!0;e=e.parent}return!1}function Dn(e){return!1}function Nt(e){return!1}var is=/eslint +react-compiler\/react-compiler: +\["error/,zn={meta:{type:"problem",docs:{description:"enforces the Rules of Hooks",recommended:!0,url:"https://reactjs.org/docs/hooks-rules.html"},schema:[{type:"object",ignoreIfReactCompilerIsEnabled:!1,properties:{ignoreIfReactCompilerIsEnabled:{type:"boolean"}}}]},create(e){if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let l of e.sourceCode.getAllComments())if(is.test(l.value))return{CallExpression(p){let c=null;p.callee.name==="useMemo"?c="useMemo":p.callee.name==="useCallback"&&(c="useCallback"),c&&e.report({node:p,message:`"${c}" is not necessary when using React Compiler.`})}}}let t=typeof e.getSource=="function"?l=>t(l):l=>e.sourceCode.getText(l),r=typeof e.getScope=="function"?()=>r():l=>e.sourceCode.getScope(l),n=null,a=[],o=[],i=new WeakSet;function s(l){for(let p of l.references){let c=p.identifier.parent;if(c.type==="VariableDeclarator"&&c.init&&c.init.type==="CallExpression"&&c.init.callee&&Dn(c.init.callee))for(let f of p.resolved.references)f!==p&&i.add(f.identifier)}}return{onCodePathSegmentStart:l=>o.push(l),onCodePathSegmentEnd:()=>o.pop(),onCodePathStart:()=>a.push(new Map),onCodePathEnd(l,p){let c=a.pop();if(c.size===0)return;let f=new Set;function y(g,m){let{cache:S}=y,k=S.get(g.id),R=new Set(m);if(R.has(g.id)){let C=[...R],N=C.slice(C.indexOf(g.id)+1);for(let W of N)f.add(W);return BigInt("0")}if(R.add(g.id),k!==void 0)return k;if(l.thrownSegments.includes(g))k=BigInt("0");else if(g.prevSegments.length===0)k=BigInt("1");else{k=BigInt("0");for(let C of g.prevSegments)k+=y(C,R)}return g.reachable&&k===BigInt("0")?S.delete(g.id):S.set(g.id,k),k}function T(g,m){let{cache:S}=T,k=S.get(g.id),R=new Set(m);if(R.has(g.id)){let C=Array.from(R),N=C.slice(C.indexOf(g.id)+1);for(let W of N)f.add(W);return BigInt("0")}if(R.add(g.id),k!==void 0)return k;if(l.thrownSegments.includes(g))k=BigInt("0");else if(g.nextSegments.length===0)k=BigInt("1");else{k=BigInt("0");for(let C of g.nextSegments)k+=T(C,R)}return S.set(g.id,k),k}function I(g){let{cache:m}=I,S=m.get(g.id);if(S===null)return 1/0;if(S!==void 0)return S;if(m.set(g.id,null),g.prevSegments.length===0)S=1;else{S=1/0;for(let k of g.prevSegments){let R=I(k);R<S&&(S=R)}S+=1}return m.set(g.id,S),S}y.cache=new Map,T.cache=new Map,I.cache=new Map;let b=T(l.initialSegment),E=Hn(p),u=Ft(p),A=E?$n(E)||Ye(E):Wn(p)||Vn(p),x=1/0;for(let g of l.finalSegments){if(!g.reachable)continue;let m=I(g);m<x&&(x=m)}for(let[g,m]of c){if(!g.reachable)continue;let S=g.nextSegments.length===0?x<=I(g):x<I(g),k=y(g)*T(g),R=f.has(g.id);for(let C of m)if(R&&!Nt(C)&&e.report({node:C,message:`React Hook "${t(C)}" may be executed more than once. Possibly because it is called in a loop. React Hooks must be called in the exact same order in every component render.`}),A){if(p.async&&e.report({node:C,message:`React Hook "${t(C)}" cannot be called in an async function.`}),!R&&k!==b&&!Nt(C)){let W=`React Hook "${t(C)}" is called conditionally. React Hooks must be called in the exact same order in every component render.`+(S?" Did you accidentally call a React Hook after an early return?":"");e.report({node:C,message:W})}}else if(p.parent&&(p.parent.type==="MethodDefinition"||p.parent.type==="ClassProperty")&&p.parent.value===p){let N=`React Hook "${t(C)}" cannot be called in a class component. React Hooks must be called in a React function component or a custom React Hook function.`;e.report({node:C,message:N})}else if(E){let N=`React Hook "${t(C)}" is called in function "${t(E)}" that is neither a React function component nor a custom React Hook function. React component names must start with an uppercase letter. React Hook names must start with the word "use".`;e.report({node:C,message:N})}else if(p.type==="Program"){let N=`React Hook "${t(C)}" cannot be called at the top level. React Hooks must be called in a React function component or a custom React Hook function.`;e.report({node:C,message:N})}else if(u&&!Nt(C)){if(p.parent.type==="CallExpression"&&p.parent.callee.type==="Identifier"&&p.parent.callee.name==="useCallback"){let W=p.parent;if(W.parent.type==="VariableDeclarator"&&_n(W.parent.id.name))return}let N=`React Hook "${t(C)}" cannot be called inside a callback. React Hooks must be called in a React function component or a custom React Hook function.`;e.report({node:C,message:N})}}},CallExpression(l){if(Ye(l.callee)){let p=Ln(a),c=Ln(o),f=p.get(c);f||(f=[],p.set(c,f)),f.push(l.callee)}l.callee.type==="Identifier"&&(l.callee.name==="useEffect"||Dn(l.callee))&&l.arguments.length>0&&(n=l)},Identifier(l){n==null&&i.has(l)&&l.parent.type!=="CallExpression"&&e.report({node:l,message:`\`${t(l)}\` is a function created with React Hook "useEffectEvent", and can only be called from the same component. They cannot be assigned to variables or passed down.`})},"CallExpression:exit"(l){l===n&&(n=null)},FunctionDeclaration(l){Ft(l)&&s(r(l))},ArrowFunctionExpression(l){Ft(l)&&s(r(l))}}}};function Hn(e){return e.type==="FunctionDeclaration"||e.type==="FunctionExpression"&&e.id?e.id:e.type==="FunctionExpression"||e.type==="ArrowFunctionExpression"?e.parent.type==="VariableDeclarator"&&e.parent.init===e?e.parent.id:e.parent.type==="AssignmentExpression"&&e.parent.right===e&&e.parent.operator==="="?e.parent.left:e.parent.type==="Property"&&e.parent.value===e&&!e.parent.computed?e.parent.key:e.parent.type==="AssignmentPattern"&&e.parent.right===e&&!e.parent.computed?e.parent.left:void 0:void 0}function Ln(e){return e[e.length-1]}import{AST_NODE_TYPES as ne,AST_TOKEN_TYPES as ss}from"@typescript-eslint/utils";import*as se from"zod/v4";var os=se.object({indent:se.union([se.string().regex(/^\s+$/),se.number().int().min(1)]).optional(),tags:se.array(se.string()).optional(),functions:se.array(se.string()).optional(),comments:se.array(se.string()).optional()}),Mt=X({name:"template-indent",meta:{type:"suggestion",docs:{description:"Fix whitespace-insensitive template indentation"},fixable:"code",schema:[xe(os)],messages:{improperlyIndented:"Templates should be properly indented."}},defaultOptions:[{}],create(e){let t=e.sourceCode,{comments:r=["HTML","indent"],functions:n=["dedent","stripIndent"],tags:a=["outdent","dedent","gql","sql","html","styled"],indent:o}=e.options[0],i=r.map(u=>u.toLowerCase());function s(u){let A=u.split(/\r?\n/),x=A.filter(m=>m.trim()!=="");if(x.length===0)return u;let g=Number.POSITIVE_INFINITY;for(let m of x){let S=m.match(/^(\s*)/);S&&(g=Math.min(g,S[1]?.length??0))}return!isFinite(g)||g===0?u:A.map(m=>m.slice(g)).join(`
|
|
17
|
-
`)}function l(u,A,
|
|
18
|
-
`)}function p(u){if(u.type===ne.Identifier)return u.name;if(u.type===ne.MemberExpression){let A=u.object.type===ne.Identifier?u.object.name:null,
|
|
15
|
+
Learn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching`});let S=l.acquire(u),k=new Set,R=null;{let d=S.upper;for(;d&&(k.add(d),d.type!=="function");)d=d.upper;if(!d)return;R=d}let C=Array.isArray;function N(d){if(!C(d.defs))return!1;let h=d.defs[0];if(h==null||h.node.type!=="VariableDeclarator")return!1;let v=h.node.init;if(v==null)return!1;for(;v.type==="TSAsExpression";)v=v.expression;let O=h.node.parent;if(O==null&&(tt(R.block,h.node.id),O=h.node.parent,O==null))return!1;if(O.kind==="const"&&v.type==="Literal"&&(typeof v.value=="string"||typeof v.value=="number"||v.value===null))return!0;if(v.type!=="CallExpression")return!1;let F=v.callee;if(F.type==="MemberExpression"&&F.object.name==="React"&&F.property!=null&&!F.computed&&(F=F.property),F.type!=="Identifier")return!1;let P=h.node.id,{name:j}=F;if(j==="useRef"&&P.type==="Identifier")return!0;if(Tr(F)&&P.type==="Identifier"){for(let D of d.references)D!==P&&T.add(D.identifier);return!0}else if(j==="useState"||j==="useReducer"){if(P.type==="ArrayPattern"&&P.elements.length===2&&C(d.identifiers)){if(P.elements[1]===d.identifiers[0]){if(j==="useState"){let D=d.references,le=0;for(let Te=0;Te<D.length;Te++){if(D[Te].isWrite()&&le++,le>1)return!1;p.set(D[Te].identifier,P.elements[0])}}return!0}else if(P.elements[0]===d.identifiers[0]){if(j==="useState"){let D=d.references;for(let le=0;le<D.length;le++)c.add(D[le].identifier)}return!1}}}else if(j==="useTransition"&&P.type==="ArrayPattern"&&P.elements.length===2&&Array.isArray(d.identifiers)&&P.elements[1]===d.identifiers[0])return!0;return!1}function W(d){if(!C(d.defs))return!1;let h=d.defs[0];if(h==null||h.node==null||h.node.id==null)return!1;let v=h.node,O=R.childScopes,F=null,P;for(P=0;P<O.length;P++){let j=O[P],D=j.block;if(v.type==="FunctionDeclaration"&&D===v||v.type==="VariableDeclarator"&&D.parent===v){F=j;break}}if(F==null)return!1;for(P=0;P<F.through.length;P++){let j=F.through[P];if(j.resolved!=null&&k.has(j.resolved.scope)&&!J(j.resolved))return!1}return!0}let J=I(N,f),te=I(W,y),Z=new Map;function be(d){let h=d.from,v=!1;for(;h.block!==u;)h.type==="function"&&(v=h.block.parent!=null&&h.block.parent.type==="ReturnStatement"),h=h.upper;return v}let B=new Map,ye=new Map;ue(S);function ue(d){for(let h of d.references){if(!h.resolved||!k.has(h.resolved.scope))continue;let v=tt(u,h.identifier),O=Gt(v),F=he(O,ye);if(m&&O.type==="Identifier"&&(O.parent.type==="MemberExpression"||O.parent.type==="OptionalMemberExpression")&&!O.parent.computed&&O.parent.property.type==="Identifier"&&O.parent.property.name==="current"&&be(h)&&Z.set(F,{reference:h,dependencyNode:O}),O.parent.type==="TSTypeQuery"||O.parent.type==="TSTypeReference")continue;let P=h.resolved.defs[0];if(P!=null&&!(P.node!=null&&P.node.init===u.parent)&&P.type!=="TypeParameter")if(B.has(F))B.get(F).references.push(h);else{let j=h.resolved,D=J(j)||te(j);B.set(F,{isStable:D,references:[h]})}}for(let h of d.childScopes)ue(h)}Z.forEach(({reference:d,dependencyNode:h},v)=>{let O=d.resolved.references,F=!1;for(let P=0;P<O.length;P++){let{identifier:j}=O[P],{parent:D}=j;if(D!=null&&D.type==="MemberExpression"&&!D.computed&&D.property.type==="Identifier"&&D.property.name==="current"&&D.parent.type==="AssignmentExpression"&&D.parent.left===D){F=!0;break}}F||s({node:h.parent.property,message:`The ref value '${v}.current' will likely have changed by the time this effect cleanup function runs. If this ref points to a node rendered by React, copy '${v}.current' to a variable inside the effect, and use that variable in the cleanup function.`})});let ie=new Set;function Se(d,h){ie.has(h)||(ie.add(h),s({node:d,message:`Assignments to the '${h}' variable from inside React Hook ${r(b)} will be lost after each render. To preserve the value over time, store it in a useRef Hook and keep the mutable value in the '.current' property. Otherwise, you can move this variable directly inside ${r(b)}.`}))}let Ae=new Set;if(B.forEach(({isStable:d,references:h},v)=>{d&&Ae.add(v),h.forEach(O=>{O.writeExpr&&Se(O.writeExpr,v)})}),ie.size>0)return;if(!A){let d=null;if(B.forEach(({isStable:h,references:v},O)=>{d||v.forEach(F=>{if(d)return;let P=F.identifier;if(!p.has(P))return;let D=F.from;for(;D.type!=="function";)D=D.upper;D.block===u&&(d=O)})}),d){let{suggestedDependencies:h}=Qe({dependencies:B,declaredDependencies:[],stableDependencies:Ae,externalDependencies:new Set,isEffect:!0});s({node:b,message:`React Hook ${g} contains a call to '${d}'. Without a list of dependencies, this can lead to an infinite chain of updates. To fix this, pass [`+h.join(", ")+`] as a second argument to the ${g} Hook.`,suggest:[{desc:`Add dependencies array: [${h.join(", ")}]`,fix(v){return v.insertTextAfter(u,`, [${h.join(", ")}]`)}}]})}return}let Pe=[],Fe=new Set;A.type!=="ArrayExpression"?s({node:A,message:`React Hook ${r(b)} was passed a dependency list that is not an array literal. This means we can't statically verify whether you've passed the correct dependencies.`}):A.elements.forEach(d=>{if(d===null)return;if(d.type==="SpreadElement"){s({node:d,message:`React Hook ${r(b)} has a spread element in its dependency array. This means we can't statically verify whether you've passed the correct dependencies.`});return}T.has(d)&&s({node:d,message:`Functions returned from \`useEffectEvent\` must not be included in the dependency array. Remove \`${r(d)}\` from the list.`,suggest:[{desc:`Remove the dependency \`${r(d)}\``,fix(F){return F.removeRange(d.range)}}]});let h;try{h=he(d,ye)}catch(F){if(/Unsupported node type/.test(F.message)){d.type==="Literal"?B.has(d.value)?s({node:d,message:`The ${d.raw} literal is not a valid dependency because it never changes. Did you mean to include ${d.value} in the array instead?`}):s({node:d,message:`The ${d.raw} literal is not a valid dependency because it never changes. You can safely remove it.`}):s({node:d,message:`React Hook ${r(b)} has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked.`});return}else throw F}let v=d;for(;v.type==="MemberExpression"||v.type==="OptionalMemberExpression"||v.type==="ChainExpression";)v=v.object||v.expression.object;let O=!R.through.some(F=>F.identifier===v);Pe.push({key:h,node:d}),O||Fe.add(h)});let{suggestedDependencies:Jn,unnecessaryDependencies:Me,missingDependencies:xe,duplicateDependencies:Dt}=Qe({dependencies:B,declaredDependencies:Pe,stableDependencies:Ae,externalDependencies:Fe,isEffect:m}),De=Jn;if(Dt.size+xe.size+Me.size===0){if(t)return;dr({declaredDependencies:Pe,declaredDependenciesNode:A,componentScope:R,scope:S}).forEach(({construction:h,isUsedOutsideOfHook:v,depType:O})=>{let F=O==="function"?"useCallback":"useMemo",P=O==="function"?"definition":"initialization",j=`wrap the ${P} of '${h.name.name}' in its own ${F}() Hook.`,D=v?`To fix this, ${j}`:`Move it inside the ${g} callback. Alternatively, ${j}`,le=O==="conditional"||O==="logical expression"?"could make":"makes",Te=`The '${h.name.name}' ${O} ${le} the dependencies of ${g} Hook (at line ${A.loc.start.line}) change on every render. ${D}`,Lt;v&&h.type==="Variable"&&O==="function"&&(Lt=[{desc:`Wrap the ${P} of '${h.name.name}' in its own ${F}() Hook.`,fix(_t){let[Xn,Gn]=F==="useMemo"?["useMemo(() => { return ","; })"]:["useCallback(",")"];return[_t.insertTextBefore(h.node.init,Xn),_t.insertTextAfter(h.node.init,Gn)]}}]),s({node:h.node,message:Te,suggest:Lt})});return}!m&&xe.size>0&&(De=Qe({dependencies:B,declaredDependencies:[],stableDependencies:Ae,externalDependencies:Fe,isEffect:m}).suggestedDependencies);function Bn(){if(Pe.length===0)return!0;let d=Pe.map(v=>v.key),h=d.slice().sort();return d.join(",")===h.join(",")}Bn()&&De.sort();function qe(d){let h=d.split("."),v="";for(let O=0;O<h.length;O++){if(O!==0){let F=h.slice(0,O+1).join("."),P=ye.get(F)===!0;v+=P?"?.":"."}v+=h[O]}return v}function Je(d,h,v,O){return d.size===0?null:(d.size>1?"":h+" ")+v+" "+(d.size>1?"dependencies":"dependency")+": "+gr(Array.from(d).sort().map(F=>"'"+qe(F)+"'"))+`. Either ${O} ${d.size>1?"them":"it"} or remove the dependency array.`}let fe="";if(Me.size>0){let d=null;if(Array.from(Me.keys()).forEach(h=>{d===null&&h.endsWith(".current")&&(d=h)}),d!==null)fe=` Mutable values like '${d}' aren't valid dependencies because mutating them doesn't re-render the component.`;else if(Fe.size>0){let h=Array.from(Fe)[0];S.set.has(h)||(fe=` Outer scope values like '${h}' aren't valid dependencies because mutating them doesn't re-render the component.`)}}if(!fe&&xe.has("props")){let d=B.get("props");if(d==null)return;let h=d.references;if(!Array.isArray(h))return;let v=!0;for(let O=0;O<h.length;O++){let F=h[O],P=tt(R.block,F.identifier);if(!P){v=!1;break}let j=P.parent;if(j==null){v=!1;break}if(j.type!=="MemberExpression"&&j.type!=="OptionalMemberExpression"){v=!1;break}}v&&(fe=` However, 'props' will change when *any* prop changes, so the preferred fix is to destructure the 'props' object outside of the ${g} call and refer to those specific props inside ${r(b)}.`)}if(!fe&&xe.size>0){let d=null;xe.forEach(h=>{if(d)return;let v=R.set.get(h),O=B.get(h);if(O.references[0].resolved!==v)return;let F=v.defs[0];if(F==null||F.name==null||F.type!=="Parameter")return;let P=!1,j;for(let D=0;D<O.references.length;D++)if(j=O.references[D].identifier,j!=null&&j.parent!=null&&(j.parent.type==="CallExpression"||j.parent.type==="OptionalCallExpression")&&j.parent.callee===j){P=!0;break}P&&(d=h)}),d!==null&&(fe=` If '${d}' changes too often, find the parent component that defines it and wrap that definition in useCallback.`)}if(!fe&&xe.size>0){let d=null;if(xe.forEach(h=>{if(d!==null)return;let O=B.get(h).references,F,P;for(let j=0;j<O.length;j++){for(F=O[j].identifier,P=F.parent;P!=null&&P!==R.block;){if(P.type==="CallExpression"){let D=p.get(P.callee);if(D!=null){if(D.name===h)d={missingDep:h,setter:P.callee.name,form:"updater"};else if(c.has(F))d={missingDep:h,setter:P.callee.name,form:"reducer"};else{let le=O[j].resolved;if(le!=null){let Te=le.defs[0];Te!=null&&Te.type==="Parameter"&&(d={missingDep:h,setter:P.callee.name,form:"inlineReducer"})}}break}}P=P.parent}if(d!==null)break}}),d!==null)switch(d.form){case"reducer":fe=` You can also replace multiple useState variables with useReducer if '${d.setter}' needs the current value of '${d.missingDep}'.`;break;case"inlineReducer":fe=` If '${d.setter}' needs the current value of '${d.missingDep}', you can also switch to useReducer instead of useState and read '${d.missingDep}' in the reducer.`;break;case"updater":fe=` You can also do a functional update '${d.setter}(${d.missingDep.slice(0,1)} => ...)' if you only need '${d.missingDep}' in the '${d.setter}' call.`;break;default:throw new Error("Unknown case.")}}s({node:A,message:`React Hook ${r(b)} has `+(Je(xe,"a","missing","include")||Je(Me,"an","unnecessary","exclude")||Je(Dt,"a","duplicate","omit"))+fe,suggest:[{desc:`Update the dependencies array to be: [${De.map(qe).join(", ")}]`,fix(d){return d.replaceText(A,`[${De.map(qe).join(", ")}]`)}}]})}function E(u){let A=yr(u.callee,i);if(A===-1)return;let b=u.arguments[A],g=u.callee,m=Kt(g).name,S=u.arguments[A+1],k=/Effect($|[^a-z])/g.test(m);if(!b){s({node:g,message:`React Hook ${m} requires an effect callback. Did you forget to pass a callback to the hook?`});return}if(!(t&&!k)){if(!S&&!k){(m==="useMemo"||m==="useCallback")&&s({node:g,message:`React Hook ${m} does nothing when called with only one argument. Did you forget to pass an array of dependencies?`});return}switch(b.type){case"FunctionExpression":case"ArrowFunctionExpression":x(b,S,g,m,k);return;case"Identifier":if(!S||S.elements&&S.elements.some(N=>N&&N.type==="Identifier"&&N.name===b.name))return;let R=n(u).set.get(b.name);if(R==null||R.defs==null)return;let C=R.defs[0];if(!C||!C.node||C.type!=="Variable"&&C.type!=="FunctionName")break;switch(C.node.type){case"FunctionDeclaration":x(C.node,S,g,m,k);return;case"VariableDeclarator":let N=C.node.init;if(!N)break;switch(N.type){case"ArrowFunctionExpression":case"FunctionExpression":x(N,S,g,m,k);return}break}break;default:s({node:g,message:`React Hook ${m} received a function whose dependencies are unknown. Pass an inline function instead.`});return}s({node:g,message:`React Hook ${m} has a missing dependency: '${b.name}'. Either include it or remove the dependency array.`,suggest:[{desc:`Update the dependencies array to be: [${b.name}]`,fix(R){return R.replaceText(S,`[${b.name}]`)}}]})}}if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let u of e.sourceCode.getAllComments())if(mr.test(u.value))return t=!0,{CallExpression:A=>E(A,!0)}}return{CallExpression:u=>E(u)}}};function Qe({dependencies:e,declaredDependencies:t,stableDependencies:r,externalDependencies:n,isEffect:a}){let o=i();function i(){return{isUsed:!1,isSatisfiedRecursively:!1,isSubtreeUsed:!1,children:new Map}}e.forEach((x,E)=>{let u=s(o,E);u.isUsed=!0,l(o,E,A=>{A.isSubtreeUsed=!0})}),t.forEach(({key:x})=>{let E=s(o,x);E.isSatisfiedRecursively=!0}),r.forEach(x=>{let E=s(o,x);E.isSatisfiedRecursively=!0});function s(x,E){let u=E.split("."),A=x;for(let b of u){let g=A.children.get(b);g||(g=i(),A.children.set(b,g)),A=g}return A}function l(x,E,u){let A=E.split("."),b=x;for(let g of A){let m=b.children.get(g);if(!m)return;u(m),b=m}}let p=new Set,c=new Set;f(o,p,c,x=>x);function f(x,E,u,A){x.children.forEach((b,g)=>{let m=A(g);if(b.isSatisfiedRecursively){b.isSubtreeUsed&&u.add(m);return}if(b.isUsed){E.add(m);return}f(b,E,u,S=>m+"."+S)})}let y=[],T=new Set,I=new Set;return t.forEach(({key:x})=>{c.has(x)?y.indexOf(x)===-1?y.push(x):I.add(x):T.add(x)}),p.forEach(x=>{y.push(x)}),{suggestedDependencies:y,unnecessaryDependencies:T,duplicateDependencies:I,missingDependencies:p}}function Ce(e){switch(e.type){case"ObjectExpression":return"object";case"ArrayExpression":return"array";case"ArrowFunctionExpression":case"FunctionExpression":return"function";case"ClassExpression":return"class";case"ConditionalExpression":return Ce(e.consequent)!=null||Ce(e.alternate)!=null?"conditional":null;case"LogicalExpression":return Ce(e.left)!=null||Ce(e.right)!=null?"logical expression":null;case"JSXFragment":return"JSX fragment";case"JSXElement":return"JSX element";case"AssignmentExpression":return Ce(e.right)!=null?"assignment expression":null;case"NewExpression":return"object construction";case"Literal":return e.value instanceof RegExp?"regular expression":null;case"TypeCastExpression":return Ce(e.expression);case"TSAsExpression":return Ce(e.expression)}return null}function dr({declaredDependencies:e,declaredDependenciesNode:t,componentScope:r,scope:n}){let a=e.map(({key:i})=>{let s=r.variables.find(p=>p.name===i);if(s==null)return null;let l=s.defs[0];if(l==null)return null;if(l.type==="Variable"&&l.node.type==="VariableDeclarator"&&l.node.id.type==="Identifier"&&l.node.init!=null){let p=Ce(l.node.init);if(p!=null)return[s,p]}return l.type==="FunctionName"&&l.node.type==="FunctionDeclaration"?[s,"function"]:l.type==="ClassName"&&l.node.type==="ClassDeclaration"?[s,"class"]:null}).filter(Boolean);function o(i){let s=!1;for(let l=0;l<i.references.length;l++){let p=i.references[l];if(p.writeExpr){if(s)return!0;s=!0;continue}let c=p.from;for(;c!==n&&c!=null;)c=c.upper;if(c!==n&&!Zt(t,p.identifier))return!0}return!1}return a.map(([i,s])=>({construction:i.defs[0],depType:s,isUsedOutsideOfHook:o(i)}))}function Gt(e){return(e.parent.type==="MemberExpression"||e.parent.type==="OptionalMemberExpression")&&e.parent.object===e&&e.parent.property.name!=="current"&&!e.parent.computed&&!(e.parent.parent!=null&&(e.parent.parent.type==="CallExpression"||e.parent.parent.type==="OptionalCallExpression")&&e.parent.parent.callee===e.parent)?Gt(e.parent):e.type==="MemberExpression"&&e.parent&&e.parent.type==="AssignmentExpression"&&e.parent.left===e?e.object:e}function et(e,t,r){t&&(e.optional?t.has(r)||t.set(r,!0):t.has(r)||t.set(r,!1))}function he(e,t){if(e.type==="Identifier"||e.type==="JSXIdentifier"){let r=e.name;return t&&t.set(r,!1),r}else if(e.type==="MemberExpression"&&!e.computed){let r=he(e.object,t),n=he(e.property,null),a=`${r}.${n}`;return et(e,t,a),a}else if(e.type==="OptionalMemberExpression"&&!e.computed){let r=he(e.object,t),n=he(e.property,null),a=`${r}.${n}`;return et(e,t,a),a}else if(e.type==="ChainExpression"&&!e.computed){let r=e.expression;if(r.type==="CallExpression")throw new Error(`Unsupported node type: ${r.type}`);let n=he(r.object,t),a=he(r.property,null),o=`${n}.${a}`;return et(r,t,o),o}else throw new Error(`Unsupported node type: ${e.type}`)}function Kt(e,t){return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.object.name==="React"&&e.property.type==="Identifier"&&!e.computed?e.property:e}function yr(e,t){let r=Kt(e);if(r.type!=="Identifier")return-1;switch(r.name){case"useEffect":case"useLayoutEffect":case"useCallback":case"useMemo":return 0;case"useImperativeHandle":return 1;default:if(r===e&&t&&t.additionalHooks){let n;try{n=he(r,null)}catch(a){if(/Unsupported node type/.test(a.message))return 0;throw a}return t.additionalHooks.test(n)?0:-1}else return-1}}function tt(e,t){let r=[e],n=null;for(;r.length;){if(n=r.shift(),Sr(n,t))return n;if(Zt(n,t))for(let[a,o]of Object.entries(n))a!=="parent"&&(Bt(o)?(o.parent=n,r.push(o)):Array.isArray(o)&&o.forEach(i=>{Bt(i)&&(i.parent=n,r.push(i))}))}return null}function gr(e){let t="";for(let r=0;r<e.length;r++)t+=e[r],r===0&&e.length===2?t+=" and ":r===e.length-2&&e.length>2?t+=", and ":r<e.length-1&&(t+=", ");return t}function Bt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function Sr(e,t){return(e.type==="Identifier"||e.type==="JSXIdentifier")&&e.type===t.type&&e.name===t.name&&e.range[0]===t.range[0]&&e.range[1]===t.range[1]}function Zt(e,t){return e.range[0]<=t.range[0]&&e.range[1]>=t.range[1]}function Tr(e){return!1}import{AST_NODE_TYPES as _e,ESLintUtils as en}from"@typescript-eslint/utils";import se from"typescript";var hr=en.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Qt="improved-no-unnecessary-condition",Er=z({}),br=["string","number","bigint","boolean","symbol","undefined","object","function","never"],xr=new Set(br),nt={name:Qt,rule:hr({name:Qt,meta:{type:"suggestion",docs:{description:"Extends checks of `no-unnecessary-condition` rule"},messages:{unnecessaryTypeofCondition:'This condition is unnecessary. The type of "{{name}}" is always "{{type}}".',alwaysFalseTypeofCondition:'This condition will always be false. The type of "{{name}}" is "{{actualType}}" so the condition has no overlap with "{{conditionType}}".'},schema:[Er]},defaultOptions:[{}],create(e){let t=en.getParserServices(e,!0),r=t.program?.getTypeChecker();if(!r||!t.program)throw new Error("TypeScript services or program not available");function n(s){return s.type===_e.UnaryExpression&&s.operator==="typeof"}function a(s){return s.flags&se.TypeFlags.Any||s.flags&se.TypeFlags.Unknown?null:s.flags&se.TypeFlags.StringLike?["string"]:s.flags&se.TypeFlags.NumberLike?["number"]:s.flags&se.TypeFlags.BigIntLike?["bigint"]:s.flags&se.TypeFlags.BooleanLike?["boolean"]:s.flags&se.TypeFlags.ESSymbolLike?["symbol"]:s.flags&se.TypeFlags.Undefined||s.flags&se.TypeFlags.Void?["undefined"]:s.flags&se.TypeFlags.Null?["object"]:s.getCallSignatures().length>0?["function"]:s.flags&se.TypeFlags.Object?s.getProperties().length===0?["string","number","bigint","boolean","symbol","object","function"]:["object"]:s.flags&se.TypeFlags.NonPrimitive?["object"]:s.flags&se.TypeFlags.Never?["never"]:null}function o(s){if(!r)return null;let l=t.esTreeNodeToTSNodeMap.get(s),p=r.getTypeAtLocation(l.expression);if(p.flags&se.TypeFlags.Any||p.flags&se.TypeFlags.Unknown)return null;let c=[];if(p.isUnion()){for(let y of p.types){let T=a(y);if(T)c.push(...T);else return null}return c}let f=a(p);return f?(c.push(...f),c):null}function i(s){if(!(s.operator==="==="||s.operator==="!=="))return;let p=null,c=null;if(n(s.left)?(p=s.left,c=s.right.type===_e.Literal&&typeof s.right.value=="string"?s.right.value:null):n(s.right)&&(p=s.right,c=s.left.type===_e.Literal&&typeof s.left.value=="string"?s.left.value:null),!p||!c||!Ir(c,xr))return;let f=o(p);if(!f)return;let y=s.operator==="!==",T=f.includes(c);f.length===1?T&&!y?e.report({node:s,messageId:"unnecessaryTypeofCondition",data:{name:ve(p,e),type:c}}):!T&&y?e.report({node:s,messageId:"unnecessaryTypeofCondition",data:{name:ve(p,e),type:Array.from(f)[0]}}):!T&&!y?e.report({node:s,messageId:"alwaysFalseTypeofCondition",data:{name:ve(p,e),actualType:Le(f),conditionType:c}}):T&&y&&e.report({node:s,messageId:"alwaysFalseTypeofCondition",data:{name:ve(p,e),actualType:Le(f),conditionType:c}}):!T&&!y?e.report({node:s,messageId:"alwaysFalseTypeofCondition",data:{name:ve(p,e),actualType:Le(f),conditionType:c}}):!T&&y&&e.report({node:s,messageId:"unnecessaryTypeofCondition",data:{name:ve(p,e),type:Le(f)}})}return{BinaryExpression:i}}})};function Le(e){return Array.from(new Set(e)).join(" | ")||"never"}function ve(e,t){let r=e.argument;return r.type===_e.Identifier?r.name:t.sourceCode.getText(r)}function Ir(e,t){return t.has(e)}import{AST_NODE_TYPES as Cr,ESLintUtils as wr}from"@typescript-eslint/utils";var Ar=wr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),tn="no-call-with-explicit-generics",Rr=z({functions:Q(V())}),vr=Ar({name:tn,meta:{type:"problem",docs:{description:"Enforce calling configured functions with inferred generics only"},messages:{noExplicitGenerics:"Function '{{ functionName }}' should be called with inferred generics (remove the explicit type parameters)"},schema:[Rr]},defaultOptions:[{functions:[]}],create(e,[t]){let r=new Set(t.functions);return{CallExpression(n){let{callee:a}=n;a.type===Cr.Identifier&&r.has(a.name)&&n.typeArguments&&e.report({node:n,messageId:"noExplicitGenerics",data:{functionName:a.name}})}}}}),rt={name:tn,rule:vr};import{AST_NODE_TYPES as $e,ESLintUtils as kr}from"@typescript-eslint/utils";var Or=kr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),nn="no-call-with-inferred-generics",Pr=Or({name:nn,meta:{type:"problem",docs:{description:"Disable calling configured functions with infered generics"},messages:{missingGenericDeclaration:"Function '{{ functionName }}' should be called with at least {{ minGenerics }} generic(s) (ex: `fn<Generic>()`) defined",anyUsedInGenerics:"Function '{{ functionName }}' should not be called with 'any' in generics"},schema:[{type:"object",properties:{functions:{type:"array",items:{type:"object",properties:{name:{type:"string"},minGenerics:{type:"number"},allowAny:{type:"boolean"},disallowTypes:{type:"array",items:{type:"string"}}},required:["name"]}},anyAliases:{type:"array",items:{type:"string"}}},required:["functions"]}]},defaultOptions:[{functions:[]}],create(e,[t]){let r=new Map(t.functions.map(n=>[n.name,n]));return{CallExpression(n){let{callee:a}=n;if(a.type!==$e.Identifier)return;let o=r.get(a.name);if(!o)return;let{minGenerics:i=1,allowAny:s,disallowTypes:l=t.disallowTypes}=o;(n.typeArguments?.params.length||0)<(i||0)&&e.report({node:n,messageId:"missingGenericDeclaration",data:{functionName:a.name,minGenerics:i||0}}),!(s&&!l)&&n.typeArguments?.params?.some(c=>!s&&c.type===$e.TSAnyKeyword||l&&c.type===$e.TSTypeReference&&c.typeName.type===$e.Identifier&&l.includes(c.typeName.name))&&e.report({node:n,messageId:"anyUsedInGenerics",data:{functionName:a.name}})}}}}),it={name:nn,rule:Pr};import{ESLintUtils as Fr}from"@typescript-eslint/utils";var Nr=Fr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),sn="no-commented-out-code",jr=["function ","class ","interface ","type ","enum ","namespace ","import ","export ","const ","let ","var ","return ","throw ","break","continue","try {","catch (","finally {","async ","await ","case ","switch (","while (","for (","default:"],X={returnStatement:/^\s*return\s+/,stringAssignment:/\w=("|'|`)/,objectPropertyWithQuotes:/\w+:\s*('|"|`)/,computedPropertyAssignment:/\[['"][^'"]*['"]\]:\s*('|"|`|[^'"`\s])/,kebabCaseProperty:/\w+-\w+:/,snakeCaseProperty:/\w+_\w+:/,ternaryOperator:/\?\s+\w/,colonWithWord:/:\s+\w/,quotedString:/^\s*('|"|`)[^'"]*('|"|`),?\s*$/,numberWithComma:/^\s*\d+[,}]/,arrayWithComma:/^\s*\[[^\]]*\][,}]/,objectWithComma:/^\s*\{[^}]*\}[,}]/,methodCall:/\.\w+\(/,arrayAccess:/\[\w+\]/,quotedPropertyKey:/^\s*(['"`]).+?\1\s*:/,jsxSelfClosing:/^<[A-Z]\w*(\s|>|\/)/,jsxElement:/^<[a-z]+(\s|>|\/)/,jsxOpeningTag:/<[A-Z]\w*(\s.*)?>/,jsxClosingTag:/<\/[A-Z]\w*>/,htmlOpeningTag:/<[a-z]+(\s.*)?>/,htmlClosingTag:/<\/[a-z]+>/,colonDescriptiveComment:/^[a-zA-Z]+(\s+[a-zA-Z]+)*:\s+[a-zA-Z]+\s+[a-zA-Z][^{=,'"]*$/,jsdocComment:/^\s*[*\s]*$/},Mr=[") {","return;",X.returnStatement,"if (","else {","else if (","/>","</","< ","},",": {"," } = ","={",X.stringAssignment,");",X.objectPropertyWithQuotes,X.computedPropertyAssignment,X.kebabCaseProperty,X.snakeCaseProperty,"&&","||","()",X.ternaryOperator,X.colonWithWord,X.quotedString,X.numberWithComma,X.arrayWithComma,X.objectWithComma,X.methodCall,X.arrayAccess,"?.(","??","=>",X.quotedPropertyKey],Dr=["/>","</",X.jsxSelfClosing,X.jsxElement,X.jsxOpeningTag,X.jsxClosingTag,X.htmlOpeningTag,X.htmlClosingTag],rn=["INFO:","TODO:","DOCS:","FIX:","FIXME:","HACK:","NOTE:","WARNING:","WARN:","BUG:","ISSUE:","TEMP:","TEMPORARY:","XXX:","REVIEW:","eslint"],Lr=Nr({name:sn,meta:{type:"problem",docs:{description:"Disallow commented code"},messages:{commentedOutCode:"Commented code is not allowed. Detected pattern: `{{ wrongPattern }}` Use a comment starting with one of these prefixes if you want to keep this code commented out: {{ allowedPrefixes }}"},schema:[]},defaultOptions:[],create(e){function t(n,a){if(n.startsWith("/"))return!1;let o=n.trimStart();if(n.startsWith("*")||o.startsWith("eslint-disable")||n.includes("@deprecated")||n.includes("@example")||n.includes("@param")||n.includes("@returns")||n.includes("@throws")||n.includes("typescript-eslint")||n.includes("@ts-")||n.includes("prettier-ignore")||X.jsdocComment.test(n))return!1;for(let i of rn)if(o.startsWith(i))return!1;if(n.includes("https://")||o.includes(":")&&X.colonDescriptiveComment.test(o.trim()))return!1;if(a==="Block"){for(let i of Dr)if(typeof i=="string"){if(n.includes(i))return{wrongPattern:i}}else if(i.test(n))return{wrongPattern:`regex(${i.toString()})`};return!1}for(let i of jr)if(o.startsWith(i))return{wrongPattern:i};for(let i of Mr)if(typeof i=="string"){if(n.includes(i))return{wrongPattern:i}}else if(i.test(n))return{wrongPattern:`regex(${i.toString()})`};return!1}function r(n,a){let o=n,i=o.trim();if(i.startsWith("`")&&(i.endsWith("`,")||i.endsWith("`;")||i.endsWith("`")))return o;if(a==="Block"&&o.includes("```")){let p=o.split(/```[\s\S]*?```/g);p.some(f=>/[a-zA-Z0-9]/.test(f))&&(o=p.join(""))}if(!o.includes("`"))return o;let s=o.split(/`[^`]*`/g);return s.some(p=>/[a-zA-Z0-9]/.test(p))?s.join(""):o}return{Program(){let a=e.sourceCode.getAllComments();for(let o of a){let i=r(o.value,o.type),s=t(i,o.type);s&&e.report({node:o,messageId:"commentedOutCode",data:{wrongPattern:s.wrongPattern,allowedPrefixes:rn.join(", ")}})}}}}}),st={name:sn,rule:Lr};import{ESLintUtils as _r,TSESTree as $r}from"@typescript-eslint/utils";var Ur=_r.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),on="no-default-export",Wr=Ur({name:on,meta:{type:"problem",docs:{description:"Disallow default exports"},schema:[],messages:{noDefaultExport:"Default exports are not allowed, use named exports instead."}},defaultOptions:[],create(e){return{ExportDefaultDeclaration(t){e.report({node:t,messageId:"noDefaultExport"})},ExportNamedDeclaration(t){for(let r of t.specifiers)r.exported.type===$r.AST_NODE_TYPES.Identifier&&r.exported.name==="default"&&e.report({node:t,messageId:"noDefaultExport"})}}}}),ot={name:on,rule:Wr};import{ESLintUtils as Vr}from"@typescript-eslint/utils";var zr=Vr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),an="no-leaked-text-in-jsx",Hr=[",",";","[","]","(",")"],Yr=zr({name:an,meta:{type:"problem",docs:{description:"Prevents leaking of text in JSX that should be wrapped in an expression container"},messages:{leakedTextInJSX:'Text "{{ text }}" should be wrapped in a JSX expression container.'},schema:[],fixable:"code"},defaultOptions:[],create(e){return{JSXText(t){let r=t.value.trim();if(!r)return;let n="";Hr.includes(r)?n=r:r.includes("&&")?n="&&":r.includes("||")?n="||":r.endsWith("? (")&&(n="? ("),n&&e.report({node:t,messageId:"leakedTextInJSX",data:{text:n}})}}}}),at={name:an,rule:Yr};import{AST_NODE_TYPES as Ne,ESLintUtils as qr}from"@typescript-eslint/utils";var Jr=qr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),pn="no-non-camel-case-functions",Br=/^(\$?[a-z][a-zA-Z0-9]*)$/;function ln(e){if(e.typeName.type!==Ne.TSQualifiedName)return!1;let{left:t,right:r}=e.typeName;return t.type===Ne.Identifier&&t.name==="JSX"&&r.name==="Element"}var Xr=Jr({name:pn,meta:{type:"suggestion",docs:{description:"Enforce camelCase naming convention for function declarations"},schema:[],messages:{nonCamelCaseFunction:'Function name "{{functionName}}" should be in camelCase format. If this fn is a React component and can\'t use the `FC` type, add a explicit "JSX.Element" return type to it'}},defaultOptions:[],create(e){return{FunctionDeclaration(t){if(t.id&&!Br.test(t.id.name)){let r=t.returnType?.typeAnnotation;if(r&&(r.type===Ne.TSTypeReference?ln(r):r.type===Ne.TSUnionType&&r.types.some(a=>a.type===Ne.TSTypeReference&&ln(a))))return;e.report({node:t.id,messageId:"nonCamelCaseFunction",data:{functionName:t.id.name}})}}}}}),lt={name:pn,rule:Xr};import{ESLintUtils as Gr,TSESTree as H}from"@typescript-eslint/utils";import{AST_NODE_TYPES as cn}from"@typescript-eslint/utils";function ke(e,t,r=1/0){if(r!==0&&e.parent)return e.type===t?e:ke(e.parent,t,r===1/0?r:r-1)}function*pt(e){yield e,e.parent&&(yield*pt(e.parent))}function ct(e,t){for(let r of e){let n=t(r);if(n!=null&&n!==!1)return n}}function un(e,t,r){let a=r.getDeclaredVariables(e).find(o=>o.name===t||o.identifiers[0]?.parent.type===cn.Property&&o.identifiers[0]?.parent.key.type===cn.Identifier&&o.identifiers[0]?.parent.key.name===t);return a?a.references.filter(o=>!o.init):[]}var Kr=Gr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),fn="no-optional-root-props",Zr=Kr({name:fn,meta:{type:"problem",docs:{description:"Prevents usage of optional properties at the root of a type if that type is a local type alias or interface referenced only once"},messages:{optionalNotAllowed:'Optional property "{{ propertyName }}" is not allowed on a local type used only once. Use `prop: undefined | ...` instead.',suggestion:"Use `prop: undefined | ...` instead."},hasSuggestions:!0,schema:[]},defaultOptions:[],create(e){function t(n){let o=e.sourceCode.getDeclaredVariables(n)[0];if(!o||o.references.length!==1)return!1;let i=o.references[0];if(!i)return!1;for(let s of pt(i.identifier)){if("returnType"in s||s.type===H.AST_NODE_TYPES.ExportNamedDeclaration)return!1;let l=s.parent;if(!l)return!1;if(l.type===H.AST_NODE_TYPES.TSTypeParameterInstantiation&&l.parent.type===H.AST_NODE_TYPES.TSTypeReference&&l.parent.typeName.type===H.AST_NODE_TYPES.Identifier&&l.parent.typeName.name==="FC"){let c=ke(l.parent.parent,H.AST_NODE_TYPES.VariableDeclaration,4);if(!c)return!1;let f=Ue(c,e.sourceCode);return f?!(f.parent.type===H.AST_NODE_TYPES.CallExpression&&f.parent.callee.type===H.AST_NODE_TYPES.Identifier&&f.parent.callee.name==="memo"):!1}if(s.type===H.AST_NODE_TYPES.AssignmentPattern)return!1;if(l.type===H.AST_NODE_TYPES.ArrowFunctionExpression){let p=ke(l,H.AST_NODE_TYPES.VariableDeclaration);return p?!!Ue(p,e.sourceCode):!1}if(l.type===H.AST_NODE_TYPES.FunctionDeclaration)return!!Ue(l,e.sourceCode)}return!1}function r(n){n.key.type!==H.AST_NODE_TYPES.Identifier||!n.optional||e.report({node:n.key,messageId:"optionalNotAllowed",data:{propertyName:n.key.name},suggest:[{messageId:"suggestion",fix:a=>{let o=ke(n,H.AST_NODE_TYPES.TSPropertySignature);if(!o)return null;let i=e.sourceCode.getText(o);return a.replaceText(o,i.replace("?:",": undefined |"))}}]})}return{TSTypeAliasDeclaration(n){if(n.typeAnnotation.type===H.AST_NODE_TYPES.TSTypeLiteral&&!(We(n)||!t(n)))for(let a of n.typeAnnotation.members)a.type===H.AST_NODE_TYPES.TSPropertySignature&&r(a)},TSInterfaceDeclaration(n){if(!(We(n)||!t(n)))for(let a of n.body.body)a.type===H.AST_NODE_TYPES.TSPropertySignature&&r(a)},TSTypeReference(n){if(n.typeName.type!==H.AST_NODE_TYPES.Identifier||n.typeName.name!=="FC"||!n.typeArguments?.params[0])return;let a=n.typeArguments.params[0];if(a.type!==H.AST_NODE_TYPES.TSTypeLiteral)return;let o=ke(n.parent,H.AST_NODE_TYPES.VariableDeclaration,4);if(!o)return;let i=Ue(o,e.sourceCode);if(!(!i||i.parent.type===H.AST_NODE_TYPES.CallExpression&&i.parent.callee.type===H.AST_NODE_TYPES.Identifier&&i.parent.callee.name==="memo"))for(let l of a.members)l.type===H.AST_NODE_TYPES.TSPropertySignature&&r(l)}}}});function We(e){return e?e.parent?.type===H.AST_NODE_TYPES.ExportNamedDeclaration||e.parent?.type===H.AST_NODE_TYPES.ExportDefaultDeclaration:!1}function Ue(e,t){if(We(e))return;let r;if(e.type===H.AST_NODE_TYPES.VariableDeclaration){if(e.declarations.length!==1)return;e.declarations[0].id.type===H.AST_NODE_TYPES.Identifier&&(r=e.declarations[0].id)}else{if(!e.id)return;r=e.id}if(!r)return;let n=t.getScope(e);e.type===H.AST_NODE_TYPES.FunctionDeclaration&&n.upper&&(n=n.upper);let a=n.variables.find(i=>i.identifiers.includes(r));if(!a)return;let o=a.references.filter(i=>i.identifier!==r);if(!(o.length!==1||!o[0])&&!We(o[0].identifier.parent.parent))return o[0].identifier}var ut={name:fn,rule:Zr};import{ESLintUtils as Qr}from"@typescript-eslint/utils";import ft from"node:path";var ei=Qr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),mn="no-relative-imports",ti=z({find:V(),replacement:V()}),ni=z({aliases:Q(ti),rootDir:_(V()),allowNotFoundAliases:_(Re()),_dev_simulateFileName:_(V())}),ri=ei({name:mn,meta:{type:"problem",fixable:"code",docs:{description:"Prevent relative imports and auto-fix them using configured aliases"},messages:{noRelativeImports:"Relative imports are not allowed. Use one of the valid aliases in tsconfig.json instead.",noRelativeImportsWithAlias:'Relative imports are not allowed. Use the "{{ alias }}" alias instead.'},schema:[ni]},defaultOptions:[{aliases:[],rootDir:void 0}],create(e,[t]){let r=t._dev_simulateFileName??e.filename;function n(i){return i.startsWith(".")||i.startsWith("..")}function a(i,s){let l=ft.dirname(s);return ft.resolve(l,i)}function o(i){let s=t.rootDir??process.cwd(),l=ft.relative(s,i);if(l.startsWith("."))return null;l.startsWith("/")||(l=`/${l}`);for(let{find:p,replacement:c}of t.aliases)if(l.startsWith(c)){let f=l.replace(c,p);return{alias:p,newPath:f}}return null}return{ImportDeclaration(i){let s=i.source.value;if(!n(s))return;let l=a(s,r),p=o(l);!p&&t.allowNotFoundAliases||e.report({node:i,messageId:p?"noRelativeImportsWithAlias":"noRelativeImports",data:{alias:p?.alias},fix:p?c=>c.replaceText(i.source,`'${p.newPath}'`):void 0})}}}}),mt={name:mn,rule:ri};import{AST_NODE_TYPES as Ve}from"@typescript-eslint/utils";import*as we from"zod/v4";var ii=we.object({alternativeMsgs:we.object({inArrayFind:we.string().optional(),inArrayFilter:we.string().optional()}).optional(),__dev_simulateFileName:we.string().optional()});function si(e){return e.typeAnnotation.type!==Ve.TSTypePredicate?!1:e.typeAnnotation.asserts===!1}function oi(e){return/\.(typeGuards|type-guards)\.(ts|tsx)$/.test(e)}function ai(e){let t=e.parent;for(;t;){if(t.type===Ve.CallExpression&&t.callee.type===Ve.MemberExpression&&t.callee.property.type===Ve.Identifier){let r=t.callee.property.name;if(r==="filter"||r==="find")return{method:r}}t=t.parent}return null}var dt=G({name:"no-type-guards",meta:{type:"problem",docs:{description:"Disallow type guards unless in *.typeGuards.(ts|tsx) or *.type-guards.(ts|tsx) files"},messages:{typeGuardNotAllowed:"Type guards are only allowed in *.typeGuards.(ts|tsx) or *.type-guards.(ts|tsx) files",useFilterWithTypeCheck:"{{message}}",useFindWithTypeCheck:"{{message}}"},schema:[Ie(ii)],hasSuggestions:!0},defaultOptions:[{}],create(e,[t]){let r=t.__dev_simulateFileName??e.filename;if(oi(r))return{};function n(a){if(!si(a))return;let o=ai(a),i=[];if(t.alternativeMsgs&&o){let s=o.method==="filter"?t.alternativeMsgs.inArrayFilter:t.alternativeMsgs.inArrayFind;if(s){let l=o.method==="filter"?"useFilterWithTypeCheck":"useFindWithTypeCheck";e.report({node:a,messageId:l,data:{message:s}});return}}e.report({node:a,messageId:"typeGuardNotAllowed"})}return{"FunctionDeclaration > :matches(TSTypeAnnotation)":n,"ArrowFunctionExpression > :matches(TSTypeAnnotation)":n,"MethodDefinition > FunctionExpression > :matches(TSTypeAnnotation)":n}}});import{AST_NODE_TYPES as Oe}from"@typescript-eslint/utils";var li="no-unnecessary-async-on-jsx-props";function pi(e){if(e.body.type!==Oe.BlockStatement)return!1;let t=e.body.body;if(t.length!==1)return!1;let r=t[0];return!r||r.type!==Oe.ExpressionStatement?!1:r.expression.type===Oe.AwaitExpression}var yt=G({name:li,meta:{type:"suggestion",fixable:"code",docs:{description:"Disallow unnecessary async/await in JSX props where a single await provides no benefit"},messages:{unnecessaryAsyncInJsxProp:"Unnecessary async/await in JSX prop. The single await expression provides no benefit here."},schema:[]},defaultOptions:[],create(e){function t(r){pi(r)&&e.report({node:r,messageId:"unnecessaryAsyncInJsxProp",fix(n){let a=e.sourceCode,o=[],i=a.getFirstToken(r,l=>l.value==="async");if(i){let l=a.getTokenAfter(i);l?o.push(n.replaceTextRange([i.range[0],l.range[0]],"")):o.push(n.remove(i))}function s(l){if(l.type===Oe.AwaitExpression){let p=a.getFirstToken(l);if(p&&p.value==="await"){let c=a.getTokenAfter(p);c?o.push(n.replaceTextRange([p.range[0],c.range[0]],"")):o.push(n.remove(p))}}if(l.type===Oe.BlockStatement)for(let p of l.body)s(p);else l.type===Oe.ExpressionStatement&&s(l.expression)}return s(r.body),o}})}return{"JSXAttribute ArrowFunctionExpression[async=true]":t,"JSXAttribute FunctionExpression[async=true]":t}}});import{AST_NODE_TYPES as je,ESLintUtils as yn}from"@typescript-eslint/utils";import*as gt from"typescript";var ci=yn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),dn="no-unnecessary-casting",ui=z({additionalCastFunctions:_(Q(z({name:V(),expectedType:$t(["string","number"])})))}),St={name:dn,rule:ci({name:dn,meta:{type:"suggestion",docs:{description:"Prevents unnecessary Number and String castings"},messages:{unnecessaryNumberCasting:"Unnecessary Number() casting on a value already of number type",unnecessaryStringCasting:"Unnecessary String() casting on a value already of string type",unnecessaryCustomCasting:"Unnecessary {{name}}() casting on a value already of {{type}} type"},schema:[ui],fixable:"code"},defaultOptions:[{}],create(e){let r=e.options[0].additionalCastFunctions||[],n=[{name:"Number",expectedType:"number"},{name:"String",expectedType:"string"},...r],a=yn.getParserServices(e,!0),o=a.program?.getTypeChecker();if(!o||!a.program)throw new Error("TypeScript services or program not available");function i(c,f){switch(c.type){case je.Literal:return f==="number"?typeof c.value=="number":typeof c.value=="string";case je.TemplateLiteral:return f==="string";case je.UnaryExpression:return f==="number"?c.operator==="+"||c.operator==="-"||c.operator==="~":!1;default:return!1}}function s(c,f){return f==="number"?!!(c.flags>.TypeFlags.NumberLike):!!(c.flags>.TypeFlags.StringLike)}function l(c,f){return y=>y.replaceText(c,e.sourceCode.getText(f))}function p(c){if(!o||c.arguments.length!==1)return;let f=c.arguments[0];if(!f||f.type===je.SpreadElement)return;let{callee:y}=c;if(y.type!==je.Identifier)return;let T=y.name,I=n.find(E=>E.name===T);if(!I)return;if(i(f,I.expectedType)||s(o.getTypeAtLocation(a.esTreeNodeToTSNodeMap.get(f)),I.expectedType)){let E,u;T==="Number"?E="unnecessaryNumberCasting":T==="String"?E="unnecessaryStringCasting":(E="unnecessaryCustomCasting",u={name:I.name,type:I.expectedType}),e.report({node:c,messageId:E,...u?{data:u}:{},fix:l(c,f)})}}return{CallExpression:p}}})};import{AST_NODE_TYPES as ze}from"@typescript-eslint/utils";import*as pe from"zod/v4";var fi=pe.object({methods:pe.union([pe.array(pe.string()),pe.literal("array")])}),Tt=G({name:"no-unnecessary-typing",meta:{type:"suggestion",docs:{description:"Prevents unnecessary explicit type annotations in callback parameters where TypeScript can infer the type"},messages:{unnecessaryTypeAnnotation:"Unnecessary type annotation. TypeScript can infer this type from context."},fixable:"code",schema:[pe.toJSONSchema(fi)]},defaultOptions:[{methods:"array"}],create(e,[t]){let r=t.methods,n=new Set(["find","filter","map","forEach","some","every","reduce","findIndex","sort"]);function a(s){return Array.isArray(r)?r.includes(s):n.has(s)}function o(s){let{callee:l}=s;if(l.type===ze.MemberExpression){let p=l.property;if(p.type===ze.Identifier)return p.name}return null}function i(s,l){if(s.type!==ze.Identifier||!s.typeAnnotation)return;let p=l.parent;if(p.type===ze.CallExpression){let c=o(p);c&&a(c)&&p.arguments.indexOf(l)===0&&e.report({node:s.typeAnnotation,messageId:"unnecessaryTypeAnnotation",fix(y){return y.remove(s.typeAnnotation)}})}}return{ArrowFunctionExpression(s){for(let l of s.params)i(l,s)},FunctionExpression(s){for(let l of s.params)i(l,s)}}}});import{AST_NODE_TYPES as ae}from"@typescript-eslint/utils";var ht=G({name:"no-unused-obj-props",meta:{type:"suggestion",docs:{description:"Disallow unused properties when it is safe to remove them"},messages:{unusedObjectProperty:'The object property "{{name}}" is not being used',unusedReturnObjectProperty:'The object property "{{name}}" returned by this function is not being used'},schema:[]},defaultOptions:[],create(e){return{VariableDeclarator(t){if(t.id.type===ae.ObjectPattern||!t.init||t.init.type!==ae.ObjectExpression||t.id.type===ae.Identifier&&t.id.typeAnnotation||t.parent.parent.type===ae.ExportNamedDeclaration)return;let r=new Map;for(let i of t.init.properties)i.type===ae.Property&&i.key.type===ae.Identifier&&r.set(i.key.name,i);if(r.size===0||t.id.type!==ae.Identifier)return;let n=mi(t,e.sourceCode);if(n.length===0)return;let a=t.init.properties.some(i=>i.type!==ae.Property?!1:i.value.type===ae.FunctionExpression),o=new Set;for(let i of n){if(i.identifier.parent.type!==ae.MemberExpression)return;let s=i.identifier.parent;if(s.object!==i.identifier)return;if(s.computed)if(s.property.type===ae.Literal&&typeof s.property.value=="string")o.add(s.property.value);else return;else{if(s.property.type!==ae.Identifier)return;o.add(s.property.name)}if(s.parent.type===ae.CallExpression&&a)return}for(let[i,s]of r)o.has(i)||e.report({node:s,messageId:"unusedObjectProperty",data:{name:i}})}}}});function mi(e,t){let r=t.getDeclaredVariables(e);if(r.length!==1)return[];let n=r[0];return n?n.references.filter(a=>a.identifier!==e.id):[]}import{AST_NODE_TYPES as q,ESLintUtils as di}from"@typescript-eslint/utils";var yi=z({selectors:Q(z({name:V(),selectorProp:_(V()),selectorArgPos:_(ge()),returnProp:_(V())}))}),gi=di.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),gn="no-unused-selected-values",Et={name:gn,rule:gi({name:gn,meta:{type:"suggestion",docs:{description:"Disallow unused values in selector objects"},messages:{unusedSelectedValue:'The selected value "{{name}}" is not being used'},schema:[yi]},defaultOptions:[{selectors:[]}],create(e,[t]){let{selectors:r=[]}=t,n=new Map(r.map(a=>[a.name,a]));return{VariableDeclarator(a){let o=null;if(a.init?.type===q.CallExpression&&(o=a.init),!o)return;let i=Ti(o);if(!i)return;let s=n.get(i);if(!s)return;let l=Si(o,s.selectorArgPos??0,s.selectorProp);if(!l)return;let p=hi(l);if(!p)return;let c=Sn(p.properties,void 0);if(!c)return;if(a.id.type===q.ObjectPattern){let T=Sn(a.id.properties,s.returnProp);if(!T)return;for(let[I,x]of c)T.has(I)||e.report({node:x,messageId:"unusedSelectedValue",data:{name:I}});return}if(a.id.type!==q.Identifier||s.returnProp)return;let f=Ei(a,e.sourceCode);if(f.length===0)return;let y=new Set;for(let T of f){if(T.identifier.parent.type!==q.MemberExpression)return;let I=T.identifier.parent.property;if(I.type!==q.Identifier)return;y.add(I.name)}for(let[T,I]of c)y.has(T)||e.report({node:I,messageId:"unusedSelectedValue",data:{name:T}})}}}})};function Si(e,t,r){let n=e.arguments[t];if(!n)return null;if(n.type===q.ArrowFunctionExpression||n.type===q.FunctionExpression)return n;if(r&&n.type===q.ObjectExpression){let a=n.properties.find(i=>i.type===q.Property&&i.key.type===q.Identifier&&i.key.name===r);if(a?.type!==q.Property)return null;let o=a.value;if(o.type===q.ArrowFunctionExpression||o.type===q.FunctionExpression)return o}return null}function Ti(e){return e.callee.type===q.Identifier?e.callee.name:e.callee.type===q.MemberExpression&&e.callee.property.type===q.Identifier?e.callee.property.name:null}function hi(e){if(e.body.type===q.ObjectExpression)return e.body;if(e.body.type===q.BlockStatement){let t=e.body.body.filter(r=>r.type===q.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==q.ObjectExpression?null:t[0].argument}return null}function Sn(e,t){let r=e;if(t){let a=e.find(o=>o.type===q.Property&&o.key.type===q.Identifier&&o.key.name===t);if(a?.type!==q.Property||a.value.type!==q.ObjectPattern)return null;r=a.value.properties}let n=new Map;for(let a of r){if(a.type!==q.Property||a.key.type!==q.Identifier)return null;n.set(a.key.name,a)}return n.size>0?n:null}function Ei(e,t){let r=t.getDeclaredVariables(e);if(r.length!==1)return[];let n=r[0];return n?n.references.filter(a=>a.identifier!==e.id):[]}import{AST_NODE_TYPES as Y}from"@typescript-eslint/utils";var bt=G({name:"no-unused-t-state-field",meta:{type:"suggestion",docs:{description:"Prevent declaring unused t-state fields"},messages:{unusedField:'Field "{{name}}" is not being used, you can safely remove it'},schema:[]},defaultOptions:[],create(e){if(!(e.filename.endsWith(".jsx")||e.filename.endsWith(".tsx")))return{};if(!e.sourceCode.ast.body.some(o=>o.type===Y.ImportDeclaration&&o.source.value==="t-state-form"))return{};let n=null,a=!1;return{CallExpression(o){if(a)return;if(!n){let s=bi(o);s&&(n=s);return}let i=xi(o,e.sourceCode);if(i){a=!0;for(let s of i)n.delete(s);if(n.size!==0)for(let[s,l]of n)e.report({node:l,messageId:"unusedField",data:{name:s}})}}}}});function bi(e){if(!(e.callee.type===Y.Identifier&&e.callee.name==="useForm"))return null;let r=e.arguments[0];if(!r||r.type!==Y.ObjectExpression)return null;let n=ct(r.properties,o=>o.type!==Y.Property||o.key.type!==Y.Identifier||o.key.name!=="initialConfig"?null:o.value.type===Y.ObjectExpression?o.value:o.value.type===Y.ArrowFunctionExpression||o.value.type===Y.FunctionExpression?Ii(o.value):null);if(!n)return null;let a=new Map;for(let o of n.properties)o.type===Y.Property&&o.key.type===Y.Identifier&&a.set(o.key.name,o);return a}function xi(e,t){if(!(e.callee.type===Y.Identifier&&e.callee.name==="useFormState")||e.parent.type!==Y.VariableDeclarator||e.parent.id.type!==Y.ObjectPattern||!ct(e.parent.id.properties,i=>i.type===Y.Property&&i.key.type===Y.Identifier&&i.key.name==="formFields"&&i))return null;let a=un(e.parent,"formFields",t),o=new Set;for(let{identifier:i}of a){if(i.type!==Y.Identifier||i.parent.type===Y.Property&&i.parent.parent.type===Y.ObjectExpression&&i.parent.parent.parent.type===Y.ReturnStatement||i.parent.type===Y.ReturnStatement)return null;if(i.parent.type===Y.MemberExpression){if(i.parent.object.type!==Y.Identifier||i.parent.property.type!==Y.Identifier)return null;o.add(i.parent.property.name)}}return o}function Ii(e){if(e.body.type===Y.ObjectExpression)return e.body;if(e.body.type===Y.BlockStatement){let t=e.body.body.filter(r=>r.type===Y.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==Y.ObjectExpression?null:t[0].argument}return null}import{AST_NODE_TYPES as U,ESLintUtils as Ci}from"@typescript-eslint/utils";var wi=Ci.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function Tn(e){let t=[];for(let r of e.members)r.type===U.TSPropertySignature&&r.key.type===U.Identifier&&t.push([r.key.name,r]);return t}function hn(e,...t){for(let r of t)e.set(...r);return e}var Ai=z({forceCheckOnFCPropTypesWithName:_(Q(V()))}),En="no-unused-type-props-in-args",xt=null,Ri=wi({name:En,meta:{type:"problem",docs:{description:"Disallow unused undestructured object type properties"},messages:{unusedObjectTypeProperty:"Object type property '{{ propertyName }}' is defined but never used",missingComponentParam:"Component has declared props but no props are used"},schema:[Ai],fixable:"code"},defaultOptions:[{}],create(e,[t]){let{forceCheckOnFCPropTypesWithName:r}=t;r&&!xt&&(xt=r.map(s=>new RegExp(s)));function n(s,l,p,c,f=!0){let y=p.name,T=e.sourceCode.getScope(l).references.find(E=>E.identifier.name===y)?.resolved,I=s&&xt?.some(E=>E.test(y));if(!T||!I&&T.references.filter(E=>E.isTypeReference).length>1)return;let x=T?.defs[0]?.node;if(!(f&&x?.parent?.type===U.ExportNamedDeclaration)){if(x?.type===U.TSTypeAliasDeclaration){a(s,l,c,x.typeAnnotation,!0);return}if(x?.type===U.TSInterfaceDeclaration){a(s,l,c,x.body,!0);return}}}function a(s,l,p,c,f){if(c.type===U.TSInterfaceBody){for(let y of c.body)y.type===U.TSPropertySignature&&y.key.type===U.Identifier&&p.set(y.key.name,y);return}if(c.type===U.TSTypeLiteral){hn(p,...Tn(c));return}if(c.type===U.TSIntersectionType){for(let y of c.types)a(s,l,p,y,!0);return}f||c.type===U.TSTypeReference&&c.typeName.type===U.Identifier&&n(s,l,c.typeName,p)}function o(s,l,p){for(let c of p)if(c.type==="ObjectPattern"&&c.typeAnnotation){let f=new Map;if(a(s,l,f,c.typeAnnotation.typeAnnotation,!1),f.size===0)continue;i(c,f)}else c.type===U.AssignmentPattern&&c.left.type===U.ObjectPattern&&o(s,l,[c.left])}function i(s,l){let p=[];if(s.properties.at(-1)?.type===U.RestElement)return;for(let T of s.properties)T.type===U.Property&&T.key.type===U.Identifier&&p.push(T.key.name);let f=[],y=[];for(let[T,I]of l)p.includes(T)||(y.push(T),f.push({node:I,messageId:"unusedObjectTypeProperty",data:{propertyName:T}}));for(let[T,I]of f.entries())e.report({...I,fix:T===f.length-1?x=>{let E=s.properties.at(-1),u=y.join(", ");return E?E?.type===U.RestElement?null:x.insertTextAfter(E,`, ${u}`):x.insertTextBeforeRange([s.range[0]+1,s.range[1]],`${u}`)}:void 0})}return{VariableDeclaration(s){let l=s.declarations[0];if(!l)return;let p=new Map,c=l.id.type===U.Identifier&&l.id.typeAnnotation?.typeAnnotation.type===U.TSTypeReference&&l.id.typeAnnotation.typeAnnotation.typeName.type===U.Identifier&&l.id.typeAnnotation.typeAnnotation.typeName.name==="FC"&&l.id.typeAnnotation.typeAnnotation.typeArguments?.params[0];if(c){if(c.type===U.TSTypeReference&&c.typeName.type===U.Identifier)n(!0,s,c.typeName,p,!1);else if(c.type===U.TSTypeLiteral)hn(p,...Tn(c));else if(c.type===U.TSIntersectionType)for(let f of c.types)f.type===U.TSTypeReference&&f.typeName.type===U.Identifier?n(!0,s,f.typeName,p,!1):a(!0,s,p,f,!0);if(p.size!==0&&l.init?.type===U.ArrowFunctionExpression){let f=l.init.params[0];if(!f){e.report({node:l.init,messageId:"missingComponentParam"});return}f.type===U.ObjectPattern&&i(f,p)}}},FunctionDeclaration:function(s){o(!1,s,s.params)},ArrowFunctionExpression(s){o(!1,s,s.params)}}}}),It={name:En,rule:Ri};import{AST_NODE_TYPES as de}from"@typescript-eslint/utils";var Ct=G({name:"no-write-only-ref",meta:{type:"problem",docs:{description:"Disallow creating refs that are never read"},messages:{refNotRead:'Ref "{{name}}" is never read. Consider removing it if not needed.'},schema:[]},defaultOptions:[],create(e){let t=new Set;function r(n){return n.callee.type===de.Identifier?t.has(n.callee.name):n.callee.type===de.MemberExpression&&n.callee.object.type===de.Identifier&&n.callee.property.type===de.Identifier?n.callee.property.name==="useRef":!1}return{ImportDeclaration(n){if(n.source.value==="react")for(let a of n.specifiers)a.type===de.ImportSpecifier&&a.imported.type===de.Identifier&&a.imported.name==="useRef"&&t.add(a.local.name)},VariableDeclarator(n){if(n.init&&n.init.type===de.CallExpression&&r(n.init)&&n.id.type===de.Identifier){let o=e.sourceCode.getScope(n).set.get(n.id.name);if(o){let i=!1;for(let s of o.references){let p=s.identifier.parent;if(p!==n&&!(p.type===de.JSXExpressionContainer&&p.parent.type===de.JSXAttribute&&p.parent.name.type===de.JSXIdentifier&&p.parent.name.name==="ref")){i=!0;break}}i||e.report({node:n.id,messageId:"refNotRead",data:{name:n.id.name}})}}}}}});import{AST_NODE_TYPES as wt,ESLintUtils as vi}from"@typescript-eslint/utils";var ki=vi.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),xn="prefer-named-functions",bn=new Map,Oi=ki({name:xn,meta:{hasSuggestions:!0,type:"suggestion",docs:{description:"Prevent using arrow functions when a named function can be used instead"},schema:[{type:"object",properties:{ignoreRegex:{type:"string"},disallowArrowFnWithImplicitReturns:{type:"boolean"}}}],messages:{suggestion:"Convert to named function",default:'Function {{functionName}} should be defined as a named function "function {{functionName}} () {}" instead of an arrow function',withIgnoreRegex:'Function {{functionName}} should be defined as a named function "function {{functionName}} () {}", if not possible to use `function` you can also use a name that matches the rule ignore regex'}},defaultOptions:[{}],create(e,[t]){let r=null;if(t.ignoreRegex){let n=bn.get(t.ignoreRegex);n?r=n:(r=new RegExp(t.ignoreRegex),bn.set(t.ignoreRegex,r))}return{VariableDeclarator(n){if(n.init&&n.init.type===wt.ArrowFunctionExpression&&n.id.type===wt.Identifier){let a=n.id.name;if(n.id.typeAnnotation||r&&r.test(a)||!t.disallowArrowFnWithImplicitReturns&&n.init.body.type!==wt.BlockStatement)return;let o=n.parent,i=n.init.params,s=n.init.body,l=n.init;e.report({node:n.id,messageId:r?"withIgnoreRegex":"default",data:{functionName:a,ignoreRegex:t.ignoreRegex},suggest:[{messageId:"suggestion",fix:p=>p.replaceText(o,`${l.async?"async ":""}function ${a}(${i.map(c=>e.sourceCode.getText(c)).join(", ")||""}) ${e.sourceCode.getText(s)}`)}]})}}}}}),At={name:xn,rule:Oi};import{AST_NODE_TYPES as M}from"@typescript-eslint/utils";var Pi=z({disallowedFunctions:Q(z({name:V(),allowUsingWithArgs:_(Re()),hookAlternative:_(V()),message:_(V()),allowUseInside:_(Q(V()))}))});function He(e){return/^use[A-Z]/.test(e)}function In(e){return/^[A-Z]/.test(e)}function Fi(e){return e.type===M.Identifier?He(e.name):e.type===M.MemberExpression&&e.property.type===M.Identifier?He(e.property.name):!1}function Cn(e,t){return e.type===M.Identifier?e.name===t:e.type===M.MemberExpression&&e.object.type===M.Identifier&&e.property.type===M.Identifier?e.object.name==="React"&&e.property.name===t:!1}function wn(e){return!!(e.parent&&e.parent.type===M.CallExpression&&Cn(e.parent.callee,"forwardRef"))}function An(e){return!!(e.parent&&e.parent.type===M.CallExpression&&Cn(e.parent.callee,"memo"))}function Rt(e){if(e.type===M.FunctionDeclaration||e.type===M.FunctionExpression&&e.id)return e.id||void 0;if(e.type===M.FunctionExpression||e.type===M.ArrowFunctionExpression){if(e.parent.type===M.VariableDeclarator&&e.parent.init===e)return e.parent.id;if(e.parent.type===M.AssignmentExpression&&e.parent.right===e&&e.parent.operator==="=")return e.parent.left;if(e.parent.type===M.Property&&e.parent.value===e&&!e.parent.computed)return e.parent.key;if(e.parent.type===M.AssignmentPattern&&e.parent.right===e)return e.parent.left}}function Ni(e){let t=e.parent,r=!1;for(;t;){if(t.type===M.FunctionDeclaration||t.type===M.FunctionExpression||t.type===M.ArrowFunctionExpression){let n=Rt(t);if(n&&n.type===M.Identifier){if(In(n.name)||He(n.name))return!r;r=!0}else{if(wn(t)||An(t))return!r;if(t.parent.type===M.CallExpression){let a=t.parent;Fi(a.callee)||(r=!0)}else t.parent.type===M.JSXExpressionContainer||(r=!0)}}t=t.parent}return!1}function Rn(e){return e.callee.type===M.Identifier?e.callee.name:e.callee.type===M.MemberExpression&&e.callee.property.type===M.Identifier?e.callee.property.name:null}function ji(e,t){if(!t.length)return!1;let r=e.parent;for(;r;){if(r.type===M.FunctionDeclaration||r.type===M.FunctionExpression||r.type===M.ArrowFunctionExpression){let n=Rt(r);if(n&&n.type===M.Identifier&&t.includes(n.name))return!0}else if(r.type===M.CallExpression){let n=Rn(r);if(n&&t.includes(n))return!0}r=r.parent}return!1}function Mi(e){return e.arguments.length>0&&!e.arguments.every(t=>t.type===M.Identifier&&t.name==="undefined")}function Di(e,t){let r=!1,n=e.parent;for(;n;){if(n.type===M.FunctionDeclaration||n.type===M.FunctionExpression||n.type===M.ArrowFunctionExpression){let a=Rt(n);if(a&&a.type===M.Identifier){if(In(a.name)||He(a.name)){r=!0;break}}else if(wn(n)||An(n)){r=!0;break}}n=n.parent}return r?t.length===0?Ni(e):!ji(e,t):!1}var vt=G({name:"prefer-react-hook-alternative",meta:{type:"suggestion",docs:{description:"Prefer hook alternatives for certain functions in React components and hooks"},messages:{preferHookAlternative:"This function should not be used in react{{message}}."},schema:[Pi],hasSuggestions:!0},defaultOptions:[{disallowedFunctions:[]}],create(e,[t]){let{disallowedFunctions:r}=t,n=new Map(r.map(a=>[a.name,a]));return{CallExpression(a){let o=Rn(a);if(!o)return;let i=n.get(o);if(!i||i.allowUsingWithArgs&&Mi(a))return;let s=i.allowUseInside||[];Di(a,s)&&e.report({node:a,messageId:"preferHookAlternative",data:{message:i.message?` ${i.message}`:` use ${i.hookAlternative} instead`},suggest:i.hookAlternative?[{messageId:"preferHookAlternative",data:{message:`Replace with ${i.hookAlternative}`,hookAlternative:i.hookAlternative},fix:l=>{let p=i.hookAlternative;return a.callee.type===M.Identifier?l.replaceText(a.callee,p):a.callee.type===M.MemberExpression&&a.callee.property.type===M.Identifier?l.replaceText(a.callee.property,p):null}}]:[]})}}}});import{AST_NODE_TYPES as K,AST_TOKEN_TYPES as vn,ESLintUtils as Li}from"@typescript-eslint/utils";var _i=Li.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),On="prefer-single-line-if",$i=z({maxLineLength:_(ge()),maxNonSimpleConditionLength:_(ge())}),Ui=_i({name:On,meta:{type:"suggestion",fixable:"code",docs:{description:"Enforce single-line if in simple if statements"},messages:{noSingleLineCurly:"If return statement with single statement body should be written in a single line"},schema:[$i]},defaultOptions:[{}],create(e,[t]){let r=e.sourceCode;return{IfStatement(n){if(n.consequent.type!==K.BlockStatement||n.loc.start.line===n.loc.end.line||r.getCommentsInside(n.consequent).length>0||n.alternate||n.consequent.body.length!==1)return;let o=n.consequent.body[0];if(o.type===K.ReturnStatement){if(!Fn(o))return}else if(!(o.type===K.ContinueStatement||o.type===K.BreakStatement))return;if(n.test.type===K.LogicalExpression||n.test.type===K.ConditionalExpression)return;let i;if(t.maxNonSimpleConditionLength){let f=kn(n.test);if(!f&&n.test.type===K.UnaryExpression&&n.test.operator==="!"){let y=n.test.argument;kn(y)&&(f=!0)}if(f&&(i=r.getText(n.test),i.length>t.maxNonSimpleConditionLength))return}i||(i=r.getText(n.test));let s=r.getText(o);if(i.includes(`
|
|
16
|
+
`))return;let l=r.getTokenAfter(n);if(l&&l.type===vn.Punctuator&&l.value==="}"){let f=r.getTokenAfter(l);if(f&&f.type===vn.Keyword&&(f.value==="else"||f.value==="catch"))return}let p=Wi(r,n),c=`if (${i}) ${s}`;t.maxLineLength&&c.length+p.length>t.maxLineLength||e.report({node:n,messageId:"noSingleLineCurly",fix:f=>f.replaceText(n,c)})}}}});function kn(e){return e.type===K.CallExpression||e.type===K.BinaryExpression||e.type===K.MemberExpression&&Pn(e)}function Pn(e){return e.object.type===K.MemberExpression?Pn(e.object):e.object.type!==K.Identifier}function Wi(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}function Fn(e){if(!e.argument)return!0;let t=e.argument;return t.type===K.ArrayExpression&&t.elements.length===0||t.type===K.ObjectExpression&&t.properties.length===0||t.type===K.Literal||t.type===K.Identifier||t.type===K.TemplateLiteral||t.type===K.TaggedTemplateExpression?!0:t.type===K.CallExpression?t.arguments.length===0:t.type===K.UnaryExpression?Fn(t):!1}var kt={name:On,rule:Ui};import{AST_NODE_TYPES as ce,ESLintUtils as Vi}from"@typescript-eslint/utils";var zi=Vi.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Nn="react-compiler-migration",Hi=z({disallowHooks:_(Q(z({name:V(),replacement:V()}))),disallowMethods:_(Q(z({name:V(),replacement:_(V()),requireTrueProp:_(V())})))}),Yi=/eslint +react-compiler\/react-compiler: +\["error/;function qi(e){return e.type===ce.Identifier?e.name.startsWith("use"):e.type===ce.MemberExpression&&e.property.type===ce.Identifier?e.property.name.startsWith("use"):!1}var Ji=zi({name:Nn,meta:{type:"suggestion",fixable:"code",docs:{description:"Rules to help migrate to the new React compiler"},messages:{disallowedFunctionOrMethod:"{{functionOrMethod}} is not supported in react compiler. Use {{replacement}} instead.",replace:"Replace with safe alternative {{replacement}}",disallowedMethodWithMissingRequireTrueProp:"{{method}} is should have a prop named {{requireTrueProp}} set to true when used in react compiler."},hasSuggestions:!0,schema:[Hi]},defaultOptions:[{}],create(e,[t]){let r=!1;for(let n of e.sourceCode.getAllComments())if(Yi.test(n.value)){r=!0;break}return r?{CallExpression(n){if(t.disallowHooks?.length){let a=null,o=null;if(n.callee.type===ce.Identifier?(a=n.callee.name,o=n.callee):n.callee.type===ce.MemberExpression&&n.callee.property.type===ce.Identifier&&(a=n.callee.property.name,o=n.callee.property),a){let i=t.disallowHooks.find(s=>s.name===a);i&&o&&e.report({node:n,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:i.name,replacement:i.replacement},suggest:[{messageId:"replace",data:{replacement:i.replacement},fix:s=>s.replaceText(o,i.replacement)}]})}}if(t.disallowMethods?.length&&qi(n.callee)){for(let a of n.arguments)if(a.type===ce.ObjectExpression){for(let o of a.properties)if(o.type===ce.Property&&o.key.type===ce.Identifier){let i=o.key.name,s=t.disallowMethods.find(l=>l.name===i);if(s){if(s.requireTrueProp){let l=s.requireTrueProp,p=!1;for(let c of a.properties)if(c.type===ce.Property&&c.key.type===ce.Identifier&&c.key.name===l&&c.value.type===ce.Literal&&c.value.value===!0){p=!0;break}if(!p){e.report({node:o,messageId:"disallowedMethodWithMissingRequireTrueProp",data:{method:s.name,requireTrueProp:l}});continue}}s.replacement&&e.report({node:o,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:s.name,replacement:s.replacement},suggest:[{messageId:"replace",data:{replacement:s.replacement},fix:l=>l.replaceText(o.key,s.replacement)}]})}}}}}}:{}}}),Ot={name:Nn,rule:Ji};import{ESLintUtils as Bi,TSESTree as Xi}from"@typescript-eslint/utils";var Gi=Bi.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),jn="require-description",Ki=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,Zi=/^eslint-disable-(next-)?line$/u,Qi=Gi({name:jn,meta:{type:"problem",docs:{description:"Require descriptions for eslint directives."},messages:{missingDescription:"Unexpected undescribed directive comment. Include descriptions to explain why the comment is necessary."},schema:[{type:"object",properties:{ignore:{type:"array",items:{type:"string",enum:["eslint","eslint-disable","eslint-disable-line","eslint-disable-next-line","eslint-enable","eslint-env","exported","global","globals"]},additionalItems:!1,uniqueItems:!0}},additionalProperties:!1}]},defaultOptions:[{ignore:[]}],create(e,[t]){let r=e.sourceCode,n=new Set(t.ignore||[]);return{Program(){for(let a of r.getAllComments()){let o=es(a);o!=null&&(n.has(o.kind)||o.description||e.report({loc:ns(a.loc),messageId:"missingDescription"}))}}}}}),Mn={name:jn,rule:Qi};function es(e){let{text:t,description:r}=ts(e.value);if(!t)return null;let n=Ki.exec(t);if(!n)return null;let a=n[1];if(!a)return null;let o=Zi.test(a);if(e.type===Xi.AST_TOKEN_TYPES.Line&&!o||o&&e.loc.start.line!==e.loc.end.line)return null;let i=t.slice(n.index+a.length);return{kind:a,value:i.trim(),description:r}}function ts(e){let t=e.split(/\s-{2,}\s/u);return{text:t[0]?.trim(),description:t.length>1?t[1]?.trim()??null:null}}function ns(e){return{start:{line:e.start.line,column:-1},end:e.end}}import{AST_NODE_TYPES as L}from"@typescript-eslint/utils";import{z as Ee}from"zod/v4";var rs=Ee.object({varsToCheck:Ee.array(Ee.object({selector:Ee.string().optional(),fromFnCall:Ee.string().optional(),prop:Ee.string().or(Ee.array(Ee.string())),errorMsg:Ee.string().optional()}))}),Pt=G({name:"require-reads-to-var-prop",meta:{type:"suggestion",docs:{description:"Require specific properties from variables to be read or ensure the variable is passed to functions/components"},messages:{propNotRead:'"{{fnName}}" requires reads to the prop "{{prop}}". {{customMsg}}',propsNotRead:'"{{fnName}}" requires reads to the props {{props}}. {{customMsg}}'},schema:[Ie(rs)]},defaultOptions:[{varsToCheck:[]}],create(e,[t]){let r=new Map,n=(i,s,l,p)=>{let c=new Set;for(let y of i.properties)y.type===L.Property&&y.key.type===L.Identifier&&c.add(y.key.name);let f=s.filter(y=>!c.has(y));if(f.length>0)if(f.length===1)e.report({node:i,messageId:"propNotRead",data:{prop:f[0],fnName:p,customMsg:l||""}});else{let y=f.map(T=>`"${T}"`).join(", ");e.report({node:i,messageId:"propsNotRead",data:{props:y,fnName:p,customMsg:l||""}})}},a=i=>{if(i.init?.type===L.CallExpression){if(i.init.callee.type===L.Identifier)return i.init.callee.name;if(i.init.callee.type===L.MemberExpression&&i.init.callee.property.type===L.Identifier)return i.init.callee.object.type===L.Identifier?`${i.init.callee.object.name}.${i.init.callee.property.name}`:i.init.callee.property.name}return"unknown function"},o={};for(let i of t.varsToCheck)i.selector&&(o[i.selector]=s=>{if(s.type===L.VariableDeclarator&&s.id.type===L.Identifier&&r.set(s.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:s.id,fnName:a(s)}),s.type===L.VariableDeclarator&&s.id.type===L.ObjectPattern){let l=Array.isArray(i.prop)?i.prop:[i.prop];n(s.id,l,i.errorMsg,a(s))}});for(let i of t.varsToCheck)if(i.fromFnCall){let s=i.fromFnCall;if(s.startsWith("*.")){let p=`VariableDeclarator > CallExpression > MemberExpression[property.name="${s.slice(2)}"]`;o[p]=c=>{if(c.type!==L.MemberExpression||c.parent.type!==L.CallExpression)return;let f=c.parent;if(f.parent.type!==L.VariableDeclarator)return;let y=f.parent;if(y.id.type===L.Identifier)r.set(y.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:y.id,fnName:i.fromFnCall||"unknown function"});else if(y.id.type===L.ObjectPattern){let T=Array.isArray(i.prop)?i.prop:[i.prop];n(y.id,T,i.errorMsg,i.fromFnCall||"unknown function")}}}else if(s.includes(".")){let[l,p]=s.split("."),c=`VariableDeclarator > CallExpression > MemberExpression[object.name="${l}"][property.name="${p}"]`;o[c]=f=>{if(f.type!==L.MemberExpression||f.parent.type!==L.CallExpression)return;let y=f.parent;if(y.parent.type!==L.VariableDeclarator)return;let T=y.parent;if(T.id.type===L.Identifier)r.set(T.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:T.id,fnName:i.fromFnCall||"unknown function"});else if(T.id.type===L.ObjectPattern){let I=Array.isArray(i.prop)?i.prop:[i.prop];n(T.id,I,i.errorMsg,i.fromFnCall||"unknown function")}}}else{let l=`VariableDeclarator > CallExpression > Identifier[name="${s}"]`;o[l]=p=>{if(p.type!==L.Identifier||p.parent.type!==L.CallExpression)return;let c=p.parent;if(c.parent.type!==L.VariableDeclarator)return;let f=c.parent;if(f.id.type===L.Identifier)r.set(f.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:f.id,fnName:i.fromFnCall||"unknown function"});else if(f.id.type===L.ObjectPattern){let y=Array.isArray(i.prop)?i.prop:[i.prop];n(f.id,y,i.errorMsg,i.fromFnCall||"unknown function")}}}}return{...o,"Program:exit"(){for(let[i,{props:s,errorMsg:l,node:p,fnName:c}]of r){let y=e.sourceCode.getScope(p).set.get(i);if(y){let T=new Set(s);for(let I of y.references){let x=I.identifier,E=x.parent;if(!(E.type===L.VariableDeclarator&&E.id===x)){if(E.type===L.MemberExpression&&E.object===x&&E.property.type===L.Identifier&&T.has(E.property.name)){if(T.delete(E.property.name),T.size===0)break;continue}if(E.type===L.VariableDeclarator&&E.init===x&&E.id.type===L.ObjectPattern){for(let u of E.id.properties)u.type===L.Property&&u.key.type===L.Identifier&&T.has(u.key.name)&&T.delete(u.key.name);if(T.size===0)break;continue}if(!(E.type===L.MemberExpression&&E.object===x&&E.property.type===L.Identifier&&!s.includes(E.property.name))){T.clear();break}}}if(T.size>0){let I=Array.from(T);if(I.length===1)e.report({node:p,messageId:"propNotRead",data:{prop:I[0],fnName:c,customMsg:l||""}});else{let x=I.map(E=>`"${E}"`).join(", ");e.report({node:p,messageId:"propsNotRead",data:{props:x,fnName:c,customMsg:l||""}})}}}}}}}});function _n(e){return/^use[A-Z0-9]/.test(e)}function Ye(e){return e.type==="Identifier"?_n(e.name):e.type==="MemberExpression"&&!e.computed&&Ye(e.property)?e.object.type==="Identifier":!1}function $n(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function Un(e,t){return e.name===t||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===t}function Wn(e){return!!(e.parent&&e.parent.callee&&Un(e.parent.callee,"forwardRef"))}function Vn(e){return!!(e.parent&&e.parent.callee&&Un(e.parent.callee,"memo"))}function Ft(e){for(;e;){let t=Hn(e);if(t&&($n(t)||Ye(t))||Wn(e)||Vn(e))return!0;e=e.parent}return!1}function Dn(e){return!1}function Nt(e){return!1}var is=/eslint +react-compiler\/react-compiler: +\["error/,zn={meta:{type:"problem",docs:{description:"enforces the Rules of Hooks",recommended:!0,url:"https://reactjs.org/docs/hooks-rules.html"},schema:[{type:"object",ignoreIfReactCompilerIsEnabled:!1,properties:{ignoreIfReactCompilerIsEnabled:{type:"boolean"}}}]},create(e){if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let l of e.sourceCode.getAllComments())if(is.test(l.value))return{CallExpression(p){let c=null;p.callee.name==="useMemo"?c="useMemo":p.callee.name==="useCallback"&&(c="useCallback"),c&&e.report({node:p,message:`"${c}" is not necessary when using React Compiler.`})}}}let t=typeof e.getSource=="function"?l=>t(l):l=>e.sourceCode.getText(l),r=typeof e.getScope=="function"?()=>r():l=>e.sourceCode.getScope(l),n=null,a=[],o=[],i=new WeakSet;function s(l){for(let p of l.references){let c=p.identifier.parent;if(c.type==="VariableDeclarator"&&c.init&&c.init.type==="CallExpression"&&c.init.callee&&Dn(c.init.callee))for(let f of p.resolved.references)f!==p&&i.add(f.identifier)}}return{onCodePathSegmentStart:l=>o.push(l),onCodePathSegmentEnd:()=>o.pop(),onCodePathStart:()=>a.push(new Map),onCodePathEnd(l,p){let c=a.pop();if(c.size===0)return;let f=new Set;function y(g,m){let{cache:S}=y,k=S.get(g.id),R=new Set(m);if(R.has(g.id)){let C=[...R],N=C.slice(C.indexOf(g.id)+1);for(let W of N)f.add(W);return BigInt("0")}if(R.add(g.id),k!==void 0)return k;if(l.thrownSegments.includes(g))k=BigInt("0");else if(g.prevSegments.length===0)k=BigInt("1");else{k=BigInt("0");for(let C of g.prevSegments)k+=y(C,R)}return g.reachable&&k===BigInt("0")?S.delete(g.id):S.set(g.id,k),k}function T(g,m){let{cache:S}=T,k=S.get(g.id),R=new Set(m);if(R.has(g.id)){let C=Array.from(R),N=C.slice(C.indexOf(g.id)+1);for(let W of N)f.add(W);return BigInt("0")}if(R.add(g.id),k!==void 0)return k;if(l.thrownSegments.includes(g))k=BigInt("0");else if(g.nextSegments.length===0)k=BigInt("1");else{k=BigInt("0");for(let C of g.nextSegments)k+=T(C,R)}return S.set(g.id,k),k}function I(g){let{cache:m}=I,S=m.get(g.id);if(S===null)return 1/0;if(S!==void 0)return S;if(m.set(g.id,null),g.prevSegments.length===0)S=1;else{S=1/0;for(let k of g.prevSegments){let R=I(k);R<S&&(S=R)}S+=1}return m.set(g.id,S),S}y.cache=new Map,T.cache=new Map,I.cache=new Map;let x=T(l.initialSegment),E=Hn(p),u=Ft(p),A=E?$n(E)||Ye(E):Wn(p)||Vn(p),b=1/0;for(let g of l.finalSegments){if(!g.reachable)continue;let m=I(g);m<b&&(b=m)}for(let[g,m]of c){if(!g.reachable)continue;let S=g.nextSegments.length===0?b<=I(g):b<I(g),k=y(g)*T(g),R=f.has(g.id);for(let C of m)if(R&&!Nt(C)&&e.report({node:C,message:`React Hook "${t(C)}" may be executed more than once. Possibly because it is called in a loop. React Hooks must be called in the exact same order in every component render.`}),A){if(p.async&&e.report({node:C,message:`React Hook "${t(C)}" cannot be called in an async function.`}),!R&&k!==x&&!Nt(C)){let W=`React Hook "${t(C)}" is called conditionally. React Hooks must be called in the exact same order in every component render.`+(S?" Did you accidentally call a React Hook after an early return?":"");e.report({node:C,message:W})}}else if(p.parent&&(p.parent.type==="MethodDefinition"||p.parent.type==="ClassProperty")&&p.parent.value===p){let N=`React Hook "${t(C)}" cannot be called in a class component. React Hooks must be called in a React function component or a custom React Hook function.`;e.report({node:C,message:N})}else if(E){let N=`React Hook "${t(C)}" is called in function "${t(E)}" that is neither a React function component nor a custom React Hook function. React component names must start with an uppercase letter. React Hook names must start with the word "use".`;e.report({node:C,message:N})}else if(p.type==="Program"){let N=`React Hook "${t(C)}" cannot be called at the top level. React Hooks must be called in a React function component or a custom React Hook function.`;e.report({node:C,message:N})}else if(u&&!Nt(C)){if(p.parent.type==="CallExpression"&&p.parent.callee.type==="Identifier"&&p.parent.callee.name==="useCallback"){let W=p.parent;if(W.parent.type==="VariableDeclarator"&&_n(W.parent.id.name))return}let N=`React Hook "${t(C)}" cannot be called inside a callback. React Hooks must be called in a React function component or a custom React Hook function.`;e.report({node:C,message:N})}}},CallExpression(l){if(Ye(l.callee)){let p=Ln(a),c=Ln(o),f=p.get(c);f||(f=[],p.set(c,f)),f.push(l.callee)}l.callee.type==="Identifier"&&(l.callee.name==="useEffect"||Dn(l.callee))&&l.arguments.length>0&&(n=l)},Identifier(l){n==null&&i.has(l)&&l.parent.type!=="CallExpression"&&e.report({node:l,message:`\`${t(l)}\` is a function created with React Hook "useEffectEvent", and can only be called from the same component. They cannot be assigned to variables or passed down.`})},"CallExpression:exit"(l){l===n&&(n=null)},FunctionDeclaration(l){Ft(l)&&s(r(l))},ArrowFunctionExpression(l){Ft(l)&&s(r(l))}}}};function Hn(e){return e.type==="FunctionDeclaration"||e.type==="FunctionExpression"&&e.id?e.id:e.type==="FunctionExpression"||e.type==="ArrowFunctionExpression"?e.parent.type==="VariableDeclarator"&&e.parent.init===e?e.parent.id:e.parent.type==="AssignmentExpression"&&e.parent.right===e&&e.parent.operator==="="?e.parent.left:e.parent.type==="Property"&&e.parent.value===e&&!e.parent.computed?e.parent.key:e.parent.type==="AssignmentPattern"&&e.parent.right===e&&!e.parent.computed?e.parent.left:void 0:void 0}function Ln(e){return e[e.length-1]}import{AST_NODE_TYPES as ne,AST_TOKEN_TYPES as ss}from"@typescript-eslint/utils";import*as oe from"zod/v4";var os=oe.object({indent:oe.union([oe.string().regex(/^\s+$/),oe.number().int().min(1)]).optional(),tags:oe.array(oe.string()).optional(),functions:oe.array(oe.string()).optional(),comments:oe.array(oe.string()).optional()}),jt=G({name:"template-indent",meta:{type:"suggestion",docs:{description:"Fix whitespace-insensitive template indentation"},fixable:"code",schema:[Ie(os)],messages:{improperlyIndented:"Templates should be properly indented."}},defaultOptions:[{}],create(e){let t=e.sourceCode,{comments:r=["HTML","indent"],functions:n=["dedent","stripIndent"],tags:a=["outdent","dedent","gql","sql","html","styled"],indent:o}=e.options[0],i=r.map(u=>u.toLowerCase());function s(u){let A=u.split(/\r?\n/),b=A.filter(m=>m.trim()!=="");if(b.length===0)return u;let g=Number.POSITIVE_INFINITY;for(let m of b){let S=m.match(/^(\s*)/);S&&(g=Math.min(g,S[1]?.length??0))}return!isFinite(g)||g===0?u:A.map(m=>m.slice(g)).join(`
|
|
17
|
+
`)}function l(u,A,b){return u.split(/\r?\n/).map(m=>m.trim()===""?m:b.repeat(A)+m).join(`
|
|
18
|
+
`)}function p(u){if(u.type===ne.Identifier)return u.name;if(u.type===ne.MemberExpression){let A=u.object.type===ne.Identifier?u.object.name:null,b=u.property.type===ne.Identifier?u.property.name:null;return A&&b?`${A}.${b}`:b}return null}function c(u,A){if(!u)return!1;for(let b of A)if(b.includes(".")){let g=b.split(".");if(u.type===ne.MemberExpression&&u.object.type===ne.Identifier&&u.property.type===ne.Identifier&&u.object.name===g[0]&&u.property.name===g[1])return!0}else if(u.type===ne.Identifier&&u.name===b)return!0;return!1}function f(u,A){let b=u.parent;if(b.type!==ne.TaggedTemplateExpression)return!1;let g=p(b.tag);return g?A.includes(g):!1}function y(u,A){if(!u||u.type!==ne.CallExpression)return!1;let{method:b,argumentsLength:g,optionalCall:m=!0,optionalMember:S=!0}=A;return g!==void 0&&u.arguments.length!==g||!m&&u.optional||u.callee.type!==ne.MemberExpression||!S&&u.callee.optional||u.callee.property.type!==ne.Identifier?!1:u.callee.property.name===b}function T(u,A){if(!u||u.type!==ne.CallExpression)return!1;let{name:b,argumentsLength:g,optionalCall:m=!0}=A;return g!==void 0&&u.arguments.length!==g||!m&&u.optional||u.callee.type!==ne.Identifier?!1:u.callee.name===b}function I(u){return y(u.parent,{method:"toMatchInlineSnapshot",argumentsLength:1,optionalCall:!1,optionalMember:!1})&&u.parent.type===ne.CallExpression&&u.parent.arguments[0]===u&&T(u.parent.callee.type===ne.MemberExpression?u.parent.callee.object:null,{name:"expect",argumentsLength:1,optionalCall:!1,optionalMember:!1})}function x(u){if(i.length>0){let A=t.getTokenBefore(u,{includeComments:!0});if(A?.type===ss.Block&&i.includes(A.value.trim().toLowerCase()))return!0}return!!(I(u)||a.length>0&&f(u,a)||n.length>0&&u.parent.type===ne.CallExpression&&u.parent.arguments.includes(u)&&c(u.parent.callee,n))}function E(u){let A=`__PLACEHOLDER__${Math.random()}`,b=u.quasis.map(B=>t.getText(B).slice(1,B.tail?-1:-2)).join(A),g=b.match(/\r?\n/);if(!g)return;let m=g[0],S=t.lines[t.getLocFromIndex(u.range[0]).line-1];if(!S)return;let R=S.match(/^(\s*)\S/)?.[1]??"",C;typeof o=="string"?C=o:typeof o=="number"?C=" ".repeat(o):C=R.startsWith(" ")?" ":" ";let W=s(b).replace(new RegExp(`^${m}|${m}[ ]*$`,"g"),""),J=m+l(W,1,R+C)+m+R,te=b.includes(`\r
|
|
19
|
+
`)?`\r
|
|
20
|
+
`:`
|
|
21
|
+
`,Z=b.split(/\r?\n/),be=Z.map((B,ye)=>ye!==Z.length-1&&B===C?"":B).join(te);if(J!==be)return{node:u,messageId:"improperlyIndented",fix:B=>J.split(A).map((ye,ue)=>{let ie=u.quasis[ue];return ie?B.replaceTextRange([ie.range[0]+1,ie.range[1]-(ie.tail?1:2)],ye):[]}).flat()}}return{TemplateLiteral(u){if(!x(u))return;let A=E(u);if(A)return e.report(A)}}}});import{AST_NODE_TYPES as Yn}from"@typescript-eslint/utils";function as(e){if(!("regex"in e))return!1;let t=e.regex.flags;return t.includes("g")||t.includes("y")}function ls(e){let t=e.parent;return t?.type===Yn.NewExpression&&t.callee.type===Yn.Identifier&&t.callee.name==="RegExp"}var Mt=G({name:"use-top-level-regex",meta:{type:"suggestion",docs:{description:"Require regex literals to be declared at the top level to avoid performance issues"},messages:{regexShouldBeTopLevel:"Move this regex literal to the top level to avoid creating new RegExp objects on each function call."},schema:[],hasSuggestions:!1},defaultOptions:[],create(e){function t(r){as(r)||ls(r)||e.report({node:r,messageId:"regexShouldBeTopLevel"})}return{"FunctionDeclaration Literal[regex], FunctionExpression Literal[regex], ArrowFunctionExpression Literal[regex], MethodDefinition Literal[regex]":t}}});var qn={[It.name]:It.rule,[st.name]:st.rule,[it.name]:it.rule,"rules-of-hooks":zn,"exhaustive-deps":Xt,"require-description":Mn.rule,[ot.name]:ot.rule,[lt.name]:lt.rule,[At.name]:At.rule,[Ge.name]:Ge.rule,[rt.name]:rt.rule,[mt.name]:mt.rule,[kt.name]:kt.rule,[ut.name]:ut.rule,[at.name]:at.rule,[Ze.name]:Ze.rule,[Ot.name]:Ot.rule,[Xe.name]:Xe.rule,[nt.name]:nt.rule,[St.name]:St.rule,[Tt.name]:Tt.rule,[Et.name]:Et.rule,[bt.name]:bt.rule,[ht.name]:ht.rule,[vt.name]:vt.rule,[yt.name]:yt.rule,[dt.name]:dt.rule,[Mt.name]:Mt.rule,[Ct.name]:Ct.rule,[Pt.name]:Pt.rule,[jt.name]:jt.rule};var Ga={rules:qn};export{Ga as extendedLintPlugin};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ls-stack/extended-lint",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.56.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -20,19 +20,19 @@
|
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@ls-stack/eslint-cfg": "^0.1.3",
|
|
23
|
-
"@ls-stack/utils": "^
|
|
23
|
+
"@ls-stack/utils": "^3.25.0",
|
|
24
24
|
"@types/eslint": "^9.6.1",
|
|
25
|
-
"@types/node": "^
|
|
26
|
-
"@typescript-eslint/parser": "^8.
|
|
27
|
-
"@typescript-eslint/rule-tester": "^8.
|
|
28
|
-
"@vitest/ui": "^3.
|
|
29
|
-
"eslint": "^9.
|
|
25
|
+
"@types/node": "^24.2.1",
|
|
26
|
+
"@typescript-eslint/parser": "^8.39.0",
|
|
27
|
+
"@typescript-eslint/rule-tester": "^8.39.0",
|
|
28
|
+
"@vitest/ui": "^3.2.4",
|
|
29
|
+
"eslint": "^9.33.0",
|
|
30
30
|
"tschema": "^3.2.0",
|
|
31
31
|
"tsm": "^2.3.0",
|
|
32
|
-
"tsup": "^8.
|
|
33
|
-
"typescript": "^5.
|
|
34
|
-
"vite": "^
|
|
35
|
-
"vitest": "^3.
|
|
32
|
+
"tsup": "^8.5.0",
|
|
33
|
+
"typescript": "^5.9.2",
|
|
34
|
+
"vite": "^7.1.1",
|
|
35
|
+
"vitest": "^3.2.4"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@typescript-eslint/utils": "^8.22.0",
|