@ls-stack/extended-lint 0.35.1 → 0.36.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.
@@ -1,5 +1,6 @@
1
- "use strict";var fn=Object.create;var he=Object.defineProperty;var mn=Object.getOwnPropertyDescriptor;var dn=Object.getOwnPropertyNames;var yn=Object.getPrototypeOf,gn=Object.prototype.hasOwnProperty;var hn=(e,t)=>{for(var n in t)he(e,n,{get:t[n],enumerable:!0})},ct=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of dn(t))!gn.call(e,l)&&l!==n&&he(e,l,{get:()=>t[l],enumerable:!(o=mn(t,l))||o.enumerable});return e};var Ae=(e,t,n)=>(n=e!=null?fn(yn(e)):{},ct(t||!e||!e.__esModule?he(n,"default",{value:e,enumerable:!0}):n,e)),Tn=e=>ct(he({},"__esModule",{value:!0}),e);var Mr={};hn(Mr,{extendedLintPlugin:()=>jr});module.exports=Tn(Mr);var H=require("@typescript-eslint/utils");var Oe=Symbol.for("optional");function $(e){return{...e,[Oe]:!0}}function Te(e,t){return{enum:e,...t}}function oe(e){return{...e,type:"boolean"}}function F(e){return{...e,type:"string"}}function J(e){return{...e,type:"number"}}function pt(e){return{...e,type:"integer"}}function V(e,t){return{...t,type:"array",items:e}}function j(e,t){let n={...t,type:"object",properties:e};if(e&&(n.additionalProperties||=!1,!n.required)){let o,l=[];for(o in e)e[o][Oe]?e[o][Oe]=void 0:l.push(o);l.length>0&&(n.required=l)}return n}function Pe(...e){return{anyOf:e}}var Sn=H.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),ft="react-compiler-extra",En=j({runOnlyWithEnableCompilerDirective:$(oe())}),bn=/eslint +react-compiler\/react-compiler: +\["error/;function xn(e){return e.type===H.AST_NODE_TYPES.Identifier?e.name.startsWith("use"):e.type===H.AST_NODE_TYPES.MemberExpression&&e.property.type===H.AST_NODE_TYPES.Identifier?e.property.name.startsWith("use"):!1}var Cn=/\bthis[.[]/;function ut(e){return Cn.test(e)}var In=Sn({name:ft,meta:{type:"suggestion",fixable:"code",docs:{description:"Extra rules to enforce best practices when using the React compiler"},messages:{objectMethodIsNotSupported:"Object methods such as `{ method() {} }` have limited support to optimizations in the React compiler, use a function expression `{ method: () => {} }` instead.",replaceWithFunctionExpression:"Replace with function expression",thisKeywordInMethod:"Object method uses `this` keyword which would have different behavior if converted to an arrow function. Fix this manually."},hasSuggestions:!0,schema:[En]},defaultOptions:[{}],create(e,[t]){let n=!1;if(t.runOnlyWithEnableCompilerDirective){for(let f of e.sourceCode.getAllComments())if(bn.test(f.value)){n=!0;break}if(!n)return{}}function o(f){for(let p of f.properties)if(p.type===H.AST_NODE_TYPES.Property&&p.method&&p.value.type===H.AST_NODE_TYPES.FunctionExpression){let r=e.sourceCode,a=r.getText(p.key),s=p.value,i=r.getText(s.body);if(ut(i))e.report({node:p,messageId:"thisKeywordInMethod"});else{let c=s.params.map(h=>r.getText(h)).join(", "),y="";s.generator?y=`${a}: function* (${c}) ${i}`:y=`${a}: (${c}) => ${i}`,e.report({node:p,messageId:"objectMethodIsNotSupported",fix:h=>h.replaceText(p,y)})}}}function l(f){for(let p of f.properties)if(p.type===H.AST_NODE_TYPES.Property&&p.value.type===H.AST_NODE_TYPES.ObjectExpression){for(let r of p.value.properties)if(r.type===H.AST_NODE_TYPES.Property&&r.method&&r.value.type===H.AST_NODE_TYPES.FunctionExpression){let s=e.sourceCode.getText(r.value.body);ut(s)&&e.report({node:r,messageId:"thisKeywordInMethod"})}}}return{CallExpression(f){if(xn(f.callee))for(let p of f.arguments){if(p.type===H.AST_NODE_TYPES.ObjectExpression&&(o(p),l(p)),p.type===H.AST_NODE_TYPES.ArrowFunctionExpression&&(p.body.type===H.AST_NODE_TYPES.ObjectExpression&&(o(p.body),l(p.body)),p.body.type===H.AST_NODE_TYPES.BlockStatement))for(let r of p.body.body)r.type===H.AST_NODE_TYPES.ReturnStatement&&r.argument?.type===H.AST_NODE_TYPES.ObjectExpression&&(o(r.argument),l(r.argument));if(p.type===H.AST_NODE_TYPES.FunctionExpression)for(let r of p.body.body)r.type===H.AST_NODE_TYPES.ReturnStatement&&r.argument?.type===H.AST_NODE_TYPES.ObjectExpression&&(o(r.argument),l(r.argument))}}}}}),Ne={name:ft,rule:In};var ae=require("@typescript-eslint/utils");var wn=ae.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Rn=j({disallow:$(V(j({selector:F(),message:F(),replace:$(Pe(F(),j({regex:F(),with:F()}))),replaceType:$(Te(["suggestion","autofix"]))}))),__dev_simulateFileName:$(F()),mustMatchSyntax:$(V(j({includeRegex:F(),mustCallFn:V(j({anyCall:V(j({fn:F(),withArgs:V(j({atIndex:pt(),literal:Pe(F(),J(),oe())}))})),message:$(F())}))})))}),yt="advanced-no-restricted-syntax",vn=wn({name:yt,meta:{type:"suggestion",docs:{description:"Disallow specific syntax patterns"},schema:[Rn],messages:{default:"{{message}}"},fixable:"code",hasSuggestions:!0},defaultOptions:[{disallow:[]}],create(e,[t]){let n={},{mustMatchSyntax:o,__dev_simulateFileName:l,disallow:f}=t,p=l??e.filename,r=[],a=new Set;for(let{includeRegex:i,mustCallFn:c}of o??[]){let y=kn(p,new RegExp(i));if(!y)continue;let h=S=>{let d=S;for(let{name:E,value:T}of y)d=d.replaceAll(E,T);return d};for(let{anyCall:S,message:d}of c){let E=`Expected file to call the function: ${S.map(({fn:T})=>T).join(" or ")}`;a.add(E),r.push(T=>{let{callee:N}=T;if(N.type===ae.AST_NODE_TYPES.Identifier){for(let{fn:v,withArgs:g}of S)if(N.name===v){a.delete(E);for(let w of g){let R=T.arguments[w.atIndex],k=typeof w.literal=="string"?h(w.literal):w.literal;if(!R){e.report({node:T,messageId:"default",data:{message:`Missing argument with value "${k}" at index ${w.atIndex}${d?`: ${h(d)}`:""}`}});continue}if(R.type!==ae.AST_NODE_TYPES.Literal){e.report({node:R,messageId:"default",data:{message:`Argument at position ${w.atIndex} should the literal "${k}"${d?`: ${h(d)}`:""}`}});continue}R.value!==k&&e.report({node:R,messageId:"default",data:{message:`Argument should have the value "${k}"${d?`: ${h(d)}`:""}`},fix:_=>_.replaceText(R,typeof k=="string"?`'${k}'`:String(k))})}break}}})}}for(let{selector:i,message:c,replace:y,replaceType:h="suggestion"}of f??[]){if(i==="CallExpression"){r.push(S=>{s(y,S,c,h)});continue}n[i]=S=>{s(y,S,c,h)}}return r.length>0&&(n.CallExpression=i=>{if(i.type===ae.AST_NODE_TYPES.CallExpression)for(let c of r)c(i)}),n["Program:exit"]=i=>{for(let c of a)e.report({node:i,messageId:"default",data:{message:`${c}`}})},n;function s(i,c,y,h){let S=d=>{if(!i)return null;if(typeof i=="string")return d.replaceText(c,i);{let E=new RegExp(i.regex),T=e.sourceCode.getText(c);return d.replaceText(c,T.replace(E,i.with))}};e.report({node:c,messageId:"default",data:{message:y},fix:i&&h==="autofix"?S:void 0,suggest:i&&h==="suggestion"?[{messageId:"default",data:{message:`Replace with "${typeof i=="string"?i:i.with}"`},fix:S}]:void 0})}}});function kn(e,t){let n=[],o=t.exec(e);if(!o)return null;let[l,...f]=o;n.push({name:"$0_lowercase",value:l.toLowerCase()}),n.push({name:"$0_capitalize",value:mt(l)}),n.push({name:"$0_uncapitalize",value:dt(l)}),n.push({name:"$0",value:l});for(let p=0;p<f.length;p++){let r=`$${p+1}`,a=f[p];n.push({name:`${r}_lowercase`,value:a.toLowerCase()}),n.push({name:`${r}_capitalize`,value:mt(a)}),n.push({name:`${r}_uncapitalize`,value:dt(a)}),n.push({name:r,value:a})}return n}function mt(e){return e.charAt(0).toUpperCase()+e.slice(1)}function dt(e){return e.charAt(0).toLowerCase()+e.slice(1)}var De={name:yt,rule:vn};var D=require("@typescript-eslint/utils");var An=D.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),ht="collapse-simple-objs-in-one-line",On=j({maxLineLength:$(J()),maxProperties:$(J()),nestedObjMaxLineLength:$(J()),nestedObjMaxProperties:$(J()),ignoreTypesWithSuffix:$(V(F()))}),Pn=An({name:ht,meta:{type:"suggestion",fixable:"code",docs:{description:"Format simple objects and types in one line"},messages:{singleLineProp:"Object/type should be written in a single line"},schema:[On]},defaultOptions:[{}],create(e,[t]){let n=e.sourceCode,o=t.ignoreTypesWithSuffix??[],l=t.maxProperties??2,f=t.nestedObjMaxLineLength??t.maxLineLength,p=t.nestedObjMaxProperties??3;function r(s){if(s.type===D.AST_NODE_TYPES.ObjectExpression){let i=s.parent.type===D.AST_NODE_TYPES.Property,c=i?p:l,y=s.properties.length;if(y>c)return!1;if(y===1){let S=s.properties[0];return S.type===D.AST_NODE_TYPES.Property&&(S.value.type===D.AST_NODE_TYPES.ObjectExpression||S.value.type===D.AST_NODE_TYPES.ArrayExpression)?!1:{text:n.getText(S),isNested:i,propsSize:y}}let h=[];for(let S of s.properties){if(S.type===D.AST_NODE_TYPES.Property){let d=S.value.type;if(!(d===D.AST_NODE_TYPES.Literal||d===D.AST_NODE_TYPES.Identifier||d===D.AST_NODE_TYPES.TemplateLiteral||d===D.AST_NODE_TYPES.TaggedTemplateExpression))return!1}h.push(n.getText(S))}return{text:h.join(", "),isNested:i,propsSize:y}}else{let i=s.parent.parent?.type===D.AST_NODE_TYPES.TSPropertySignature,c=i?p:l,y=s.members.length;if(y>c)return!1;if(o.length>0&&s.parent.type===D.AST_NODE_TYPES.TSTypeAliasDeclaration){let S=s.parent.id.name;if(o.some(d=>S.endsWith(d)))return!1}if(y===1){let S=s.members[0];return S.type===D.AST_NODE_TYPES.TSPropertySignature&&S.typeAnnotation?.typeAnnotation.type===D.AST_NODE_TYPES.TSTypeLiteral?!1:{text:n.getText(S),isNested:i,propsSize:1}}if(s.parent.type===D.AST_NODE_TYPES.TSIntersectionType||s.parent.type===D.AST_NODE_TYPES.TSUnionType)return!1;let h=[];for(let S of s.members){if(S.type!==D.AST_NODE_TYPES.TSPropertySignature)return!1;let d=S.typeAnnotation?.typeAnnotation;if(!d||d.type===D.AST_NODE_TYPES.TSTypeLiteral||!gt(d.type))return!1;if(d.type===D.AST_NODE_TYPES.TSTypeReference&&d.typeArguments){if(d.typeArguments.params.length>1)return!1;let T=d.typeArguments.params[0];if(!gt(T.type))return!1}let E=n.getText(S).trim();(E.endsWith(";")||E.endsWith(","))&&(E=E.slice(0,-1)),h.push(E)}return{text:h.join("; "),isNested:i,propsSize:y}}}function a(s){if(s.loc.start.line===s.loc.end.line||s.parent.type!==D.AST_NODE_TYPES.JSXExpressionContainer&&n.getTokenAfter(s,{filter:E=>{let T=E.type===D.AST_TOKEN_TYPES.Punctuator&&E.value===",",N=E.type===D.AST_TOKEN_TYPES.Punctuator&&E.value===";";return!T&&!N}})?.loc.start.line===s.loc.end.line)return;let i=r(s);if(!i)return;let c=i.text;if(c.includes(`
2
- `)||n.getCommentsInside(s).length>0)return;c.endsWith(";")&&(c=c.slice(0,-1));let y=`{ ${c} }`,h=Dn(n,s),S=i.isNested&&i.propsSize>2?f:t.maxLineLength;S&&y.length+h.length+(Nn(s,n)?1:0)>S||e.report({node:s,messageId:"singleLineProp",fix:d=>d.replaceText(s,y)})}return{TSTypeLiteral:a,ObjectExpression:a}}});function gt(e){return e===D.AST_NODE_TYPES.TSLiteralType||e===D.AST_NODE_TYPES.TSTypeReference||e===D.AST_NODE_TYPES.TSNumberKeyword||e===D.AST_NODE_TYPES.TSStringKeyword||e===D.AST_NODE_TYPES.TSBooleanKeyword||e===D.AST_NODE_TYPES.TSNullKeyword||e===D.AST_NODE_TYPES.TSUndefinedKeyword}function Nn(e,t){let n=t.getTokenAfter(e);return n?.type===D.AST_TOKEN_TYPES.Punctuator&&(n.value===","||n.value===";"||n.value==="}")&&n.loc.start.line===e.loc.end.line}function Dn(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}var _e={name:ht,rule:Pn};var _n=/eslint +react-compiler\/react-compiler: +\["error/,St={meta:{type:"suggestion",docs:{description:"verifies the list of dependencies for Hooks like useEffect and similar",recommended:!0,url:"https://github.com/facebook/react/issues/14920"},fixable:"code",hasSuggestions:!0,schema:[{type:"object",additionalProperties:!1,ignoreIfReactCompilerIsEnabled:!1,enableDangerousAutofixThisMayCauseInfiniteLoops:!1,properties:{additionalHooks:{type:"string"},ignoreIfReactCompilerIsEnabled:{type:"boolean"},enableDangerousAutofixThisMayCauseInfiniteLoops:{type:"boolean"}}}]},create(e){let t=!1,n=typeof e.getSource=="function"?T=>n(T):T=>e.sourceCode.getText(T),o=typeof e.getScope=="function"?()=>o():T=>e.sourceCode.getScope(T),l=e.options&&e.options[0]&&e.options[0].additionalHooks?new RegExp(e.options[0].additionalHooks):void 0,f=e.options&&e.options[0]&&e.options[0].enableDangerousAutofixThisMayCauseInfiniteLoops||!1,p={additionalHooks:l,enableDangerousAutofixThisMayCauseInfiniteLoops:f};function r(T){f&&Array.isArray(T.suggest)&&T.suggest.length>0&&(T.fix=T.suggest[0].fix),e.report(T)}let a=e.getSourceCode().scopeManager,s=new WeakMap,i=new WeakSet,c=new WeakMap,y=new WeakMap,h=new WeakSet;function S(T,N){return function(v){if(N.has(v))return N.get(v);let g=T(v);return N.set(v,g),g}}function d(T,N,v,g,w){w&&T.async&&r({node:T,message:`Effect callbacks are synchronous to prevent race conditions. Put the async function inside:
1
+ "use strict";var fn=Object.create;var he=Object.defineProperty;var mn=Object.getOwnPropertyDescriptor;var dn=Object.getOwnPropertyNames;var yn=Object.getPrototypeOf,gn=Object.prototype.hasOwnProperty;var hn=(e,t)=>{for(var n in t)he(e,n,{get:t[n],enumerable:!0})},ct=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of dn(t))!gn.call(e,l)&&l!==n&&he(e,l,{get:()=>t[l],enumerable:!(s=mn(t,l))||s.enumerable});return e};var Ae=(e,t,n)=>(n=e!=null?fn(yn(e)):{},ct(t||!e||!e.__esModule?he(n,"default",{value:e,enumerable:!0}):n,e)),Tn=e=>ct(he({},"__esModule",{value:!0}),e);var Mr={};hn(Mr,{extendedLintPlugin:()=>jr});module.exports=Tn(Mr);var H=require("@typescript-eslint/utils");var Oe=Symbol.for("optional");function $(e){return{...e,[Oe]:!0}}function Te(e,t){return{enum:e,...t}}function oe(e){return{...e,type:"boolean"}}function F(e){return{...e,type:"string"}}function J(e){return{...e,type:"number"}}function pt(e){return{...e,type:"integer"}}function V(e,t){return{...t,type:"array",items:e}}function j(e,t){let n={...t,type:"object",properties:e};if(e&&(n.additionalProperties||=!1,!n.required)){let s,l=[];for(s in e)e[s][Oe]?e[s][Oe]=void 0:l.push(s);l.length>0&&(n.required=l)}return n}function Pe(...e){return{anyOf:e}}var Sn=H.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),ft="react-compiler-extra",En=j({runOnlyWithEnableCompilerDirective:$(oe())}),bn=/eslint +react-compiler\/react-compiler: +\["error/;function xn(e){return e.type===H.AST_NODE_TYPES.Identifier?e.name.startsWith("use"):e.type===H.AST_NODE_TYPES.MemberExpression&&e.property.type===H.AST_NODE_TYPES.Identifier?e.property.name.startsWith("use"):!1}var Cn=/\bthis[.[]/;function ut(e){return Cn.test(e)}var In=Sn({name:ft,meta:{type:"suggestion",fixable:"code",docs:{description:"Extra rules to enforce best practices when using the React compiler"},messages:{objectMethodIsNotSupported:"Object methods such as `{ method() {} }` have limited support to optimizations in the React compiler, use a function expression `{ method: () => {} }` instead.",replaceWithFunctionExpression:"Replace with function expression",thisKeywordInMethod:"Object method uses `this` keyword which would have different behavior if converted to an arrow function. Fix this manually."},hasSuggestions:!0,schema:[En]},defaultOptions:[{}],create(e,[t]){let n=!1;if(t.runOnlyWithEnableCompilerDirective){for(let f of e.sourceCode.getAllComments())if(bn.test(f.value)){n=!0;break}if(!n)return{}}function s(f){for(let p of f.properties)if(p.type===H.AST_NODE_TYPES.Property&&p.method&&p.value.type===H.AST_NODE_TYPES.FunctionExpression){let r=e.sourceCode,a=r.getText(p.key),o=p.value,i=r.getText(o.body);if(ut(i))e.report({node:p,messageId:"thisKeywordInMethod"});else{let c=o.params.map(T=>r.getText(T)).join(", "),g="";o.generator?g=`${a}: function* (${c}) ${i}`:g=`${a}: (${c}) => ${i}`,e.report({node:p,messageId:"objectMethodIsNotSupported",fix:T=>T.replaceText(p,g)})}}}function l(f){for(let p of f.properties)if(p.type===H.AST_NODE_TYPES.Property&&p.value.type===H.AST_NODE_TYPES.ObjectExpression){for(let r of p.value.properties)if(r.type===H.AST_NODE_TYPES.Property&&r.method&&r.value.type===H.AST_NODE_TYPES.FunctionExpression){let o=e.sourceCode.getText(r.value.body);ut(o)&&e.report({node:r,messageId:"thisKeywordInMethod"})}}}return{CallExpression(f){if(xn(f.callee))for(let p of f.arguments){if(p.type===H.AST_NODE_TYPES.ObjectExpression&&(s(p),l(p)),p.type===H.AST_NODE_TYPES.ArrowFunctionExpression&&(p.body.type===H.AST_NODE_TYPES.ObjectExpression&&(s(p.body),l(p.body)),p.body.type===H.AST_NODE_TYPES.BlockStatement))for(let r of p.body.body)r.type===H.AST_NODE_TYPES.ReturnStatement&&r.argument?.type===H.AST_NODE_TYPES.ObjectExpression&&(s(r.argument),l(r.argument));if(p.type===H.AST_NODE_TYPES.FunctionExpression)for(let r of p.body.body)r.type===H.AST_NODE_TYPES.ReturnStatement&&r.argument?.type===H.AST_NODE_TYPES.ObjectExpression&&(s(r.argument),l(r.argument))}}}}}),Ne={name:ft,rule:In};var ae=require("@typescript-eslint/utils");var wn=ae.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Rn=j({disallow:$(V(j({selector:F(),message:F(),replace:$(Pe(F(),j({regex:F(),with:F()}))),replaceType:$(Te(["suggestion","autofix"]))}))),__dev_simulateFileName:$(F()),mustMatchSyntax:$(V(j({includeRegex:F(),mustCallFn:V(j({anyCall:V(j({fn:F(),withArgs:V(j({atIndex:pt(),literal:Pe(F(),J(),oe())}))})),message:$(F())}))})))}),yt="advanced-no-restricted-syntax",vn=wn({name:yt,meta:{type:"suggestion",docs:{description:"Disallow specific syntax patterns"},schema:[Rn],messages:{default:"{{message}}"},fixable:"code",hasSuggestions:!0},defaultOptions:[{disallow:[]}],create(e,[t]){let n={},{mustMatchSyntax:s,__dev_simulateFileName:l,disallow:f}=t,p=l??e.filename,r=[],a=new Set;for(let{includeRegex:i,mustCallFn:c}of s??[]){let g=kn(p,new RegExp(i));if(!g)continue;let T=S=>{let d=S;for(let{name:b,value:y}of g)d=d.replaceAll(b,y);return d};for(let{anyCall:S,message:d}of c){let b=`Expected file to call the function: ${S.map(({fn:y})=>y).join(" or ")}`;a.add(b),r.push(y=>{let{callee:N}=y;if(N.type===ae.AST_NODE_TYPES.Identifier){for(let{fn:v,withArgs:h}of S)if(N.name===v){a.delete(b);for(let w of h){let R=y.arguments[w.atIndex],k=typeof w.literal=="string"?T(w.literal):w.literal;if(!R){e.report({node:y,messageId:"default",data:{message:`Missing argument with value "${k}" at index ${w.atIndex}${d?`: ${T(d)}`:""}`}});continue}if(R.type!==ae.AST_NODE_TYPES.Literal){e.report({node:R,messageId:"default",data:{message:`Argument at position ${w.atIndex} should the literal "${k}"${d?`: ${T(d)}`:""}`}});continue}R.value!==k&&e.report({node:R,messageId:"default",data:{message:`Argument should have the value "${k}"${d?`: ${T(d)}`:""}`},fix:D=>D.replaceText(R,typeof k=="string"?`'${k}'`:String(k))})}break}}})}}for(let{selector:i,message:c,replace:g,replaceType:T="suggestion"}of f??[]){if(i==="CallExpression"){r.push(S=>{o(g,S,c,T)});continue}n[i]=S=>{o(g,S,c,T)}}return r.length>0&&(n.CallExpression=i=>{if(i.type===ae.AST_NODE_TYPES.CallExpression)for(let c of r)c(i)}),n["Program:exit"]=i=>{for(let c of a)e.report({node:i,messageId:"default",data:{message:`${c}`}})},n;function o(i,c,g,T){let S=d=>{if(!i)return null;if(typeof i=="string")return d.replaceText(c,i);{let b=new RegExp(i.regex),y=e.sourceCode.getText(c);return d.replaceText(c,y.replace(b,i.with))}};e.report({node:c,messageId:"default",data:{message:g},fix:i&&T==="autofix"?S:void 0,suggest:i&&T==="suggestion"?[{messageId:"default",data:{message:`Replace with "${typeof i=="string"?i:i.with}"`},fix:S}]:void 0})}}});function kn(e,t){let n=[],s=t.exec(e);if(!s)return null;let[l,...f]=s;n.push({name:"$0_lowercase",value:l.toLowerCase()}),n.push({name:"$0_capitalize",value:mt(l)}),n.push({name:"$0_uncapitalize",value:dt(l)}),n.push({name:"$0",value:l});for(let p=0;p<f.length;p++){let r=`$${p+1}`,a=f[p];n.push({name:`${r}_lowercase`,value:a.toLowerCase()}),n.push({name:`${r}_capitalize`,value:mt(a)}),n.push({name:`${r}_uncapitalize`,value:dt(a)}),n.push({name:r,value:a})}return n}function mt(e){return e.charAt(0).toUpperCase()+e.slice(1)}function dt(e){return e.charAt(0).toLowerCase()+e.slice(1)}var De={name:yt,rule:vn};var _=require("@typescript-eslint/utils");var An=_.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),ht="collapse-simple-objs-in-one-line",On=j({maxLineLength:$(J()),maxProperties:$(J()),nestedObjMaxLineLength:$(J()),nestedObjMaxProperties:$(J()),ignoreTypesWithSuffix:$(V(F()))}),Pn=An({name:ht,meta:{type:"suggestion",fixable:"code",docs:{description:"Format simple objects and types in one line"},messages:{singleLineProp:"Object/type should be written in a single line"},schema:[On]},defaultOptions:[{}],create(e,[t]){let n=e.sourceCode,s=t.ignoreTypesWithSuffix??[],l=t.maxProperties??2,f=t.nestedObjMaxLineLength??t.maxLineLength,p=t.nestedObjMaxProperties??3;function r(o){if(o.type===_.AST_NODE_TYPES.ObjectExpression){let i=o.parent.type===_.AST_NODE_TYPES.Property,c=i?p:l,g=o.properties.length;if(g>c)return!1;if(g===1){let S=o.properties[0];return S.type===_.AST_NODE_TYPES.Property&&(S.value.type===_.AST_NODE_TYPES.ObjectExpression||S.value.type===_.AST_NODE_TYPES.ArrayExpression)?!1:{text:n.getText(S),isNested:i,propsSize:g}}let T=[];for(let S of o.properties){if(S.type===_.AST_NODE_TYPES.Property){let d=S.value.type;if(!(d===_.AST_NODE_TYPES.Literal||d===_.AST_NODE_TYPES.Identifier||d===_.AST_NODE_TYPES.TemplateLiteral||d===_.AST_NODE_TYPES.TaggedTemplateExpression))return!1}T.push(n.getText(S))}return{text:T.join(", "),isNested:i,propsSize:g}}else{let i=o.parent.parent?.type===_.AST_NODE_TYPES.TSPropertySignature,c=i?p:l,g=o.members.length;if(g>c)return!1;if(s.length>0&&o.parent.type===_.AST_NODE_TYPES.TSTypeAliasDeclaration){let S=o.parent.id.name;if(s.some(d=>S.endsWith(d)))return!1}if(g===1){let S=o.members[0];return S.type===_.AST_NODE_TYPES.TSPropertySignature&&S.typeAnnotation?.typeAnnotation.type===_.AST_NODE_TYPES.TSTypeLiteral?!1:{text:n.getText(S),isNested:i,propsSize:1}}if(o.parent.type===_.AST_NODE_TYPES.TSIntersectionType||o.parent.type===_.AST_NODE_TYPES.TSUnionType)return!1;let T=[];for(let S of o.members){if(S.type!==_.AST_NODE_TYPES.TSPropertySignature)return!1;let d=S.typeAnnotation?.typeAnnotation;if(!d||d.type===_.AST_NODE_TYPES.TSTypeLiteral||!gt(d.type))return!1;if(d.type===_.AST_NODE_TYPES.TSTypeReference&&d.typeArguments){if(d.typeArguments.params.length>1)return!1;let y=d.typeArguments.params[0];if(!gt(y.type))return!1}let b=n.getText(S).trim();(b.endsWith(";")||b.endsWith(","))&&(b=b.slice(0,-1)),T.push(b)}return{text:T.join("; "),isNested:i,propsSize:g}}}function a(o){if(o.loc.start.line===o.loc.end.line)return;if(o.parent.type!==_.AST_NODE_TYPES.JSXExpressionContainer){let d=0,b=n.getTokenAfter(o,{filter:y=>y.type!==_.AST_TOKEN_TYPES.Punctuator?!0:y.value===","||y.value===";"||y.value===")"||y.value==="}"?(d++,!1):!0});if(d>2||b?.loc.start.line===o.loc.end.line)return}let i=r(o);if(!i)return;let c=i.text;if(c.includes(`
2
+ `)||n.getCommentsInside(o).length>0)return;c.endsWith(";")&&(c=c.slice(0,-1));let g=`{ ${c} }`,T=Dn(n,o),S=i.isNested&&i.propsSize>2?f:t.maxLineLength;S&&g.length+T.length+Nn(o,n)>S||e.report({node:o,messageId:"singleLineProp",fix:d=>d.replaceText(o,g)})}return{TSTypeLiteral:a,ObjectExpression:a}}});function gt(e){return e===_.AST_NODE_TYPES.TSLiteralType||e===_.AST_NODE_TYPES.TSTypeReference||e===_.AST_NODE_TYPES.TSNumberKeyword||e===_.AST_NODE_TYPES.TSStringKeyword||e===_.AST_NODE_TYPES.TSBooleanKeyword||e===_.AST_NODE_TYPES.TSNullKeyword||e===_.AST_NODE_TYPES.TSUndefinedKeyword}function Nn(e,t){let n=t.getLastToken(e);if(!n)return 0;let s=t.text.indexOf(`
3
+ `,n.range[1]);return(s!==-1?s:t.text.length)-n.range[1]}function Dn(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}var _e={name:ht,rule:Pn};var _n=/eslint +react-compiler\/react-compiler: +\["error/,St={meta:{type:"suggestion",docs:{description:"verifies the list of dependencies for Hooks like useEffect and similar",recommended:!0,url:"https://github.com/facebook/react/issues/14920"},fixable:"code",hasSuggestions:!0,schema:[{type:"object",additionalProperties:!1,ignoreIfReactCompilerIsEnabled:!1,enableDangerousAutofixThisMayCauseInfiniteLoops:!1,properties:{additionalHooks:{type:"string"},ignoreIfReactCompilerIsEnabled:{type:"boolean"},enableDangerousAutofixThisMayCauseInfiniteLoops:{type:"boolean"}}}]},create(e){let t=!1,n=typeof e.getSource=="function"?y=>n(y):y=>e.sourceCode.getText(y),s=typeof e.getScope=="function"?()=>s():y=>e.sourceCode.getScope(y),l=e.options&&e.options[0]&&e.options[0].additionalHooks?new RegExp(e.options[0].additionalHooks):void 0,f=e.options&&e.options[0]&&e.options[0].enableDangerousAutofixThisMayCauseInfiniteLoops||!1,p={additionalHooks:l,enableDangerousAutofixThisMayCauseInfiniteLoops:f};function r(y){f&&Array.isArray(y.suggest)&&y.suggest.length>0&&(y.fix=y.suggest[0].fix),e.report(y)}let a=e.getSourceCode().scopeManager,o=new WeakMap,i=new WeakSet,c=new WeakMap,g=new WeakMap,T=new WeakSet;function S(y,N){return function(v){if(N.has(v))return N.get(v);let h=y(v);return N.set(v,h),h}}function d(y,N,v,h,w){w&&y.async&&r({node:y,message:`Effect callbacks are synchronous to prevent race conditions. Put the async function inside:
3
4
 
4
5
  useEffect(() => {
5
6
  async function fetchData() {
@@ -10,5 +11,5 @@ useEffect(() => {
10
11
  fetchData();
11
12
  }, [someId]); // Or [] if effect doesn't need props or state
12
13
 
13
- Learn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching`});let R=a.acquire(T),k=new Set,_=null;{let u=R.upper;for(;u&&(k.add(u),u.type!=="function");)u=u.upper;if(!u)return;_=u}let A=Array.isArray;function W(u){if(!A(u.defs))return!1;let m=u.defs[0];if(m==null||m.node.type!=="VariableDeclarator")return!1;let b=m.node.init;if(b==null)return!1;for(;b.type==="TSAsExpression";)b=b.expression;let x=m.node.parent;if(x==null&&(Fe(_.block,m.node.id),x=m.node.parent,x==null))return!1;if(x.kind==="const"&&b.type==="Literal"&&(typeof b.value=="string"||typeof b.value=="number"||b.value===null))return!0;if(b.type!=="CallExpression")return!1;let I=b.callee;if(I.type==="MemberExpression"&&I.object.name==="React"&&I.property!=null&&!I.computed&&(I=I.property),I.type!=="Identifier")return!1;let C=m.node.id,{name:O}=I;if(O==="useRef"&&C.type==="Identifier")return!0;if(Mn(I)&&C.type==="Identifier"){for(let P of u.references)P!==C&&h.add(P.identifier);return!0}else if(O==="useState"||O==="useReducer"){if(C.type==="ArrayPattern"&&C.elements.length===2&&A(u.identifiers)){if(C.elements[1]===u.identifiers[0]){if(O==="useState"){let P=u.references,q=0;for(let Z=0;Z<P.length;Z++){if(P[Z].isWrite()&&q++,q>1)return!1;s.set(P[Z].identifier,C.elements[0])}}return!0}else if(C.elements[0]===u.identifiers[0]){if(O==="useState"){let P=u.references;for(let q=0;q<P.length;q++)i.add(P[q].identifier)}return!1}}}else if(O==="useTransition"&&C.type==="ArrayPattern"&&C.elements.length===2&&Array.isArray(u.identifiers)&&C.elements[1]===u.identifiers[0])return!0;return!1}function X(u){if(!A(u.defs))return!1;let m=u.defs[0];if(m==null||m.node==null||m.node.id==null)return!1;let b=m.node,x=_.childScopes,I=null,C;for(C=0;C<x.length;C++){let O=x[C],P=O.block;if(b.type==="FunctionDeclaration"&&P===b||b.type==="VariableDeclarator"&&P.parent===b){I=O;break}}if(I==null)return!1;for(C=0;C<I.through.length;C++){let O=I.through[C];if(O.resolved!=null&&k.has(O.resolved.scope)&&!rt(O.resolved))return!1}return!0}let rt=S(W,c),sn=S(X,y),it=new Map;function on(u){let m=u.from,b=!1;for(;m.block!==T;)m.type==="function"&&(b=m.block.parent!=null&&m.block.parent.type==="ReturnStatement"),m=m.upper;return b}let B=new Map,we=new Map;st(R);function st(u){for(let m of u.references){if(!m.resolved||!k.has(m.resolved.scope))continue;let b=Fe(T,m.identifier),x=Et(b),I=Q(x,we);if(w&&x.type==="Identifier"&&(x.parent.type==="MemberExpression"||x.parent.type==="OptionalMemberExpression")&&!x.parent.computed&&x.parent.property.type==="Identifier"&&x.parent.property.name==="current"&&on(m)&&it.set(I,{reference:m,dependencyNode:x}),x.parent.type==="TSTypeQuery"||x.parent.type==="TSTypeReference")continue;let C=m.resolved.defs[0];if(C!=null&&!(C.node!=null&&C.node.init===T.parent)&&C.type!=="TypeParameter")if(B.has(I))B.get(I).references.push(m);else{let O=m.resolved,P=rt(O)||sn(O);B.set(I,{isStable:P,references:[m]})}}for(let m of u.childScopes)st(m)}it.forEach(({reference:u,dependencyNode:m},b)=>{let x=u.resolved.references,I=!1;for(let C=0;C<x.length;C++){let{identifier:O}=x[C],{parent:P}=O;if(P!=null&&P.type==="MemberExpression"&&!P.computed&&P.property.type==="Identifier"&&P.property.name==="current"&&P.parent.type==="AssignmentExpression"&&P.parent.left===P){I=!0;break}}I||r({node:m.parent.property,message:`The ref value '${b}.current' will likely have changed by the time this effect cleanup function runs. If this ref points to a node rendered by React, copy '${b}.current' to a variable inside the effect, and use that variable in the cleanup function.`})});let Re=new Set;function an(u,m){Re.has(m)||(Re.add(m),r({node:u,message:`Assignments to the '${m}' variable from inside React Hook ${n(v)} will be lost after each render. To preserve the value over time, store it in a useRef Hook and keep the mutable value in the '.current' property. Otherwise, you can move this variable directly inside ${n(v)}.`}))}let de=new Set;if(B.forEach(({isStable:u,references:m},b)=>{u&&de.add(b),m.forEach(x=>{x.writeExpr&&an(x.writeExpr,b)})}),Re.size>0)return;if(!N){let u=null;if(B.forEach(({isStable:m,references:b},x)=>{u||b.forEach(I=>{if(u)return;let C=I.identifier;if(!s.has(C))return;let P=I.from;for(;P.type!=="function";)P=P.upper;P.block===T&&(u=x)})}),u){let{suggestedDependencies:m}=Le({dependencies:B,declaredDependencies:[],stableDependencies:de,externalDependencies:new Set,isEffect:!0});r({node:v,message:`React Hook ${g} contains a call to '${u}'. Without a list of dependencies, this can lead to an infinite chain of updates. To fix this, pass [`+m.join(", ")+`] as a second argument to the ${g} Hook.`,suggest:[{desc:`Add dependencies array: [${m.join(", ")}]`,fix(b){return b.insertTextAfter(T,`, [${m.join(", ")}]`)}}]})}return}let ue=[],fe=new Set;N.type!=="ArrayExpression"?r({node:N,message:`React Hook ${n(v)} 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.`}):N.elements.forEach(u=>{if(u===null)return;if(u.type==="SpreadElement"){r({node:u,message:`React Hook ${n(v)} has a spread element in its dependency array. This means we can't statically verify whether you've passed the correct dependencies.`});return}h.has(u)&&r({node:u,message:`Functions returned from \`useEffectEvent\` must not be included in the dependency array. Remove \`${n(u)}\` from the list.`,suggest:[{desc:`Remove the dependency \`${n(u)}\``,fix(I){return I.removeRange(u.range)}}]});let m;try{m=Q(u,we)}catch(I){if(/Unsupported node type/.test(I.message)){u.type==="Literal"?B.has(u.value)?r({node:u,message:`The ${u.raw} literal is not a valid dependency because it never changes. Did you mean to include ${u.value} in the array instead?`}):r({node:u,message:`The ${u.raw} literal is not a valid dependency because it never changes. You can safely remove it.`}):r({node:u,message:`React Hook ${n(v)} has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked.`});return}else throw I}let b=u;for(;b.type==="MemberExpression"||b.type==="OptionalMemberExpression"||b.type==="ChainExpression";)b=b.object||b.expression.object;let x=!_.through.some(I=>I.identifier===b);ue.push({key:m,node:u}),x||fe.add(m)});let{suggestedDependencies:ln,unnecessaryDependencies:ye,missingDependencies:ne,duplicateDependencies:ot}=Le({dependencies:B,declaredDependencies:ue,stableDependencies:de,externalDependencies:fe,isEffect:w}),ge=ln;if(ot.size+ne.size+ye.size===0){if(t)return;Ln({declaredDependencies:ue,declaredDependenciesNode:N,componentScope:_,scope:R}).forEach(({construction:m,isUsedOutsideOfHook:b,depType:x})=>{let I=x==="function"?"useCallback":"useMemo",C=x==="function"?"definition":"initialization",O=`wrap the ${C} of '${m.name.name}' in its own ${I}() Hook.`,P=b?`To fix this, ${O}`:`Move it inside the ${g} callback. Alternatively, ${O}`,q=x==="conditional"||x==="logical expression"?"could make":"makes",Z=`The '${m.name.name}' ${x} ${q} the dependencies of ${g} Hook (at line ${N.loc.start.line}) change on every render. ${P}`,at;b&&m.type==="Variable"&&x==="function"&&(at=[{desc:`Wrap the ${C} of '${m.name.name}' in its own ${I}() Hook.`,fix(lt){let[pn,un]=I==="useMemo"?["useMemo(() => { return ","; })"]:["useCallback(",")"];return[lt.insertTextBefore(m.node.init,pn),lt.insertTextAfter(m.node.init,un)]}}]),r({node:m.node,message:Z,suggest:at})});return}!w&&ne.size>0&&(ge=Le({dependencies:B,declaredDependencies:[],stableDependencies:de,externalDependencies:fe,isEffect:w}).suggestedDependencies);function cn(){if(ue.length===0)return!0;let u=ue.map(b=>b.key),m=u.slice().sort();return u.join(",")===m.join(",")}cn()&&ge.sort();function ve(u){let m=u.split("."),b="";for(let x=0;x<m.length;x++){if(x!==0){let I=m.slice(0,x+1).join("."),C=we.get(I)===!0;b+=C?"?.":"."}b+=m[x]}return b}function ke(u,m,b,x){return u.size===0?null:(u.size>1?"":m+" ")+b+" "+(u.size>1?"dependencies":"dependency")+": "+Fn(Array.from(u).sort().map(I=>"'"+ve(I)+"'"))+`. Either ${x} ${u.size>1?"them":"it"} or remove the dependency array.`}let K="";if(ye.size>0){let u=null;if(Array.from(ye.keys()).forEach(m=>{u===null&&m.endsWith(".current")&&(u=m)}),u!==null)K=` Mutable values like '${u}' aren't valid dependencies because mutating them doesn't re-render the component.`;else if(fe.size>0){let m=Array.from(fe)[0];R.set.has(m)||(K=` Outer scope values like '${m}' aren't valid dependencies because mutating them doesn't re-render the component.`)}}if(!K&&ne.has("props")){let u=B.get("props");if(u==null)return;let m=u.references;if(!Array.isArray(m))return;let b=!0;for(let x=0;x<m.length;x++){let I=m[x],C=Fe(_.block,I.identifier);if(!C){b=!1;break}let O=C.parent;if(O==null){b=!1;break}if(O.type!=="MemberExpression"&&O.type!=="OptionalMemberExpression"){b=!1;break}}b&&(K=` 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 ${n(v)}.`)}if(!K&&ne.size>0){let u=null;ne.forEach(m=>{if(u)return;let b=_.set.get(m),x=B.get(m);if(x.references[0].resolved!==b)return;let I=b.defs[0];if(I==null||I.name==null||I.type!=="Parameter")return;let C=!1,O;for(let P=0;P<x.references.length;P++)if(O=x.references[P].identifier,O!=null&&O.parent!=null&&(O.parent.type==="CallExpression"||O.parent.type==="OptionalCallExpression")&&O.parent.callee===O){C=!0;break}C&&(u=m)}),u!==null&&(K=` If '${u}' changes too often, find the parent component that defines it and wrap that definition in useCallback.`)}if(!K&&ne.size>0){let u=null;if(ne.forEach(m=>{if(u!==null)return;let x=B.get(m).references,I,C;for(let O=0;O<x.length;O++){for(I=x[O].identifier,C=I.parent;C!=null&&C!==_.block;){if(C.type==="CallExpression"){let P=s.get(C.callee);if(P!=null){if(P.name===m)u={missingDep:m,setter:C.callee.name,form:"updater"};else if(i.has(I))u={missingDep:m,setter:C.callee.name,form:"reducer"};else{let q=x[O].resolved;if(q!=null){let Z=q.defs[0];Z!=null&&Z.type==="Parameter"&&(u={missingDep:m,setter:C.callee.name,form:"inlineReducer"})}}break}}C=C.parent}if(u!==null)break}}),u!==null)switch(u.form){case"reducer":K=` You can also replace multiple useState variables with useReducer if '${u.setter}' needs the current value of '${u.missingDep}'.`;break;case"inlineReducer":K=` If '${u.setter}' needs the current value of '${u.missingDep}', you can also switch to useReducer instead of useState and read '${u.missingDep}' in the reducer.`;break;case"updater":K=` You can also do a functional update '${u.setter}(${u.missingDep.slice(0,1)} => ...)' if you only need '${u.missingDep}' in the '${u.setter}' call.`;break;default:throw new Error("Unknown case.")}}r({node:N,message:`React Hook ${n(v)} has `+(ke(ne,"a","missing","include")||ke(ye,"an","unnecessary","exclude")||ke(ot,"a","duplicate","omit"))+K,suggest:[{desc:`Update the dependencies array to be: [${ge.map(ve).join(", ")}]`,fix(u){return u.replaceText(N,`[${ge.map(ve).join(", ")}]`)}}]})}function E(T){let N=$n(T.callee,p);if(N===-1)return;let v=T.arguments[N],g=T.callee,w=bt(g).name,R=T.arguments[N+1],k=/Effect($|[^a-z])/g.test(w);if(!v){r({node:g,message:`React Hook ${w} requires an effect callback. Did you forget to pass a callback to the hook?`});return}if(!(t&&!k)){if(!R&&!k){(w==="useMemo"||w==="useCallback")&&r({node:g,message:`React Hook ${w} does nothing when called with only one argument. Did you forget to pass an array of dependencies?`});return}switch(v.type){case"FunctionExpression":case"ArrowFunctionExpression":d(v,R,g,w,k);return;case"Identifier":if(!R||R.elements&&R.elements.some(W=>W&&W.type==="Identifier"&&W.name===v.name))return;let _=o(T).set.get(v.name);if(_==null||_.defs==null)return;let A=_.defs[0];if(!A||!A.node||A.type!=="Variable"&&A.type!=="FunctionName")break;switch(A.node.type){case"FunctionDeclaration":d(A.node,R,g,w,k);return;case"VariableDeclarator":let W=A.node.init;if(!W)break;switch(W.type){case"ArrowFunctionExpression":case"FunctionExpression":d(W,R,g,w,k);return}break}break;default:r({node:g,message:`React Hook ${w} received a function whose dependencies are unknown. Pass an inline function instead.`});return}r({node:g,message:`React Hook ${w} has a missing dependency: '${v.name}'. Either include it or remove the dependency array.`,suggest:[{desc:`Update the dependencies array to be: [${v.name}]`,fix(_){return _.replaceText(R,`[${v.name}]`)}}]})}}if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let T of e.sourceCode.getAllComments())if(_n.test(T.value))return t=!0,{CallExpression:N=>E(N,!0)}}return{CallExpression:T=>E(T)}}};function Le({dependencies:e,declaredDependencies:t,stableDependencies:n,externalDependencies:o,isEffect:l}){let f=p();function p(){return{isUsed:!1,isSatisfiedRecursively:!1,isSubtreeUsed:!1,children:new Map}}e.forEach((d,E)=>{let T=r(f,E);T.isUsed=!0,a(f,E,N=>{N.isSubtreeUsed=!0})}),t.forEach(({key:d})=>{let E=r(f,d);E.isSatisfiedRecursively=!0}),n.forEach(d=>{let E=r(f,d);E.isSatisfiedRecursively=!0});function r(d,E){let T=E.split("."),N=d;for(let v of T){let g=N.children.get(v);g||(g=p(),N.children.set(v,g)),N=g}return N}function a(d,E,T){let N=E.split("."),v=d;for(let g of N){let w=v.children.get(g);if(!w)return;T(w),v=w}}let s=new Set,i=new Set;c(f,s,i,d=>d);function c(d,E,T,N){d.children.forEach((v,g)=>{let w=N(g);if(v.isSatisfiedRecursively){v.isSubtreeUsed&&T.add(w);return}if(v.isUsed){E.add(w);return}c(v,E,T,R=>w+"."+R)})}let y=[],h=new Set,S=new Set;return t.forEach(({key:d})=>{i.has(d)?y.indexOf(d)===-1?y.push(d):S.add(d):h.add(d)}),s.forEach(d=>{y.push(d)}),{suggestedDependencies:y,unnecessaryDependencies:h,duplicateDependencies:S,missingDependencies:s}}function re(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 re(e.consequent)!=null||re(e.alternate)!=null?"conditional":null;case"LogicalExpression":return re(e.left)!=null||re(e.right)!=null?"logical expression":null;case"JSXFragment":return"JSX fragment";case"JSXElement":return"JSX element";case"AssignmentExpression":return re(e.right)!=null?"assignment expression":null;case"NewExpression":return"object construction";case"Literal":return e.value instanceof RegExp?"regular expression":null;case"TypeCastExpression":return re(e.expression);case"TSAsExpression":return re(e.expression)}return null}function Ln({declaredDependencies:e,declaredDependenciesNode:t,componentScope:n,scope:o}){let l=e.map(({key:p})=>{let r=n.variables.find(s=>s.name===p);if(r==null)return null;let a=r.defs[0];if(a==null)return null;if(a.type==="Variable"&&a.node.type==="VariableDeclarator"&&a.node.id.type==="Identifier"&&a.node.init!=null){let s=re(a.node.init);if(s!=null)return[r,s]}return a.type==="FunctionName"&&a.node.type==="FunctionDeclaration"?[r,"function"]:a.type==="ClassName"&&a.node.type==="ClassDeclaration"?[r,"class"]:null}).filter(Boolean);function f(p){let r=!1;for(let a=0;a<p.references.length;a++){let s=p.references[a];if(s.writeExpr){if(r)return!0;r=!0;continue}let i=s.from;for(;i!==o&&i!=null;)i=i.upper;if(i!==o&&!xt(t,s.identifier))return!0}return!1}return l.map(([p,r])=>({construction:p.defs[0],depType:r,isUsedOutsideOfHook:f(p)}))}function Et(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)?Et(e.parent):e.type==="MemberExpression"&&e.parent&&e.parent.type==="AssignmentExpression"&&e.parent.left===e?e.object:e}function $e(e,t,n){t&&(e.optional?t.has(n)||t.set(n,!0):t.has(n)||t.set(n,!1))}function Q(e,t){if(e.type==="Identifier"||e.type==="JSXIdentifier"){let n=e.name;return t&&t.set(n,!1),n}else if(e.type==="MemberExpression"&&!e.computed){let n=Q(e.object,t),o=Q(e.property,null),l=`${n}.${o}`;return $e(e,t,l),l}else if(e.type==="OptionalMemberExpression"&&!e.computed){let n=Q(e.object,t),o=Q(e.property,null),l=`${n}.${o}`;return $e(e,t,l),l}else if(e.type==="ChainExpression"&&!e.computed){let n=e.expression;if(n.type==="CallExpression")throw new Error(`Unsupported node type: ${n.type}`);let o=Q(n.object,t),l=Q(n.property,null),f=`${o}.${l}`;return $e(n,t,f),f}else throw new Error(`Unsupported node type: ${e.type}`)}function bt(e,t){return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.object.name==="React"&&e.property.type==="Identifier"&&!e.computed?e.property:e}function $n(e,t){let n=bt(e);if(n.type!=="Identifier")return-1;switch(n.name){case"useEffect":case"useLayoutEffect":case"useCallback":case"useMemo":return 0;case"useImperativeHandle":return 1;default:if(n===e&&t&&t.additionalHooks){let o;try{o=Q(n,null)}catch(l){if(/Unsupported node type/.test(l.message))return 0;throw l}return t.additionalHooks.test(o)?0:-1}else return-1}}function Fe(e,t){let n=[e],o=null;for(;n.length;){if(o=n.shift(),jn(o,t))return o;if(xt(o,t))for(let[l,f]of Object.entries(o))l!=="parent"&&(Tt(f)?(f.parent=o,n.push(f)):Array.isArray(f)&&f.forEach(p=>{Tt(p)&&(p.parent=o,n.push(p))}))}return null}function Fn(e){let t="";for(let n=0;n<e.length;n++)t+=e[n],n===0&&e.length===2?t+=" and ":n===e.length-2&&e.length>2?t+=", and ":n<e.length-1&&(t+=", ");return t}function Tt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function jn(e,t){return(e.type==="Identifier"||e.type==="JSXIdentifier")&&e.type===t.type&&e.name===t.name&&e.range[0]===t.range[0]&&e.range[1]===t.range[1]}function xt(e,t){return e.range[0]<=t.range[0]&&e.range[1]>=t.range[1]}function Mn(e){return!1}var ie=require("@typescript-eslint/utils");var Y=Ae(require("typescript")),Un=ie.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ct="improved-no-unnecessary-condition",Wn=j({}),Hn=["string","number","bigint","boolean","symbol","undefined","object","function","never"],Vn=new Set(Hn),je={name:Ct,rule:Un({name:Ct,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:[Wn]},defaultOptions:[{}],create(e){let t=ie.ESLintUtils.getParserServices(e,!0),n=t.program?.getTypeChecker();if(!n||!t.program)throw new Error("TypeScript services or program not available");function o(r){return r.type===ie.AST_NODE_TYPES.UnaryExpression&&r.operator==="typeof"}function l(r){return r.flags&Y.default.TypeFlags.Any||r.flags&Y.default.TypeFlags.Unknown?null:r.flags&Y.default.TypeFlags.StringLike?["string"]:r.flags&Y.default.TypeFlags.NumberLike?["number"]:r.flags&Y.default.TypeFlags.BigIntLike?["bigint"]:r.flags&Y.default.TypeFlags.BooleanLike?["boolean"]:r.flags&Y.default.TypeFlags.ESSymbolLike?["symbol"]:r.flags&Y.default.TypeFlags.Undefined||r.flags&Y.default.TypeFlags.Void?["undefined"]:r.flags&Y.default.TypeFlags.Null?["object"]:r.getCallSignatures().length>0?["function"]:r.flags&Y.default.TypeFlags.Object?r.getProperties().length===0?["string","number","bigint","boolean","symbol","object","function"]:["object"]:r.flags&Y.default.TypeFlags.NonPrimitive?["object"]:r.flags&Y.default.TypeFlags.Never?["never"]:null}function f(r){if(!n)return null;let a=t.esTreeNodeToTSNodeMap.get(r),s=n.getTypeAtLocation(a.expression);if(s.flags&Y.default.TypeFlags.Any||s.flags&Y.default.TypeFlags.Unknown)return null;let i=[];if(s.isUnion()){for(let y of s.types){let h=l(y);if(h)i.push(...h);else return null}return i}let c=l(s);return c?(i.push(...c),i):null}function p(r){if(!(r.operator==="==="||r.operator==="!=="))return;let s=null,i=null;if(o(r.left)?(s=r.left,i=r.right.type===ie.AST_NODE_TYPES.Literal&&typeof r.right.value=="string"?r.right.value:null):o(r.right)&&(s=r.right,i=r.left.type===ie.AST_NODE_TYPES.Literal&&typeof r.left.value=="string"?r.left.value:null),!s||!i||!Yn(i,Vn))return;let c=f(s);if(!c)return;let y=r.operator==="!==",h=c.includes(i);c.length===1?h&&!y?e.report({node:r,messageId:"unnecessaryTypeofCondition",data:{name:le(s,e),type:i}}):!h&&y?e.report({node:r,messageId:"unnecessaryTypeofCondition",data:{name:le(s,e),type:Array.from(c)[0]}}):!h&&!y?e.report({node:r,messageId:"alwaysFalseTypeofCondition",data:{name:le(s,e),actualType:Se(c),conditionType:i}}):h&&y&&e.report({node:r,messageId:"alwaysFalseTypeofCondition",data:{name:le(s,e),actualType:Se(c),conditionType:i}}):!h&&!y?e.report({node:r,messageId:"alwaysFalseTypeofCondition",data:{name:le(s,e),actualType:Se(c),conditionType:i}}):!h&&y&&e.report({node:r,messageId:"unnecessaryTypeofCondition",data:{name:le(s,e),type:Se(c)}})}return{BinaryExpression:p}}})};function Se(e){return Array.from(new Set(e)).join(" | ")||"never"}function le(e,t){let n=e.argument;return n.type===ie.AST_NODE_TYPES.Identifier?n.name:t.sourceCode.getText(n)}function Yn(e,t){return t.has(e)}var Ee=require("@typescript-eslint/utils");var zn=Ee.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),It="no-call-with-explicit-generics",Bn=j({functions:V(F())}),qn=zn({name:It,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:[Bn]},defaultOptions:[{functions:[]}],create(e,[t]){let n=new Set(t.functions);return{CallExpression(o){let{callee:l}=o;l.type===Ee.AST_NODE_TYPES.Identifier&&n.has(l.name)&&o.typeArguments&&e.report({node:o,messageId:"noExplicitGenerics",data:{functionName:l.name}})}}}}),Me={name:It,rule:qn};var se=require("@typescript-eslint/utils"),Kn=se.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),wt="no-call-with-inferred-generics",Xn=Kn({name:wt,meta:{type:"problem",docs:{description:"Disable calling configured functions with infered generics"},messages:{missingGenericDeclaration:"Function '{{ functionName }}' should be called with at least {{ minGenerics }} generic(s) (ex: `fn<Generic>()`) defined",anyUsedInGenerics:"Function '{{ functionName }}' should not be called with 'any' in generics"},schema:[{type:"object",properties:{functions:{type:"array",items:{type:"object",properties:{name:{type:"string"},minGenerics:{type:"number"},allowAny:{type:"boolean"},disallowTypes:{type:"array",items:{type:"string"}}},required:["name"]}},anyAliases:{type:"array",items:{type:"string"}}},required:["functions"]}]},defaultOptions:[{functions:[]}],create(e,[t]){let n=new Map(t.functions.map(o=>[o.name,o]));return{CallExpression(o){let{callee:l}=o;if(l.type!==se.AST_NODE_TYPES.Identifier)return;let f=n.get(l.name);if(!f)return;let{minGenerics:p=1,allowAny:r,disallowTypes:a=t.disallowTypes}=f;(o.typeArguments?.params.length||0)<(p||0)&&e.report({node:o,messageId:"missingGenericDeclaration",data:{functionName:l.name,minGenerics:p||0}}),!(r&&!a)&&o.typeArguments?.params?.some(i=>!r&&i.type===se.AST_NODE_TYPES.TSAnyKeyword||a&&i.type===se.AST_NODE_TYPES.TSTypeReference&&i.typeName.type===se.AST_NODE_TYPES.Identifier&&a.includes(i.typeName.name))&&e.report({node:o,messageId:"anyUsedInGenerics",data:{functionName:l.name}})}}}}),Ue={name:wt,rule:Xn};var me=require("@typescript-eslint/utils"),Jn=me.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Rt="no-commented-out-code",Gn=["function ","class ","interface ","type ","enum ","namespace ","import ","export ","const ","let ","var ","return "],Zn=[") {","return;","if (","else {","for (","switch (","/>","</","},",": {"," } = ","={",/\w=("|')/,");"],Qn=Jn({name:Rt,meta:{type:"problem",docs:{description:"Disallow commented code"},messages:{commentedOutCode:"Commented code is not allowed. Detected pattern: `{{ wrongPattern }}` Use a comment starting with `INFO:` if you want to keep this code commented out."},schema:[]},defaultOptions:[],create(e){function t(n){if(n.startsWith("/"))return!1;let o=n.trimStart();if(n.startsWith("*")||o.startsWith("INFO:")||o.startsWith("TODO:")||o.startsWith("DOCS:")||o.startsWith("FIX:")||o.startsWith("eslint-disable")||n.includes("@deprecated")||n.includes("@example"))return!1;for(let l of Gn)if(o.startsWith(l))return{wrongPattern:l};for(let l of Zn)if(typeof l=="string"){if(n.includes(l))return{wrongPattern:l}}else if(l.test(n))return{wrongPattern:`regex(${l.toString()})`};return!1}return{Program(){let o=e.sourceCode.getAllComments();for(let l of o)if(l.type===me.TSESTree.AST_TOKEN_TYPES.Line||l.type===me.TSESTree.AST_TOKEN_TYPES.Block){let f=t(l.value);f&&e.report({node:l,messageId:"commentedOutCode",data:{wrongPattern:f.wrongPattern}})}}}}}),We={name:Rt,rule:Qn};var be=require("@typescript-eslint/utils"),er=be.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),vt="no-default-export",tr=er({name:vt,meta:{type:"problem",docs:{description:"Disallow default exports"},schema:[],messages:{noDefaultExport:"Default exports are not allowed, use named exports instead."}},defaultOptions:[],create(e){return{ExportDefaultDeclaration(t){e.report({node:t,messageId:"noDefaultExport"})},ExportNamedDeclaration(t){for(let n of t.specifiers)n.exported.type===be.TSESTree.AST_NODE_TYPES.Identifier&&n.exported.name==="default"&&e.report({node:t,messageId:"noDefaultExport"})}}}}),He={name:vt,rule:tr};var kt=require("@typescript-eslint/utils"),nr=kt.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),At="no-leaked-text-in-jsx",rr=[",",";","[","]","(",")"],ir=nr({name:At,meta:{type:"problem",docs:{description:"Prevents leaking of text in JSX that should be wrapped in an expression container"},messages:{leakedTextInJSX:'Text "{{ text }}" should be wrapped in a JSX expression container.'},schema:[],fixable:"code"},defaultOptions:[],create(e){return{JSXText(t){let n=t.value.trim();if(!n)return;let o="";rr.includes(n)?o=n:n.includes("&&")?o="&&":n.includes("||")?o="||":n.endsWith("? (")&&(o="? ("),o&&e.report({node:t,messageId:"leakedTextInJSX",data:{text:o}})}}}}),Ve={name:At,rule:ir};var ee=require("@typescript-eslint/utils"),sr=ee.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Pt="no-non-camel-case-functions",or=/^[a-z][a-zA-Z0-9]*$/;function Ot(e){return e.typeName.type===ee.AST_NODE_TYPES.TSQualifiedName&&e.typeName.left.type===ee.AST_NODE_TYPES.Identifier&&e.typeName.left.name==="JSX"&&e.typeName.right.type===ee.AST_NODE_TYPES.Identifier&&e.typeName.right.name==="Element"}var ar=sr({name:Pt,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&&!or.test(t.id.name)){let n=t.returnType?.typeAnnotation;if(n&&(n.type===ee.AST_NODE_TYPES.TSTypeReference?Ot(n):n.type===ee.AST_NODE_TYPES.TSUnionType&&n.types.some(l=>l.type===ee.AST_NODE_TYPES.TSTypeReference&&Ot(l))))return;e.report({node:t.id,messageId:"nonCamelCaseFunction",data:{functionName:t.id.name}})}}}}}),Ye={name:Pt,rule:ar};var M=require("@typescript-eslint/utils");function ce(e,t,n=1/0){if(n!==0&&e.parent)return e.type===t?e:ce(e.parent,t,n===1/0?n:n-1)}function*ze(e){yield e,e.parent&&(yield*ze(e.parent))}var lr=M.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Nt="no-optional-root-props",cr=lr({name:Nt,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(l){return l?l.parent?.type===M.TSESTree.AST_NODE_TYPES.ExportNamedDeclaration||l.parent?.type===M.TSESTree.AST_NODE_TYPES.ExportDefaultDeclaration:!1}function n(l){let p=e.sourceCode.getDeclaredVariables(l)[0];if(!p||p.references.length!==1)return!1;let r=p.references[0];if(!r)return!1;for(let a of ze(r.identifier)){if("returnType"in a||a.type===M.TSESTree.AST_NODE_TYPES.ExportNamedDeclaration)return!1;let s=a.parent;if(!s)return!1;if(s.type===M.TSESTree.AST_NODE_TYPES.TSTypeParameterInstantiation&&s.parent.type===M.TSESTree.AST_NODE_TYPES.TSTypeReference&&s.parent.typeName.type===M.TSESTree.AST_NODE_TYPES.Identifier&&s.parent.typeName.name==="FC"){let c=ce(s.parent.parent,M.TSESTree.AST_NODE_TYPES.VariableDeclaration,4);if(c)return!(t(c)||e.sourceCode.getScope(c).references.some(h=>t(h.identifier.parent.parent)))}if(a.type===M.TSESTree.AST_NODE_TYPES.AssignmentPattern)return!1;if(s.type===M.TSESTree.AST_NODE_TYPES.ArrowFunctionExpression){let i=ce(s,M.TSESTree.AST_NODE_TYPES.VariableDeclaration);return i&&t(i)||i&&e.sourceCode.getScope(i).references.some(y=>y.identifier.parent.parent?.parent?.type===M.TSESTree.AST_NODE_TYPES.ExportNamedDeclaration)?!1:s.params.some(c=>c===a)}if(s.type===M.TSESTree.AST_NODE_TYPES.FunctionDeclaration)return t(s)||e.sourceCode.getScope(s).upper?.references.some(c=>t(c.identifier.parent.parent))?!1:s.params.some(c=>c===a)}return!1}function o(l){l.key.type!==M.TSESTree.AST_NODE_TYPES.Identifier||!l.optional||e.report({node:l.key,messageId:"optionalNotAllowed",data:{propertyName:l.key.name},suggest:[{messageId:"suggestion",fix:f=>{let p=ce(l,M.TSESTree.AST_NODE_TYPES.TSPropertySignature);if(!p)return null;let r=e.sourceCode.getText(p);return f.replaceText(p,r.replace("?:",": undefined |"))}}]})}return{TSTypeAliasDeclaration(l){if(l.typeAnnotation.type===M.TSESTree.AST_NODE_TYPES.TSTypeLiteral&&!(t(l)||!n(l)))for(let f of l.typeAnnotation.members)f.type===M.TSESTree.AST_NODE_TYPES.TSPropertySignature&&o(f)},TSInterfaceDeclaration(l){if(!(t(l)||!n(l)))for(let f of l.body.body)f.type===M.TSESTree.AST_NODE_TYPES.TSPropertySignature&&o(f)},TSTypeReference(l){if(l.typeName.type!==M.TSESTree.AST_NODE_TYPES.Identifier||l.typeName.name!=="FC"||!l.typeArguments?.params[0])return;let f=l.typeArguments.params[0];if(f.type!==M.TSESTree.AST_NODE_TYPES.TSTypeLiteral)return;let p=ce(l.parent,M.TSESTree.AST_NODE_TYPES.VariableDeclaration,4);if(!p||t(p)||e.sourceCode.getScope(p).references.some(i=>i.identifier.parent.parent?.parent?.type===M.TSESTree.AST_NODE_TYPES.ExportNamedDeclaration))return;let a=p.declarations[0].id.type===M.TSESTree.AST_NODE_TYPES.Identifier?p.declarations[0].id:null,s=e.sourceCode.getScope(p).variables.find(i=>i.name===a?.name)?.references.filter(i=>i.identifier!==a);if(!(s&&s.length>1))for(let i of f.members)i.type===M.TSESTree.AST_NODE_TYPES.TSPropertySignature&&o(i)}}}}),Be={name:Nt,rule:cr};var Dt=require("@typescript-eslint/utils"),xe=Ae(require("path"));var pr=Dt.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),_t="no-relative-imports",ur=j({find:F(),replacement:F()}),fr=j({aliases:V(ur),rootDir:$(F()),allowNotFoundAliases:$(oe()),_dev_simulateFileName:$(F())}),mr=pr({name:_t,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:[fr]},defaultOptions:[{aliases:[],rootDir:void 0}],create(e,[t]){let n=t._dev_simulateFileName??e.filename;function o(p){return p.startsWith(".")||p.startsWith("..")}function l(p,r){let a=xe.default.dirname(r);return xe.default.resolve(a,p)}function f(p){let r=t.rootDir??process.cwd(),a=xe.default.relative(r,p);if(a.startsWith("."))return null;a.startsWith("/")||(a=`/${a}`);for(let{find:s,replacement:i}of t.aliases)if(a.startsWith(i)){let c=a.replace(i,s);return{alias:s,newPath:c}}return null}return{ImportDeclaration(p){let r=p.source.value;if(!o(r))return;let a=l(r,n),s=f(a);!s&&t.allowNotFoundAliases||e.report({node:p,messageId:s?"noRelativeImportsWithAlias":"noRelativeImports",data:{alias:s?.alias},fix:s?i=>i.replaceText(p.source,`'${s.newPath}'`):void 0})}}}}),qe={name:_t,rule:mr};var te=require("@typescript-eslint/utils");var Ke=Ae(require("typescript")),dr=te.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Lt="no-unnecessary-casting",yr=j({additionalCastFunctions:$(V(j({name:F(),expectedType:Te(["string","number"])})))}),Xe={name:Lt,rule:dr({name:Lt,meta:{type:"suggestion",docs:{description:"Prevents unnecessary Number and String castings"},messages:{unnecessaryNumberCasting:"Unnecessary Number() casting on a value already of number type",unnecessaryStringCasting:"Unnecessary String() casting on a value already of string type",unnecessaryCustomCasting:"Unnecessary {{name}}() casting on a value already of {{type}} type"},schema:[yr],fixable:"code"},defaultOptions:[{}],create(e){let n=e.options[0].additionalCastFunctions||[],o=[{name:"Number",expectedType:"number"},{name:"String",expectedType:"string"},...n],l=te.ESLintUtils.getParserServices(e,!0),f=l.program?.getTypeChecker();if(!f||!l.program)throw new Error("TypeScript services or program not available");function p(i,c){switch(i.type){case te.AST_NODE_TYPES.Literal:return c==="number"?typeof i.value=="number":typeof i.value=="string";case te.AST_NODE_TYPES.TemplateLiteral:return c==="string";case te.AST_NODE_TYPES.UnaryExpression:return c==="number"?i.operator==="+"||i.operator==="-"||i.operator==="~":!1;default:return!1}}function r(i,c){return c==="number"?!!(i.flags&Ke.TypeFlags.NumberLike):!!(i.flags&Ke.TypeFlags.StringLike)}function a(i,c){return y=>y.replaceText(i,e.sourceCode.getText(c))}function s(i){if(!f||i.arguments.length!==1)return;let c=i.arguments[0];if(!c||c.type===te.AST_NODE_TYPES.SpreadElement)return;let{callee:y}=i;if(y.type!==te.AST_NODE_TYPES.Identifier)return;let h=y.name,S=o.find(E=>E.name===h);if(!S)return;if(p(c,S.expectedType)||r(f.getTypeAtLocation(l.esTreeNodeToTSNodeMap.get(c)),S.expectedType)){let E,T;h==="Number"?E="unnecessaryNumberCasting":h==="String"?E="unnecessaryStringCasting":(E="unnecessaryCustomCasting",T={name:S.name,type:S.expectedType}),e.report({node:i,messageId:E,...T?{data:T}:{},fix:a(i,c)})}}return{CallExpression:s}}})};var L=require("@typescript-eslint/utils");var gr=L.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function $t(e){let t=[];for(let n of e.members)n.type===L.AST_NODE_TYPES.TSPropertySignature&&n.key.type===L.AST_NODE_TYPES.Identifier&&t.push([n.key.name,n]);return t}function Ft(e,...t){for(let n of t)e.set(...n);return e}var hr=j({forceCheckOnFCPropTypesWithName:$(V(F()))}),jt="no-unused-type-props-in-args",Je=null,Tr=gr({name:jt,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:[hr],fixable:"code"},defaultOptions:[{}],create(e,[t]){let{forceCheckOnFCPropTypesWithName:n}=t;n&&!Je&&(Je=n.map(r=>new RegExp(r)));function o(r,a,s,i,c=!0){let y=s.name,h=e.sourceCode.getScope(a).references.find(E=>E.identifier.name===y)?.resolved,S=r&&Je?.some(E=>E.test(y));if(!h||!S&&h.references.filter(E=>E.isTypeReference).length>1)return;let d=h?.defs[0]?.node;if(!(c&&d?.parent?.type===L.AST_NODE_TYPES.ExportNamedDeclaration)){if(d?.type===L.AST_NODE_TYPES.TSTypeAliasDeclaration){l(r,a,i,d.typeAnnotation,!0);return}if(d?.type===L.AST_NODE_TYPES.TSInterfaceDeclaration){l(r,a,i,d.body,!0);return}}}function l(r,a,s,i,c){if(i.type===L.AST_NODE_TYPES.TSInterfaceBody){for(let y of i.body)y.type===L.AST_NODE_TYPES.TSPropertySignature&&y.key.type===L.AST_NODE_TYPES.Identifier&&s.set(y.key.name,y);return}if(i.type===L.AST_NODE_TYPES.TSTypeLiteral){Ft(s,...$t(i));return}if(i.type===L.AST_NODE_TYPES.TSIntersectionType){for(let y of i.types)l(r,a,s,y,!0);return}c||i.type===L.AST_NODE_TYPES.TSTypeReference&&i.typeName.type===L.AST_NODE_TYPES.Identifier&&o(r,a,i.typeName,s)}function f(r,a,s){for(let i of s)if(i.type==="ObjectPattern"&&i.typeAnnotation){let c=new Map;if(l(r,a,c,i.typeAnnotation.typeAnnotation,!1),c.size===0)continue;p(i,c)}else i.type===L.AST_NODE_TYPES.AssignmentPattern&&i.left.type===L.AST_NODE_TYPES.ObjectPattern&&f(r,a,[i.left])}function p(r,a){let s=[];if(r.properties.at(-1)?.type===L.AST_NODE_TYPES.RestElement)return;for(let h of r.properties)h.type===L.AST_NODE_TYPES.Property&&h.key.type===L.AST_NODE_TYPES.Identifier&&s.push(h.key.name);let c=[],y=[];for(let[h,S]of a)s.includes(h)||(y.push(h),c.push({node:S,messageId:"unusedObjectTypeProperty",data:{propertyName:h}}));for(let[h,S]of c.entries())e.report({...S,fix:h===c.length-1?d=>{let E=r.properties.at(-1),T=y.join(", ");return E?E?.type===L.AST_NODE_TYPES.RestElement?null:d.insertTextAfter(E,`, ${T}`):d.insertTextBeforeRange([r.range[0]+1,r.range[1]],`${T}`)}:void 0})}return{VariableDeclaration(r){let a=r.declarations[0];if(!a)return;let s=new Map,i=a.id.type===L.AST_NODE_TYPES.Identifier&&a.id.typeAnnotation?.typeAnnotation.type===L.AST_NODE_TYPES.TSTypeReference&&a.id.typeAnnotation.typeAnnotation.typeName.type===L.AST_NODE_TYPES.Identifier&&a.id.typeAnnotation.typeAnnotation.typeName.name==="FC"&&a.id.typeAnnotation.typeAnnotation.typeArguments?.params[0];if(i){if(i.type===L.AST_NODE_TYPES.TSTypeReference&&i.typeName.type===L.AST_NODE_TYPES.Identifier)o(!0,r,i.typeName,s,!1);else if(i.type===L.AST_NODE_TYPES.TSTypeLiteral)Ft(s,...$t(i));else if(i.type===L.AST_NODE_TYPES.TSIntersectionType)for(let c of i.types)c.type===L.AST_NODE_TYPES.TSTypeReference&&c.typeName.type===L.AST_NODE_TYPES.Identifier?o(!0,r,c.typeName,s,!1):l(!0,r,s,c,!0);if(s.size!==0&&a.init?.type===L.AST_NODE_TYPES.ArrowFunctionExpression){let c=a.init.params[0];if(!c){e.report({node:a.init,messageId:"missingComponentParam"});return}c.type===L.AST_NODE_TYPES.ObjectPattern&&p(c,s)}}},FunctionDeclaration:function(r){f(!1,r,r.params)},ArrowFunctionExpression(r){f(!1,r,r.params)}}}}),Ge={name:jt,rule:Tr};var pe=require("@typescript-eslint/utils"),Sr=pe.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ut="prefer-named-functions",Mt=new Map,Er=Sr({name:Ut,meta:{hasSuggestions:!0,type:"suggestion",docs:{description:"Prevent using arrow functions when a named function can be used instead"},schema:[{type:"object",properties:{ignoreRegex:{type:"string"},disallowArrowFnWithImplicitReturns:{type:"boolean"}}}],messages:{suggestion:"Convert to named function",default:'Function {{functionName}} should be defined as a named function "function {{functionName}} () {}" instead of an arrow function',withIgnoreRegex:'Function {{functionName}} should be defined as a named function "function {{functionName}} () {}", if not possible to use `function` you can also use a name that matches the rule ignore regex'}},defaultOptions:[{}],create(e,[t]){let n=null;if(t.ignoreRegex){let o=Mt.get(t.ignoreRegex);o?n=o:(n=new RegExp(t.ignoreRegex),Mt.set(t.ignoreRegex,n))}return{VariableDeclarator(o){if(o.init&&o.init.type===pe.AST_NODE_TYPES.ArrowFunctionExpression&&o.id.type===pe.AST_NODE_TYPES.Identifier){let l=o.id.name;if(o.id.typeAnnotation||n&&n.test(l)||!t.disallowArrowFnWithImplicitReturns&&o.init.body.type!==pe.AST_NODE_TYPES.BlockStatement)return;let f=o.parent,p=o.init.params,r=o.init.body,a=o.init;e.report({node:o.id,messageId:n?"withIgnoreRegex":"default",data:{functionName:l,ignoreRegex:t.ignoreRegex},suggest:[{messageId:"suggestion",fix:s=>s.replaceText(f,`${a.async?"async ":""}function ${l}(${p.map(i=>e.sourceCode.getText(i)).join(", ")||""}) ${e.sourceCode.getText(r)}`)}]})}}}}}),Ze={name:Ut,rule:Er};var U=require("@typescript-eslint/utils");var br=U.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ht="prefer-single-line-if",xr=j({maxLineLength:$(J()),maxNonSimpleConditionLength:$(J())}),Cr=br({name:Ht,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:[xr]},defaultOptions:[{}],create(e,[t]){let n=e.sourceCode;return{IfStatement(o){if(o.consequent.type!==U.AST_NODE_TYPES.BlockStatement||o.loc.start.line===o.loc.end.line||n.getCommentsInside(o.consequent).length>0||o.alternate||o.consequent.body.length!==1)return;let f=o.consequent.body[0];if(f.type===U.AST_NODE_TYPES.ReturnStatement){if(!Yt(f))return}else if(!(f.type===U.AST_NODE_TYPES.ContinueStatement||f.type===U.AST_NODE_TYPES.BreakStatement))return;if(o.test.type===U.AST_NODE_TYPES.LogicalExpression||o.test.type===U.AST_NODE_TYPES.ConditionalExpression)return;let p;if(t.maxNonSimpleConditionLength){let c=Wt(o.test);if(!c&&o.test.type===U.AST_NODE_TYPES.UnaryExpression&&o.test.operator==="!"){let y=o.test.argument;Wt(y)&&(c=!0)}if(c&&(p=n.getText(o.test),p.length>t.maxNonSimpleConditionLength))return}p||(p=n.getText(o.test));let r=n.getText(f);if(p.includes(`
14
- `))return;let a=n.getTokenAfter(o);if(a&&a.type===U.AST_TOKEN_TYPES.Punctuator&&a.value==="}"){let c=n.getTokenAfter(a);if(c&&c.type===U.AST_TOKEN_TYPES.Keyword&&(c.value==="else"||c.value==="catch"))return}let s=Ir(n,o),i=`if (${p}) ${r}`;t.maxLineLength&&i.length+s.length>t.maxLineLength||e.report({node:o,messageId:"noSingleLineCurly",fix:c=>c.replaceText(o,i)})}}}});function Wt(e){return e.type===U.AST_NODE_TYPES.CallExpression||e.type===U.AST_NODE_TYPES.BinaryExpression||e.type===U.AST_NODE_TYPES.MemberExpression&&Vt(e)}function Vt(e){return e.object.type===U.AST_NODE_TYPES.MemberExpression?Vt(e.object):e.object.type!==U.AST_NODE_TYPES.Identifier}function Ir(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}function Yt(e){if(!e.argument)return!0;let t=e.argument;return t.type===U.AST_NODE_TYPES.ArrayExpression&&t.elements.length===0||t.type===U.AST_NODE_TYPES.ObjectExpression&&t.properties.length===0||t.type===U.AST_NODE_TYPES.Literal||t.type===U.AST_NODE_TYPES.Identifier||t.type===U.AST_NODE_TYPES.TemplateLiteral||t.type===U.AST_NODE_TYPES.TaggedTemplateExpression?!0:t.type===U.AST_NODE_TYPES.CallExpression?t.arguments.length===0:t.type===U.AST_NODE_TYPES.UnaryExpression?Yt(t):!1}var Qe={name:Ht,rule:Cr};var z=require("@typescript-eslint/utils");var wr=z.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),zt="react-compiler-migration",Rr=j({disallowHooks:$(V(j({name:F(),replacement:F()}))),disallowMethods:$(V(j({name:F(),replacement:$(F()),requireTrueProp:$(F())})))}),vr=/eslint +react-compiler\/react-compiler: +\["error/;function kr(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 Ar=wr({name:zt,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:[Rr]},defaultOptions:[{}],create(e,[t]){let n=!1;for(let o of e.sourceCode.getAllComments())if(vr.test(o.value)){n=!0;break}return n?{CallExpression(o){if(t.disallowHooks?.length){let l=null,f=null;if(o.callee.type===z.AST_NODE_TYPES.Identifier?(l=o.callee.name,f=o.callee):o.callee.type===z.AST_NODE_TYPES.MemberExpression&&o.callee.property.type===z.AST_NODE_TYPES.Identifier&&(l=o.callee.property.name,f=o.callee.property),l){let p=t.disallowHooks.find(r=>r.name===l);p&&f&&e.report({node:o,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:p.name,replacement:p.replacement},suggest:[{messageId:"replace",data:{replacement:p.replacement},fix:r=>r.replaceText(f,p.replacement)}]})}}if(t.disallowMethods?.length&&kr(o.callee)){for(let l of o.arguments)if(l.type===z.AST_NODE_TYPES.ObjectExpression){for(let f of l.properties)if(f.type===z.AST_NODE_TYPES.Property&&f.key.type===z.AST_NODE_TYPES.Identifier){let p=f.key.name,r=t.disallowMethods.find(a=>a.name===p);if(r){if(r.requireTrueProp){let a=r.requireTrueProp,s=!1;for(let i of l.properties)if(i.type===z.AST_NODE_TYPES.Property&&i.key.type===z.AST_NODE_TYPES.Identifier&&i.key.name===a&&i.value.type===z.AST_NODE_TYPES.Literal&&i.value.value===!0){s=!0;break}if(!s){e.report({node:f,messageId:"disallowedMethodWithMissingRequireTrueProp",data:{method:r.name,requireTrueProp:a}});continue}}r.replacement&&e.report({node:f,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:r.name,replacement:r.replacement},suggest:[{messageId:"replace",data:{replacement:r.replacement},fix:a=>a.replaceText(f.key,r.replacement)}]})}}}}}}:{}}}),et={name:zt,rule:Ar};var Ce=require("@typescript-eslint/utils"),Or=Ce.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Bt="require-description",Pr=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,Nr=/^eslint-disable-(next-)?line$/u,Dr=Or({name:Bt,meta:{type:"problem",docs:{description:"Require descriptions for eslint directives."},messages:{missingDescription:"Unexpected undescribed directive comment. Include descriptions to explain why the comment is necessary."},schema:[{type:"object",properties:{ignore:{type:"array",items:{type:"string",enum:["eslint","eslint-disable","eslint-disable-line","eslint-disable-next-line","eslint-enable","eslint-env","exported","global","globals"]},additionalItems:!1,uniqueItems:!0}},additionalProperties:!1}]},defaultOptions:[{ignore:[]}],create(e,[t]){let n=e.sourceCode,o=new Set(t.ignore||[]);return{Program(){for(let l of n.getAllComments()){let f=_r(l);f!=null&&(o.has(f.kind)||f.description||e.report({loc:$r(l.loc),messageId:"missingDescription"}))}}}}}),qt={name:Bt,rule:Dr};function _r(e){let{text:t,description:n}=Lr(e.value);if(!t)return null;let o=Pr.exec(t);if(!o)return null;let l=o[1];if(!l)return null;let f=Nr.test(l);if(e.type===Ce.TSESTree.AST_TOKEN_TYPES.Line&&!f||f&&e.loc.start.line!==e.loc.end.line)return null;let p=t.slice(o.index+l.length);return{kind:l,value:p.trim(),description:n}}function Lr(e){let t=e.split(/\s-{2,}\s/u);return{text:t[0]?.trim(),description:t.length>1?t[1]?.trim()??null:null}}function $r(e){return{start:{line:e.start.line,column:-1},end:e.end}}function Jt(e){return/^use[A-Z0-9]/.test(e)}function Ie(e){return e.type==="Identifier"?Jt(e.name):e.type==="MemberExpression"&&!e.computed&&Ie(e.property)?e.object.type==="Identifier":!1}function Gt(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function Zt(e,t){return e.name===t||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===t}function Qt(e){return!!(e.parent&&e.parent.callee&&Zt(e.parent.callee,"forwardRef"))}function en(e){return!!(e.parent&&e.parent.callee&&Zt(e.parent.callee,"memo"))}function tt(e){for(;e;){let t=nn(e);if(t&&(Gt(t)||Ie(t))||Qt(e)||en(e))return!0;e=e.parent}return!1}function Kt(e){return!1}function nt(e){return!1}var Fr=/eslint +react-compiler\/react-compiler: +\["error/,tn={meta:{type:"problem",docs:{description:"enforces the Rules of Hooks",recommended:!0,url:"https://reactjs.org/docs/hooks-rules.html"},schema:[{type:"object",ignoreIfReactCompilerIsEnabled:!1,properties:{ignoreIfReactCompilerIsEnabled:{type:"boolean"}}}]},create(e){if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let a of e.sourceCode.getAllComments())if(Fr.test(a.value))return{CallExpression(s){let i=null;s.callee.name==="useMemo"?i="useMemo":s.callee.name==="useCallback"&&(i="useCallback"),i&&e.report({node:s,message:`"${i}" is not necessary when using React Compiler.`})}}}let t=typeof e.getSource=="function"?a=>t(a):a=>e.sourceCode.getText(a),n=typeof e.getScope=="function"?()=>n():a=>e.sourceCode.getScope(a),o=null,l=[],f=[],p=new WeakSet;function r(a){for(let s of a.references){let i=s.identifier.parent;if(i.type==="VariableDeclarator"&&i.init&&i.init.type==="CallExpression"&&i.init.callee&&Kt(i.init.callee))for(let c of s.resolved.references)c!==s&&p.add(c.identifier)}}return{onCodePathSegmentStart:a=>f.push(a),onCodePathSegmentEnd:()=>f.pop(),onCodePathStart:()=>l.push(new Map),onCodePathEnd(a,s){let i=l.pop();if(i.size===0)return;let c=new Set;function y(g,w){let{cache:R}=y,k=R.get(g.id),_=new Set(w);if(_.has(g.id)){let A=[..._],W=A.slice(A.indexOf(g.id)+1);for(let X of W)c.add(X);return BigInt("0")}if(_.add(g.id),k!==void 0)return k;if(a.thrownSegments.includes(g))k=BigInt("0");else if(g.prevSegments.length===0)k=BigInt("1");else{k=BigInt("0");for(let A of g.prevSegments)k+=y(A,_)}return g.reachable&&k===BigInt("0")?R.delete(g.id):R.set(g.id,k),k}function h(g,w){let{cache:R}=h,k=R.get(g.id),_=new Set(w);if(_.has(g.id)){let A=Array.from(_),W=A.slice(A.indexOf(g.id)+1);for(let X of W)c.add(X);return BigInt("0")}if(_.add(g.id),k!==void 0)return k;if(a.thrownSegments.includes(g))k=BigInt("0");else if(g.nextSegments.length===0)k=BigInt("1");else{k=BigInt("0");for(let A of g.nextSegments)k+=h(A,_)}return R.set(g.id,k),k}function S(g){let{cache:w}=S,R=w.get(g.id);if(R===null)return 1/0;if(R!==void 0)return R;if(w.set(g.id,null),g.prevSegments.length===0)R=1;else{R=1/0;for(let k of g.prevSegments){let _=S(k);_<R&&(R=_)}R+=1}return w.set(g.id,R),R}y.cache=new Map,h.cache=new Map,S.cache=new Map;let d=h(a.initialSegment),E=nn(s),T=tt(s),N=E?Gt(E)||Ie(E):Qt(s)||en(s),v=1/0;for(let g of a.finalSegments){if(!g.reachable)continue;let w=S(g);w<v&&(v=w)}for(let[g,w]of i){if(!g.reachable)continue;let R=g.nextSegments.length===0?v<=S(g):v<S(g),k=y(g)*h(g),_=c.has(g.id);for(let A of w)if(_&&!nt(A)&&e.report({node:A,message:`React Hook "${t(A)}" 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.`}),N){if(s.async&&e.report({node:A,message:`React Hook "${t(A)}" cannot be called in an async function.`}),!_&&k!==d&&!nt(A)){let X=`React Hook "${t(A)}" is called conditionally. React Hooks must be called in the exact same order in every component render.`+(R?" Did you accidentally call a React Hook after an early return?":"");e.report({node:A,message:X})}}else if(s.parent&&(s.parent.type==="MethodDefinition"||s.parent.type==="ClassProperty")&&s.parent.value===s){let W=`React Hook "${t(A)}" 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:A,message:W})}else if(E){let W=`React Hook "${t(A)}" 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:A,message:W})}else if(s.type==="Program"){let W=`React Hook "${t(A)}" 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:A,message:W})}else if(T&&!nt(A)){if(s.parent.type==="CallExpression"&&s.parent.callee.type==="Identifier"&&s.parent.callee.name==="useCallback"){let X=s.parent;if(X.parent.type==="VariableDeclarator"&&Jt(X.parent.id.name))return}let W=`React Hook "${t(A)}" 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:A,message:W})}}},CallExpression(a){if(Ie(a.callee)){let s=Xt(l),i=Xt(f),c=s.get(i);c||(c=[],s.set(i,c)),c.push(a.callee)}a.callee.type==="Identifier"&&(a.callee.name==="useEffect"||Kt(a.callee))&&a.arguments.length>0&&(o=a)},Identifier(a){o==null&&p.has(a)&&a.parent.type!=="CallExpression"&&e.report({node:a,message:`\`${t(a)}\` is a function created with React Hook "useEffectEvent", and can only be called from the same component. They cannot be assigned to variables or passed down.`})},"CallExpression:exit"(a){a===o&&(o=null)},FunctionDeclaration(a){tt(a)&&r(n(a))},ArrowFunctionExpression(a){tt(a)&&r(n(a))}}}};function nn(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 Xt(e){return e[e.length-1]}var rn={[Ge.name]:Ge.rule,[We.name]:We.rule,[Ue.name]:Ue.rule,"rules-of-hooks":tn,"exhaustive-deps":St,"require-description":qt.rule,[He.name]:He.rule,[Ye.name]:Ye.rule,[Ze.name]:Ze.rule,[De.name]:De.rule,[Me.name]:Me.rule,[qe.name]:qe.rule,[Qe.name]:Qe.rule,[Be.name]:Be.rule,[Ve.name]:Ve.rule,[_e.name]:_e.rule,[et.name]:et.rule,[Ne.name]:Ne.rule,[je.name]:je.rule,[Xe.name]:Xe.rule};var jr={rules:rn};0&&(module.exports={extendedLintPlugin});
14
+ Learn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching`});let R=a.acquire(y),k=new Set,D=null;{let u=R.upper;for(;u&&(k.add(u),u.type!=="function");)u=u.upper;if(!u)return;D=u}let A=Array.isArray;function W(u){if(!A(u.defs))return!1;let m=u.defs[0];if(m==null||m.node.type!=="VariableDeclarator")return!1;let E=m.node.init;if(E==null)return!1;for(;E.type==="TSAsExpression";)E=E.expression;let x=m.node.parent;if(x==null&&(Fe(D.block,m.node.id),x=m.node.parent,x==null))return!1;if(x.kind==="const"&&E.type==="Literal"&&(typeof E.value=="string"||typeof E.value=="number"||E.value===null))return!0;if(E.type!=="CallExpression")return!1;let I=E.callee;if(I.type==="MemberExpression"&&I.object.name==="React"&&I.property!=null&&!I.computed&&(I=I.property),I.type!=="Identifier")return!1;let C=m.node.id,{name:O}=I;if(O==="useRef"&&C.type==="Identifier")return!0;if(Mn(I)&&C.type==="Identifier"){for(let P of u.references)P!==C&&T.add(P.identifier);return!0}else if(O==="useState"||O==="useReducer"){if(C.type==="ArrayPattern"&&C.elements.length===2&&A(u.identifiers)){if(C.elements[1]===u.identifiers[0]){if(O==="useState"){let P=u.references,q=0;for(let Z=0;Z<P.length;Z++){if(P[Z].isWrite()&&q++,q>1)return!1;o.set(P[Z].identifier,C.elements[0])}}return!0}else if(C.elements[0]===u.identifiers[0]){if(O==="useState"){let P=u.references;for(let q=0;q<P.length;q++)i.add(P[q].identifier)}return!1}}}else if(O==="useTransition"&&C.type==="ArrayPattern"&&C.elements.length===2&&Array.isArray(u.identifiers)&&C.elements[1]===u.identifiers[0])return!0;return!1}function X(u){if(!A(u.defs))return!1;let m=u.defs[0];if(m==null||m.node==null||m.node.id==null)return!1;let E=m.node,x=D.childScopes,I=null,C;for(C=0;C<x.length;C++){let O=x[C],P=O.block;if(E.type==="FunctionDeclaration"&&P===E||E.type==="VariableDeclarator"&&P.parent===E){I=O;break}}if(I==null)return!1;for(C=0;C<I.through.length;C++){let O=I.through[C];if(O.resolved!=null&&k.has(O.resolved.scope)&&!rt(O.resolved))return!1}return!0}let rt=S(W,c),sn=S(X,g),it=new Map;function on(u){let m=u.from,E=!1;for(;m.block!==y;)m.type==="function"&&(E=m.block.parent!=null&&m.block.parent.type==="ReturnStatement"),m=m.upper;return E}let B=new Map,we=new Map;st(R);function st(u){for(let m of u.references){if(!m.resolved||!k.has(m.resolved.scope))continue;let E=Fe(y,m.identifier),x=Et(E),I=Q(x,we);if(w&&x.type==="Identifier"&&(x.parent.type==="MemberExpression"||x.parent.type==="OptionalMemberExpression")&&!x.parent.computed&&x.parent.property.type==="Identifier"&&x.parent.property.name==="current"&&on(m)&&it.set(I,{reference:m,dependencyNode:x}),x.parent.type==="TSTypeQuery"||x.parent.type==="TSTypeReference")continue;let C=m.resolved.defs[0];if(C!=null&&!(C.node!=null&&C.node.init===y.parent)&&C.type!=="TypeParameter")if(B.has(I))B.get(I).references.push(m);else{let O=m.resolved,P=rt(O)||sn(O);B.set(I,{isStable:P,references:[m]})}}for(let m of u.childScopes)st(m)}it.forEach(({reference:u,dependencyNode:m},E)=>{let x=u.resolved.references,I=!1;for(let C=0;C<x.length;C++){let{identifier:O}=x[C],{parent:P}=O;if(P!=null&&P.type==="MemberExpression"&&!P.computed&&P.property.type==="Identifier"&&P.property.name==="current"&&P.parent.type==="AssignmentExpression"&&P.parent.left===P){I=!0;break}}I||r({node:m.parent.property,message:`The ref value '${E}.current' will likely have changed by the time this effect cleanup function runs. If this ref points to a node rendered by React, copy '${E}.current' to a variable inside the effect, and use that variable in the cleanup function.`})});let Re=new Set;function an(u,m){Re.has(m)||(Re.add(m),r({node:u,message:`Assignments to the '${m}' variable from inside React Hook ${n(v)} will be lost after each render. To preserve the value over time, store it in a useRef Hook and keep the mutable value in the '.current' property. Otherwise, you can move this variable directly inside ${n(v)}.`}))}let de=new Set;if(B.forEach(({isStable:u,references:m},E)=>{u&&de.add(E),m.forEach(x=>{x.writeExpr&&an(x.writeExpr,E)})}),Re.size>0)return;if(!N){let u=null;if(B.forEach(({isStable:m,references:E},x)=>{u||E.forEach(I=>{if(u)return;let C=I.identifier;if(!o.has(C))return;let P=I.from;for(;P.type!=="function";)P=P.upper;P.block===y&&(u=x)})}),u){let{suggestedDependencies:m}=Le({dependencies:B,declaredDependencies:[],stableDependencies:de,externalDependencies:new Set,isEffect:!0});r({node:v,message:`React Hook ${h} contains a call to '${u}'. Without a list of dependencies, this can lead to an infinite chain of updates. To fix this, pass [`+m.join(", ")+`] as a second argument to the ${h} Hook.`,suggest:[{desc:`Add dependencies array: [${m.join(", ")}]`,fix(E){return E.insertTextAfter(y,`, [${m.join(", ")}]`)}}]})}return}let ue=[],fe=new Set;N.type!=="ArrayExpression"?r({node:N,message:`React Hook ${n(v)} 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.`}):N.elements.forEach(u=>{if(u===null)return;if(u.type==="SpreadElement"){r({node:u,message:`React Hook ${n(v)} 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(u)&&r({node:u,message:`Functions returned from \`useEffectEvent\` must not be included in the dependency array. Remove \`${n(u)}\` from the list.`,suggest:[{desc:`Remove the dependency \`${n(u)}\``,fix(I){return I.removeRange(u.range)}}]});let m;try{m=Q(u,we)}catch(I){if(/Unsupported node type/.test(I.message)){u.type==="Literal"?B.has(u.value)?r({node:u,message:`The ${u.raw} literal is not a valid dependency because it never changes. Did you mean to include ${u.value} in the array instead?`}):r({node:u,message:`The ${u.raw} literal is not a valid dependency because it never changes. You can safely remove it.`}):r({node:u,message:`React Hook ${n(v)} has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked.`});return}else throw I}let E=u;for(;E.type==="MemberExpression"||E.type==="OptionalMemberExpression"||E.type==="ChainExpression";)E=E.object||E.expression.object;let x=!D.through.some(I=>I.identifier===E);ue.push({key:m,node:u}),x||fe.add(m)});let{suggestedDependencies:ln,unnecessaryDependencies:ye,missingDependencies:ne,duplicateDependencies:ot}=Le({dependencies:B,declaredDependencies:ue,stableDependencies:de,externalDependencies:fe,isEffect:w}),ge=ln;if(ot.size+ne.size+ye.size===0){if(t)return;Ln({declaredDependencies:ue,declaredDependenciesNode:N,componentScope:D,scope:R}).forEach(({construction:m,isUsedOutsideOfHook:E,depType:x})=>{let I=x==="function"?"useCallback":"useMemo",C=x==="function"?"definition":"initialization",O=`wrap the ${C} of '${m.name.name}' in its own ${I}() Hook.`,P=E?`To fix this, ${O}`:`Move it inside the ${h} callback. Alternatively, ${O}`,q=x==="conditional"||x==="logical expression"?"could make":"makes",Z=`The '${m.name.name}' ${x} ${q} the dependencies of ${h} Hook (at line ${N.loc.start.line}) change on every render. ${P}`,at;E&&m.type==="Variable"&&x==="function"&&(at=[{desc:`Wrap the ${C} of '${m.name.name}' in its own ${I}() Hook.`,fix(lt){let[pn,un]=I==="useMemo"?["useMemo(() => { return ","; })"]:["useCallback(",")"];return[lt.insertTextBefore(m.node.init,pn),lt.insertTextAfter(m.node.init,un)]}}]),r({node:m.node,message:Z,suggest:at})});return}!w&&ne.size>0&&(ge=Le({dependencies:B,declaredDependencies:[],stableDependencies:de,externalDependencies:fe,isEffect:w}).suggestedDependencies);function cn(){if(ue.length===0)return!0;let u=ue.map(E=>E.key),m=u.slice().sort();return u.join(",")===m.join(",")}cn()&&ge.sort();function ve(u){let m=u.split("."),E="";for(let x=0;x<m.length;x++){if(x!==0){let I=m.slice(0,x+1).join("."),C=we.get(I)===!0;E+=C?"?.":"."}E+=m[x]}return E}function ke(u,m,E,x){return u.size===0?null:(u.size>1?"":m+" ")+E+" "+(u.size>1?"dependencies":"dependency")+": "+Fn(Array.from(u).sort().map(I=>"'"+ve(I)+"'"))+`. Either ${x} ${u.size>1?"them":"it"} or remove the dependency array.`}let K="";if(ye.size>0){let u=null;if(Array.from(ye.keys()).forEach(m=>{u===null&&m.endsWith(".current")&&(u=m)}),u!==null)K=` Mutable values like '${u}' aren't valid dependencies because mutating them doesn't re-render the component.`;else if(fe.size>0){let m=Array.from(fe)[0];R.set.has(m)||(K=` Outer scope values like '${m}' aren't valid dependencies because mutating them doesn't re-render the component.`)}}if(!K&&ne.has("props")){let u=B.get("props");if(u==null)return;let m=u.references;if(!Array.isArray(m))return;let E=!0;for(let x=0;x<m.length;x++){let I=m[x],C=Fe(D.block,I.identifier);if(!C){E=!1;break}let O=C.parent;if(O==null){E=!1;break}if(O.type!=="MemberExpression"&&O.type!=="OptionalMemberExpression"){E=!1;break}}E&&(K=` However, 'props' will change when *any* prop changes, so the preferred fix is to destructure the 'props' object outside of the ${h} call and refer to those specific props inside ${n(v)}.`)}if(!K&&ne.size>0){let u=null;ne.forEach(m=>{if(u)return;let E=D.set.get(m),x=B.get(m);if(x.references[0].resolved!==E)return;let I=E.defs[0];if(I==null||I.name==null||I.type!=="Parameter")return;let C=!1,O;for(let P=0;P<x.references.length;P++)if(O=x.references[P].identifier,O!=null&&O.parent!=null&&(O.parent.type==="CallExpression"||O.parent.type==="OptionalCallExpression")&&O.parent.callee===O){C=!0;break}C&&(u=m)}),u!==null&&(K=` If '${u}' changes too often, find the parent component that defines it and wrap that definition in useCallback.`)}if(!K&&ne.size>0){let u=null;if(ne.forEach(m=>{if(u!==null)return;let x=B.get(m).references,I,C;for(let O=0;O<x.length;O++){for(I=x[O].identifier,C=I.parent;C!=null&&C!==D.block;){if(C.type==="CallExpression"){let P=o.get(C.callee);if(P!=null){if(P.name===m)u={missingDep:m,setter:C.callee.name,form:"updater"};else if(i.has(I))u={missingDep:m,setter:C.callee.name,form:"reducer"};else{let q=x[O].resolved;if(q!=null){let Z=q.defs[0];Z!=null&&Z.type==="Parameter"&&(u={missingDep:m,setter:C.callee.name,form:"inlineReducer"})}}break}}C=C.parent}if(u!==null)break}}),u!==null)switch(u.form){case"reducer":K=` You can also replace multiple useState variables with useReducer if '${u.setter}' needs the current value of '${u.missingDep}'.`;break;case"inlineReducer":K=` If '${u.setter}' needs the current value of '${u.missingDep}', you can also switch to useReducer instead of useState and read '${u.missingDep}' in the reducer.`;break;case"updater":K=` You can also do a functional update '${u.setter}(${u.missingDep.slice(0,1)} => ...)' if you only need '${u.missingDep}' in the '${u.setter}' call.`;break;default:throw new Error("Unknown case.")}}r({node:N,message:`React Hook ${n(v)} has `+(ke(ne,"a","missing","include")||ke(ye,"an","unnecessary","exclude")||ke(ot,"a","duplicate","omit"))+K,suggest:[{desc:`Update the dependencies array to be: [${ge.map(ve).join(", ")}]`,fix(u){return u.replaceText(N,`[${ge.map(ve).join(", ")}]`)}}]})}function b(y){let N=$n(y.callee,p);if(N===-1)return;let v=y.arguments[N],h=y.callee,w=bt(h).name,R=y.arguments[N+1],k=/Effect($|[^a-z])/g.test(w);if(!v){r({node:h,message:`React Hook ${w} requires an effect callback. Did you forget to pass a callback to the hook?`});return}if(!(t&&!k)){if(!R&&!k){(w==="useMemo"||w==="useCallback")&&r({node:h,message:`React Hook ${w} does nothing when called with only one argument. Did you forget to pass an array of dependencies?`});return}switch(v.type){case"FunctionExpression":case"ArrowFunctionExpression":d(v,R,h,w,k);return;case"Identifier":if(!R||R.elements&&R.elements.some(W=>W&&W.type==="Identifier"&&W.name===v.name))return;let D=s(y).set.get(v.name);if(D==null||D.defs==null)return;let A=D.defs[0];if(!A||!A.node||A.type!=="Variable"&&A.type!=="FunctionName")break;switch(A.node.type){case"FunctionDeclaration":d(A.node,R,h,w,k);return;case"VariableDeclarator":let W=A.node.init;if(!W)break;switch(W.type){case"ArrowFunctionExpression":case"FunctionExpression":d(W,R,h,w,k);return}break}break;default:r({node:h,message:`React Hook ${w} received a function whose dependencies are unknown. Pass an inline function instead.`});return}r({node:h,message:`React Hook ${w} has a missing dependency: '${v.name}'. Either include it or remove the dependency array.`,suggest:[{desc:`Update the dependencies array to be: [${v.name}]`,fix(D){return D.replaceText(R,`[${v.name}]`)}}]})}}if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let y of e.sourceCode.getAllComments())if(_n.test(y.value))return t=!0,{CallExpression:N=>b(N,!0)}}return{CallExpression:y=>b(y)}}};function Le({dependencies:e,declaredDependencies:t,stableDependencies:n,externalDependencies:s,isEffect:l}){let f=p();function p(){return{isUsed:!1,isSatisfiedRecursively:!1,isSubtreeUsed:!1,children:new Map}}e.forEach((d,b)=>{let y=r(f,b);y.isUsed=!0,a(f,b,N=>{N.isSubtreeUsed=!0})}),t.forEach(({key:d})=>{let b=r(f,d);b.isSatisfiedRecursively=!0}),n.forEach(d=>{let b=r(f,d);b.isSatisfiedRecursively=!0});function r(d,b){let y=b.split("."),N=d;for(let v of y){let h=N.children.get(v);h||(h=p(),N.children.set(v,h)),N=h}return N}function a(d,b,y){let N=b.split("."),v=d;for(let h of N){let w=v.children.get(h);if(!w)return;y(w),v=w}}let o=new Set,i=new Set;c(f,o,i,d=>d);function c(d,b,y,N){d.children.forEach((v,h)=>{let w=N(h);if(v.isSatisfiedRecursively){v.isSubtreeUsed&&y.add(w);return}if(v.isUsed){b.add(w);return}c(v,b,y,R=>w+"."+R)})}let g=[],T=new Set,S=new Set;return t.forEach(({key:d})=>{i.has(d)?g.indexOf(d)===-1?g.push(d):S.add(d):T.add(d)}),o.forEach(d=>{g.push(d)}),{suggestedDependencies:g,unnecessaryDependencies:T,duplicateDependencies:S,missingDependencies:o}}function re(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 re(e.consequent)!=null||re(e.alternate)!=null?"conditional":null;case"LogicalExpression":return re(e.left)!=null||re(e.right)!=null?"logical expression":null;case"JSXFragment":return"JSX fragment";case"JSXElement":return"JSX element";case"AssignmentExpression":return re(e.right)!=null?"assignment expression":null;case"NewExpression":return"object construction";case"Literal":return e.value instanceof RegExp?"regular expression":null;case"TypeCastExpression":return re(e.expression);case"TSAsExpression":return re(e.expression)}return null}function Ln({declaredDependencies:e,declaredDependenciesNode:t,componentScope:n,scope:s}){let l=e.map(({key:p})=>{let r=n.variables.find(o=>o.name===p);if(r==null)return null;let a=r.defs[0];if(a==null)return null;if(a.type==="Variable"&&a.node.type==="VariableDeclarator"&&a.node.id.type==="Identifier"&&a.node.init!=null){let o=re(a.node.init);if(o!=null)return[r,o]}return a.type==="FunctionName"&&a.node.type==="FunctionDeclaration"?[r,"function"]:a.type==="ClassName"&&a.node.type==="ClassDeclaration"?[r,"class"]:null}).filter(Boolean);function f(p){let r=!1;for(let a=0;a<p.references.length;a++){let o=p.references[a];if(o.writeExpr){if(r)return!0;r=!0;continue}let i=o.from;for(;i!==s&&i!=null;)i=i.upper;if(i!==s&&!xt(t,o.identifier))return!0}return!1}return l.map(([p,r])=>({construction:p.defs[0],depType:r,isUsedOutsideOfHook:f(p)}))}function Et(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)?Et(e.parent):e.type==="MemberExpression"&&e.parent&&e.parent.type==="AssignmentExpression"&&e.parent.left===e?e.object:e}function $e(e,t,n){t&&(e.optional?t.has(n)||t.set(n,!0):t.has(n)||t.set(n,!1))}function Q(e,t){if(e.type==="Identifier"||e.type==="JSXIdentifier"){let n=e.name;return t&&t.set(n,!1),n}else if(e.type==="MemberExpression"&&!e.computed){let n=Q(e.object,t),s=Q(e.property,null),l=`${n}.${s}`;return $e(e,t,l),l}else if(e.type==="OptionalMemberExpression"&&!e.computed){let n=Q(e.object,t),s=Q(e.property,null),l=`${n}.${s}`;return $e(e,t,l),l}else if(e.type==="ChainExpression"&&!e.computed){let n=e.expression;if(n.type==="CallExpression")throw new Error(`Unsupported node type: ${n.type}`);let s=Q(n.object,t),l=Q(n.property,null),f=`${s}.${l}`;return $e(n,t,f),f}else throw new Error(`Unsupported node type: ${e.type}`)}function bt(e,t){return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.object.name==="React"&&e.property.type==="Identifier"&&!e.computed?e.property:e}function $n(e,t){let n=bt(e);if(n.type!=="Identifier")return-1;switch(n.name){case"useEffect":case"useLayoutEffect":case"useCallback":case"useMemo":return 0;case"useImperativeHandle":return 1;default:if(n===e&&t&&t.additionalHooks){let s;try{s=Q(n,null)}catch(l){if(/Unsupported node type/.test(l.message))return 0;throw l}return t.additionalHooks.test(s)?0:-1}else return-1}}function Fe(e,t){let n=[e],s=null;for(;n.length;){if(s=n.shift(),jn(s,t))return s;if(xt(s,t))for(let[l,f]of Object.entries(s))l!=="parent"&&(Tt(f)?(f.parent=s,n.push(f)):Array.isArray(f)&&f.forEach(p=>{Tt(p)&&(p.parent=s,n.push(p))}))}return null}function Fn(e){let t="";for(let n=0;n<e.length;n++)t+=e[n],n===0&&e.length===2?t+=" and ":n===e.length-2&&e.length>2?t+=", and ":n<e.length-1&&(t+=", ");return t}function Tt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function jn(e,t){return(e.type==="Identifier"||e.type==="JSXIdentifier")&&e.type===t.type&&e.name===t.name&&e.range[0]===t.range[0]&&e.range[1]===t.range[1]}function xt(e,t){return e.range[0]<=t.range[0]&&e.range[1]>=t.range[1]}function Mn(e){return!1}var ie=require("@typescript-eslint/utils");var Y=Ae(require("typescript")),Un=ie.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ct="improved-no-unnecessary-condition",Wn=j({}),Hn=["string","number","bigint","boolean","symbol","undefined","object","function","never"],Vn=new Set(Hn),je={name:Ct,rule:Un({name:Ct,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:[Wn]},defaultOptions:[{}],create(e){let t=ie.ESLintUtils.getParserServices(e,!0),n=t.program?.getTypeChecker();if(!n||!t.program)throw new Error("TypeScript services or program not available");function s(r){return r.type===ie.AST_NODE_TYPES.UnaryExpression&&r.operator==="typeof"}function l(r){return r.flags&Y.default.TypeFlags.Any||r.flags&Y.default.TypeFlags.Unknown?null:r.flags&Y.default.TypeFlags.StringLike?["string"]:r.flags&Y.default.TypeFlags.NumberLike?["number"]:r.flags&Y.default.TypeFlags.BigIntLike?["bigint"]:r.flags&Y.default.TypeFlags.BooleanLike?["boolean"]:r.flags&Y.default.TypeFlags.ESSymbolLike?["symbol"]:r.flags&Y.default.TypeFlags.Undefined||r.flags&Y.default.TypeFlags.Void?["undefined"]:r.flags&Y.default.TypeFlags.Null?["object"]:r.getCallSignatures().length>0?["function"]:r.flags&Y.default.TypeFlags.Object?r.getProperties().length===0?["string","number","bigint","boolean","symbol","object","function"]:["object"]:r.flags&Y.default.TypeFlags.NonPrimitive?["object"]:r.flags&Y.default.TypeFlags.Never?["never"]:null}function f(r){if(!n)return null;let a=t.esTreeNodeToTSNodeMap.get(r),o=n.getTypeAtLocation(a.expression);if(o.flags&Y.default.TypeFlags.Any||o.flags&Y.default.TypeFlags.Unknown)return null;let i=[];if(o.isUnion()){for(let g of o.types){let T=l(g);if(T)i.push(...T);else return null}return i}let c=l(o);return c?(i.push(...c),i):null}function p(r){if(!(r.operator==="==="||r.operator==="!=="))return;let o=null,i=null;if(s(r.left)?(o=r.left,i=r.right.type===ie.AST_NODE_TYPES.Literal&&typeof r.right.value=="string"?r.right.value:null):s(r.right)&&(o=r.right,i=r.left.type===ie.AST_NODE_TYPES.Literal&&typeof r.left.value=="string"?r.left.value:null),!o||!i||!Yn(i,Vn))return;let c=f(o);if(!c)return;let g=r.operator==="!==",T=c.includes(i);c.length===1?T&&!g?e.report({node:r,messageId:"unnecessaryTypeofCondition",data:{name:le(o,e),type:i}}):!T&&g?e.report({node:r,messageId:"unnecessaryTypeofCondition",data:{name:le(o,e),type:Array.from(c)[0]}}):!T&&!g?e.report({node:r,messageId:"alwaysFalseTypeofCondition",data:{name:le(o,e),actualType:Se(c),conditionType:i}}):T&&g&&e.report({node:r,messageId:"alwaysFalseTypeofCondition",data:{name:le(o,e),actualType:Se(c),conditionType:i}}):!T&&!g?e.report({node:r,messageId:"alwaysFalseTypeofCondition",data:{name:le(o,e),actualType:Se(c),conditionType:i}}):!T&&g&&e.report({node:r,messageId:"unnecessaryTypeofCondition",data:{name:le(o,e),type:Se(c)}})}return{BinaryExpression:p}}})};function Se(e){return Array.from(new Set(e)).join(" | ")||"never"}function le(e,t){let n=e.argument;return n.type===ie.AST_NODE_TYPES.Identifier?n.name:t.sourceCode.getText(n)}function Yn(e,t){return t.has(e)}var Ee=require("@typescript-eslint/utils");var zn=Ee.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),It="no-call-with-explicit-generics",Bn=j({functions:V(F())}),qn=zn({name:It,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:[Bn]},defaultOptions:[{functions:[]}],create(e,[t]){let n=new Set(t.functions);return{CallExpression(s){let{callee:l}=s;l.type===Ee.AST_NODE_TYPES.Identifier&&n.has(l.name)&&s.typeArguments&&e.report({node:s,messageId:"noExplicitGenerics",data:{functionName:l.name}})}}}}),Me={name:It,rule:qn};var se=require("@typescript-eslint/utils"),Kn=se.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),wt="no-call-with-inferred-generics",Xn=Kn({name:wt,meta:{type:"problem",docs:{description:"Disable calling configured functions with infered generics"},messages:{missingGenericDeclaration:"Function '{{ functionName }}' should be called with at least {{ minGenerics }} generic(s) (ex: `fn<Generic>()`) defined",anyUsedInGenerics:"Function '{{ functionName }}' should not be called with 'any' in generics"},schema:[{type:"object",properties:{functions:{type:"array",items:{type:"object",properties:{name:{type:"string"},minGenerics:{type:"number"},allowAny:{type:"boolean"},disallowTypes:{type:"array",items:{type:"string"}}},required:["name"]}},anyAliases:{type:"array",items:{type:"string"}}},required:["functions"]}]},defaultOptions:[{functions:[]}],create(e,[t]){let n=new Map(t.functions.map(s=>[s.name,s]));return{CallExpression(s){let{callee:l}=s;if(l.type!==se.AST_NODE_TYPES.Identifier)return;let f=n.get(l.name);if(!f)return;let{minGenerics:p=1,allowAny:r,disallowTypes:a=t.disallowTypes}=f;(s.typeArguments?.params.length||0)<(p||0)&&e.report({node:s,messageId:"missingGenericDeclaration",data:{functionName:l.name,minGenerics:p||0}}),!(r&&!a)&&s.typeArguments?.params?.some(i=>!r&&i.type===se.AST_NODE_TYPES.TSAnyKeyword||a&&i.type===se.AST_NODE_TYPES.TSTypeReference&&i.typeName.type===se.AST_NODE_TYPES.Identifier&&a.includes(i.typeName.name))&&e.report({node:s,messageId:"anyUsedInGenerics",data:{functionName:l.name}})}}}}),Ue={name:wt,rule:Xn};var me=require("@typescript-eslint/utils"),Jn=me.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Rt="no-commented-out-code",Gn=["function ","class ","interface ","type ","enum ","namespace ","import ","export ","const ","let ","var ","return "],Zn=[") {","return;","if (","else {","for (","switch (","/>","</","},",": {"," } = ","={",/\w=("|')/,");"],Qn=Jn({name:Rt,meta:{type:"problem",docs:{description:"Disallow commented code"},messages:{commentedOutCode:"Commented code is not allowed. Detected pattern: `{{ wrongPattern }}` Use a comment starting with `INFO:` if you want to keep this code commented out."},schema:[]},defaultOptions:[],create(e){function t(n){if(n.startsWith("/"))return!1;let s=n.trimStart();if(n.startsWith("*")||s.startsWith("INFO:")||s.startsWith("TODO:")||s.startsWith("DOCS:")||s.startsWith("FIX:")||s.startsWith("eslint-disable")||n.includes("@deprecated")||n.includes("@example"))return!1;for(let l of Gn)if(s.startsWith(l))return{wrongPattern:l};for(let l of Zn)if(typeof l=="string"){if(n.includes(l))return{wrongPattern:l}}else if(l.test(n))return{wrongPattern:`regex(${l.toString()})`};return!1}return{Program(){let s=e.sourceCode.getAllComments();for(let l of s)if(l.type===me.TSESTree.AST_TOKEN_TYPES.Line||l.type===me.TSESTree.AST_TOKEN_TYPES.Block){let f=t(l.value);f&&e.report({node:l,messageId:"commentedOutCode",data:{wrongPattern:f.wrongPattern}})}}}}}),We={name:Rt,rule:Qn};var be=require("@typescript-eslint/utils"),er=be.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),vt="no-default-export",tr=er({name:vt,meta:{type:"problem",docs:{description:"Disallow default exports"},schema:[],messages:{noDefaultExport:"Default exports are not allowed, use named exports instead."}},defaultOptions:[],create(e){return{ExportDefaultDeclaration(t){e.report({node:t,messageId:"noDefaultExport"})},ExportNamedDeclaration(t){for(let n of t.specifiers)n.exported.type===be.TSESTree.AST_NODE_TYPES.Identifier&&n.exported.name==="default"&&e.report({node:t,messageId:"noDefaultExport"})}}}}),He={name:vt,rule:tr};var kt=require("@typescript-eslint/utils"),nr=kt.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),At="no-leaked-text-in-jsx",rr=[",",";","[","]","(",")"],ir=nr({name:At,meta:{type:"problem",docs:{description:"Prevents leaking of text in JSX that should be wrapped in an expression container"},messages:{leakedTextInJSX:'Text "{{ text }}" should be wrapped in a JSX expression container.'},schema:[],fixable:"code"},defaultOptions:[],create(e){return{JSXText(t){let n=t.value.trim();if(!n)return;let s="";rr.includes(n)?s=n:n.includes("&&")?s="&&":n.includes("||")?s="||":n.endsWith("? (")&&(s="? ("),s&&e.report({node:t,messageId:"leakedTextInJSX",data:{text:s}})}}}}),Ve={name:At,rule:ir};var ee=require("@typescript-eslint/utils"),sr=ee.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Pt="no-non-camel-case-functions",or=/^[a-z][a-zA-Z0-9]*$/;function Ot(e){return e.typeName.type===ee.AST_NODE_TYPES.TSQualifiedName&&e.typeName.left.type===ee.AST_NODE_TYPES.Identifier&&e.typeName.left.name==="JSX"&&e.typeName.right.type===ee.AST_NODE_TYPES.Identifier&&e.typeName.right.name==="Element"}var ar=sr({name:Pt,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&&!or.test(t.id.name)){let n=t.returnType?.typeAnnotation;if(n&&(n.type===ee.AST_NODE_TYPES.TSTypeReference?Ot(n):n.type===ee.AST_NODE_TYPES.TSUnionType&&n.types.some(l=>l.type===ee.AST_NODE_TYPES.TSTypeReference&&Ot(l))))return;e.report({node:t.id,messageId:"nonCamelCaseFunction",data:{functionName:t.id.name}})}}}}}),Ye={name:Pt,rule:ar};var M=require("@typescript-eslint/utils");function ce(e,t,n=1/0){if(n!==0&&e.parent)return e.type===t?e:ce(e.parent,t,n===1/0?n:n-1)}function*ze(e){yield e,e.parent&&(yield*ze(e.parent))}var lr=M.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Nt="no-optional-root-props",cr=lr({name:Nt,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(l){return l?l.parent?.type===M.TSESTree.AST_NODE_TYPES.ExportNamedDeclaration||l.parent?.type===M.TSESTree.AST_NODE_TYPES.ExportDefaultDeclaration:!1}function n(l){let p=e.sourceCode.getDeclaredVariables(l)[0];if(!p||p.references.length!==1)return!1;let r=p.references[0];if(!r)return!1;for(let a of ze(r.identifier)){if("returnType"in a||a.type===M.TSESTree.AST_NODE_TYPES.ExportNamedDeclaration)return!1;let o=a.parent;if(!o)return!1;if(o.type===M.TSESTree.AST_NODE_TYPES.TSTypeParameterInstantiation&&o.parent.type===M.TSESTree.AST_NODE_TYPES.TSTypeReference&&o.parent.typeName.type===M.TSESTree.AST_NODE_TYPES.Identifier&&o.parent.typeName.name==="FC"){let c=ce(o.parent.parent,M.TSESTree.AST_NODE_TYPES.VariableDeclaration,4);if(c)return!(t(c)||e.sourceCode.getScope(c).references.some(T=>t(T.identifier.parent.parent)))}if(a.type===M.TSESTree.AST_NODE_TYPES.AssignmentPattern)return!1;if(o.type===M.TSESTree.AST_NODE_TYPES.ArrowFunctionExpression){let i=ce(o,M.TSESTree.AST_NODE_TYPES.VariableDeclaration);return i&&t(i)||i&&e.sourceCode.getScope(i).references.some(g=>g.identifier.parent.parent?.parent?.type===M.TSESTree.AST_NODE_TYPES.ExportNamedDeclaration)?!1:o.params.some(c=>c===a)}if(o.type===M.TSESTree.AST_NODE_TYPES.FunctionDeclaration)return t(o)||e.sourceCode.getScope(o).upper?.references.some(c=>t(c.identifier.parent.parent))?!1:o.params.some(c=>c===a)}return!1}function s(l){l.key.type!==M.TSESTree.AST_NODE_TYPES.Identifier||!l.optional||e.report({node:l.key,messageId:"optionalNotAllowed",data:{propertyName:l.key.name},suggest:[{messageId:"suggestion",fix:f=>{let p=ce(l,M.TSESTree.AST_NODE_TYPES.TSPropertySignature);if(!p)return null;let r=e.sourceCode.getText(p);return f.replaceText(p,r.replace("?:",": undefined |"))}}]})}return{TSTypeAliasDeclaration(l){if(l.typeAnnotation.type===M.TSESTree.AST_NODE_TYPES.TSTypeLiteral&&!(t(l)||!n(l)))for(let f of l.typeAnnotation.members)f.type===M.TSESTree.AST_NODE_TYPES.TSPropertySignature&&s(f)},TSInterfaceDeclaration(l){if(!(t(l)||!n(l)))for(let f of l.body.body)f.type===M.TSESTree.AST_NODE_TYPES.TSPropertySignature&&s(f)},TSTypeReference(l){if(l.typeName.type!==M.TSESTree.AST_NODE_TYPES.Identifier||l.typeName.name!=="FC"||!l.typeArguments?.params[0])return;let f=l.typeArguments.params[0];if(f.type!==M.TSESTree.AST_NODE_TYPES.TSTypeLiteral)return;let p=ce(l.parent,M.TSESTree.AST_NODE_TYPES.VariableDeclaration,4);if(!p||t(p)||e.sourceCode.getScope(p).references.some(i=>i.identifier.parent.parent?.parent?.type===M.TSESTree.AST_NODE_TYPES.ExportNamedDeclaration))return;let a=p.declarations[0].id.type===M.TSESTree.AST_NODE_TYPES.Identifier?p.declarations[0].id:null,o=e.sourceCode.getScope(p).variables.find(i=>i.name===a?.name)?.references.filter(i=>i.identifier!==a);if(!(o&&o.length>1))for(let i of f.members)i.type===M.TSESTree.AST_NODE_TYPES.TSPropertySignature&&s(i)}}}}),Be={name:Nt,rule:cr};var Dt=require("@typescript-eslint/utils"),xe=Ae(require("path"));var pr=Dt.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),_t="no-relative-imports",ur=j({find:F(),replacement:F()}),fr=j({aliases:V(ur),rootDir:$(F()),allowNotFoundAliases:$(oe()),_dev_simulateFileName:$(F())}),mr=pr({name:_t,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:[fr]},defaultOptions:[{aliases:[],rootDir:void 0}],create(e,[t]){let n=t._dev_simulateFileName??e.filename;function s(p){return p.startsWith(".")||p.startsWith("..")}function l(p,r){let a=xe.default.dirname(r);return xe.default.resolve(a,p)}function f(p){let r=t.rootDir??process.cwd(),a=xe.default.relative(r,p);if(a.startsWith("."))return null;a.startsWith("/")||(a=`/${a}`);for(let{find:o,replacement:i}of t.aliases)if(a.startsWith(i)){let c=a.replace(i,o);return{alias:o,newPath:c}}return null}return{ImportDeclaration(p){let r=p.source.value;if(!s(r))return;let a=l(r,n),o=f(a);!o&&t.allowNotFoundAliases||e.report({node:p,messageId:o?"noRelativeImportsWithAlias":"noRelativeImports",data:{alias:o?.alias},fix:o?i=>i.replaceText(p.source,`'${o.newPath}'`):void 0})}}}}),qe={name:_t,rule:mr};var te=require("@typescript-eslint/utils");var Ke=Ae(require("typescript")),dr=te.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Lt="no-unnecessary-casting",yr=j({additionalCastFunctions:$(V(j({name:F(),expectedType:Te(["string","number"])})))}),Xe={name:Lt,rule:dr({name:Lt,meta:{type:"suggestion",docs:{description:"Prevents unnecessary Number and String castings"},messages:{unnecessaryNumberCasting:"Unnecessary Number() casting on a value already of number type",unnecessaryStringCasting:"Unnecessary String() casting on a value already of string type",unnecessaryCustomCasting:"Unnecessary {{name}}() casting on a value already of {{type}} type"},schema:[yr],fixable:"code"},defaultOptions:[{}],create(e){let n=e.options[0].additionalCastFunctions||[],s=[{name:"Number",expectedType:"number"},{name:"String",expectedType:"string"},...n],l=te.ESLintUtils.getParserServices(e,!0),f=l.program?.getTypeChecker();if(!f||!l.program)throw new Error("TypeScript services or program not available");function p(i,c){switch(i.type){case te.AST_NODE_TYPES.Literal:return c==="number"?typeof i.value=="number":typeof i.value=="string";case te.AST_NODE_TYPES.TemplateLiteral:return c==="string";case te.AST_NODE_TYPES.UnaryExpression:return c==="number"?i.operator==="+"||i.operator==="-"||i.operator==="~":!1;default:return!1}}function r(i,c){return c==="number"?!!(i.flags&Ke.TypeFlags.NumberLike):!!(i.flags&Ke.TypeFlags.StringLike)}function a(i,c){return g=>g.replaceText(i,e.sourceCode.getText(c))}function o(i){if(!f||i.arguments.length!==1)return;let c=i.arguments[0];if(!c||c.type===te.AST_NODE_TYPES.SpreadElement)return;let{callee:g}=i;if(g.type!==te.AST_NODE_TYPES.Identifier)return;let T=g.name,S=s.find(b=>b.name===T);if(!S)return;if(p(c,S.expectedType)||r(f.getTypeAtLocation(l.esTreeNodeToTSNodeMap.get(c)),S.expectedType)){let b,y;T==="Number"?b="unnecessaryNumberCasting":T==="String"?b="unnecessaryStringCasting":(b="unnecessaryCustomCasting",y={name:S.name,type:S.expectedType}),e.report({node:i,messageId:b,...y?{data:y}:{},fix:a(i,c)})}}return{CallExpression:o}}})};var L=require("@typescript-eslint/utils");var gr=L.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function $t(e){let t=[];for(let n of e.members)n.type===L.AST_NODE_TYPES.TSPropertySignature&&n.key.type===L.AST_NODE_TYPES.Identifier&&t.push([n.key.name,n]);return t}function Ft(e,...t){for(let n of t)e.set(...n);return e}var hr=j({forceCheckOnFCPropTypesWithName:$(V(F()))}),jt="no-unused-type-props-in-args",Je=null,Tr=gr({name:jt,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:[hr],fixable:"code"},defaultOptions:[{}],create(e,[t]){let{forceCheckOnFCPropTypesWithName:n}=t;n&&!Je&&(Je=n.map(r=>new RegExp(r)));function s(r,a,o,i,c=!0){let g=o.name,T=e.sourceCode.getScope(a).references.find(b=>b.identifier.name===g)?.resolved,S=r&&Je?.some(b=>b.test(g));if(!T||!S&&T.references.filter(b=>b.isTypeReference).length>1)return;let d=T?.defs[0]?.node;if(!(c&&d?.parent?.type===L.AST_NODE_TYPES.ExportNamedDeclaration)){if(d?.type===L.AST_NODE_TYPES.TSTypeAliasDeclaration){l(r,a,i,d.typeAnnotation,!0);return}if(d?.type===L.AST_NODE_TYPES.TSInterfaceDeclaration){l(r,a,i,d.body,!0);return}}}function l(r,a,o,i,c){if(i.type===L.AST_NODE_TYPES.TSInterfaceBody){for(let g of i.body)g.type===L.AST_NODE_TYPES.TSPropertySignature&&g.key.type===L.AST_NODE_TYPES.Identifier&&o.set(g.key.name,g);return}if(i.type===L.AST_NODE_TYPES.TSTypeLiteral){Ft(o,...$t(i));return}if(i.type===L.AST_NODE_TYPES.TSIntersectionType){for(let g of i.types)l(r,a,o,g,!0);return}c||i.type===L.AST_NODE_TYPES.TSTypeReference&&i.typeName.type===L.AST_NODE_TYPES.Identifier&&s(r,a,i.typeName,o)}function f(r,a,o){for(let i of o)if(i.type==="ObjectPattern"&&i.typeAnnotation){let c=new Map;if(l(r,a,c,i.typeAnnotation.typeAnnotation,!1),c.size===0)continue;p(i,c)}else i.type===L.AST_NODE_TYPES.AssignmentPattern&&i.left.type===L.AST_NODE_TYPES.ObjectPattern&&f(r,a,[i.left])}function p(r,a){let o=[];if(r.properties.at(-1)?.type===L.AST_NODE_TYPES.RestElement)return;for(let T of r.properties)T.type===L.AST_NODE_TYPES.Property&&T.key.type===L.AST_NODE_TYPES.Identifier&&o.push(T.key.name);let c=[],g=[];for(let[T,S]of a)o.includes(T)||(g.push(T),c.push({node:S,messageId:"unusedObjectTypeProperty",data:{propertyName:T}}));for(let[T,S]of c.entries())e.report({...S,fix:T===c.length-1?d=>{let b=r.properties.at(-1),y=g.join(", ");return b?b?.type===L.AST_NODE_TYPES.RestElement?null:d.insertTextAfter(b,`, ${y}`):d.insertTextBeforeRange([r.range[0]+1,r.range[1]],`${y}`)}:void 0})}return{VariableDeclaration(r){let a=r.declarations[0];if(!a)return;let o=new Map,i=a.id.type===L.AST_NODE_TYPES.Identifier&&a.id.typeAnnotation?.typeAnnotation.type===L.AST_NODE_TYPES.TSTypeReference&&a.id.typeAnnotation.typeAnnotation.typeName.type===L.AST_NODE_TYPES.Identifier&&a.id.typeAnnotation.typeAnnotation.typeName.name==="FC"&&a.id.typeAnnotation.typeAnnotation.typeArguments?.params[0];if(i){if(i.type===L.AST_NODE_TYPES.TSTypeReference&&i.typeName.type===L.AST_NODE_TYPES.Identifier)s(!0,r,i.typeName,o,!1);else if(i.type===L.AST_NODE_TYPES.TSTypeLiteral)Ft(o,...$t(i));else if(i.type===L.AST_NODE_TYPES.TSIntersectionType)for(let c of i.types)c.type===L.AST_NODE_TYPES.TSTypeReference&&c.typeName.type===L.AST_NODE_TYPES.Identifier?s(!0,r,c.typeName,o,!1):l(!0,r,o,c,!0);if(o.size!==0&&a.init?.type===L.AST_NODE_TYPES.ArrowFunctionExpression){let c=a.init.params[0];if(!c){e.report({node:a.init,messageId:"missingComponentParam"});return}c.type===L.AST_NODE_TYPES.ObjectPattern&&p(c,o)}}},FunctionDeclaration:function(r){f(!1,r,r.params)},ArrowFunctionExpression(r){f(!1,r,r.params)}}}}),Ge={name:jt,rule:Tr};var pe=require("@typescript-eslint/utils"),Sr=pe.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ut="prefer-named-functions",Mt=new Map,Er=Sr({name:Ut,meta:{hasSuggestions:!0,type:"suggestion",docs:{description:"Prevent using arrow functions when a named function can be used instead"},schema:[{type:"object",properties:{ignoreRegex:{type:"string"},disallowArrowFnWithImplicitReturns:{type:"boolean"}}}],messages:{suggestion:"Convert to named function",default:'Function {{functionName}} should be defined as a named function "function {{functionName}} () {}" instead of an arrow function',withIgnoreRegex:'Function {{functionName}} should be defined as a named function "function {{functionName}} () {}", if not possible to use `function` you can also use a name that matches the rule ignore regex'}},defaultOptions:[{}],create(e,[t]){let n=null;if(t.ignoreRegex){let s=Mt.get(t.ignoreRegex);s?n=s:(n=new RegExp(t.ignoreRegex),Mt.set(t.ignoreRegex,n))}return{VariableDeclarator(s){if(s.init&&s.init.type===pe.AST_NODE_TYPES.ArrowFunctionExpression&&s.id.type===pe.AST_NODE_TYPES.Identifier){let l=s.id.name;if(s.id.typeAnnotation||n&&n.test(l)||!t.disallowArrowFnWithImplicitReturns&&s.init.body.type!==pe.AST_NODE_TYPES.BlockStatement)return;let f=s.parent,p=s.init.params,r=s.init.body,a=s.init;e.report({node:s.id,messageId:n?"withIgnoreRegex":"default",data:{functionName:l,ignoreRegex:t.ignoreRegex},suggest:[{messageId:"suggestion",fix:o=>o.replaceText(f,`${a.async?"async ":""}function ${l}(${p.map(i=>e.sourceCode.getText(i)).join(", ")||""}) ${e.sourceCode.getText(r)}`)}]})}}}}}),Ze={name:Ut,rule:Er};var U=require("@typescript-eslint/utils");var br=U.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ht="prefer-single-line-if",xr=j({maxLineLength:$(J()),maxNonSimpleConditionLength:$(J())}),Cr=br({name:Ht,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:[xr]},defaultOptions:[{}],create(e,[t]){let n=e.sourceCode;return{IfStatement(s){if(s.consequent.type!==U.AST_NODE_TYPES.BlockStatement||s.loc.start.line===s.loc.end.line||n.getCommentsInside(s.consequent).length>0||s.alternate||s.consequent.body.length!==1)return;let f=s.consequent.body[0];if(f.type===U.AST_NODE_TYPES.ReturnStatement){if(!Yt(f))return}else if(!(f.type===U.AST_NODE_TYPES.ContinueStatement||f.type===U.AST_NODE_TYPES.BreakStatement))return;if(s.test.type===U.AST_NODE_TYPES.LogicalExpression||s.test.type===U.AST_NODE_TYPES.ConditionalExpression)return;let p;if(t.maxNonSimpleConditionLength){let c=Wt(s.test);if(!c&&s.test.type===U.AST_NODE_TYPES.UnaryExpression&&s.test.operator==="!"){let g=s.test.argument;Wt(g)&&(c=!0)}if(c&&(p=n.getText(s.test),p.length>t.maxNonSimpleConditionLength))return}p||(p=n.getText(s.test));let r=n.getText(f);if(p.includes(`
15
+ `))return;let a=n.getTokenAfter(s);if(a&&a.type===U.AST_TOKEN_TYPES.Punctuator&&a.value==="}"){let c=n.getTokenAfter(a);if(c&&c.type===U.AST_TOKEN_TYPES.Keyword&&(c.value==="else"||c.value==="catch"))return}let o=Ir(n,s),i=`if (${p}) ${r}`;t.maxLineLength&&i.length+o.length>t.maxLineLength||e.report({node:s,messageId:"noSingleLineCurly",fix:c=>c.replaceText(s,i)})}}}});function Wt(e){return e.type===U.AST_NODE_TYPES.CallExpression||e.type===U.AST_NODE_TYPES.BinaryExpression||e.type===U.AST_NODE_TYPES.MemberExpression&&Vt(e)}function Vt(e){return e.object.type===U.AST_NODE_TYPES.MemberExpression?Vt(e.object):e.object.type!==U.AST_NODE_TYPES.Identifier}function Ir(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}function Yt(e){if(!e.argument)return!0;let t=e.argument;return t.type===U.AST_NODE_TYPES.ArrayExpression&&t.elements.length===0||t.type===U.AST_NODE_TYPES.ObjectExpression&&t.properties.length===0||t.type===U.AST_NODE_TYPES.Literal||t.type===U.AST_NODE_TYPES.Identifier||t.type===U.AST_NODE_TYPES.TemplateLiteral||t.type===U.AST_NODE_TYPES.TaggedTemplateExpression?!0:t.type===U.AST_NODE_TYPES.CallExpression?t.arguments.length===0:t.type===U.AST_NODE_TYPES.UnaryExpression?Yt(t):!1}var Qe={name:Ht,rule:Cr};var z=require("@typescript-eslint/utils");var wr=z.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),zt="react-compiler-migration",Rr=j({disallowHooks:$(V(j({name:F(),replacement:F()}))),disallowMethods:$(V(j({name:F(),replacement:$(F()),requireTrueProp:$(F())})))}),vr=/eslint +react-compiler\/react-compiler: +\["error/;function kr(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 Ar=wr({name:zt,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:[Rr]},defaultOptions:[{}],create(e,[t]){let n=!1;for(let s of e.sourceCode.getAllComments())if(vr.test(s.value)){n=!0;break}return n?{CallExpression(s){if(t.disallowHooks?.length){let l=null,f=null;if(s.callee.type===z.AST_NODE_TYPES.Identifier?(l=s.callee.name,f=s.callee):s.callee.type===z.AST_NODE_TYPES.MemberExpression&&s.callee.property.type===z.AST_NODE_TYPES.Identifier&&(l=s.callee.property.name,f=s.callee.property),l){let p=t.disallowHooks.find(r=>r.name===l);p&&f&&e.report({node:s,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:p.name,replacement:p.replacement},suggest:[{messageId:"replace",data:{replacement:p.replacement},fix:r=>r.replaceText(f,p.replacement)}]})}}if(t.disallowMethods?.length&&kr(s.callee)){for(let l of s.arguments)if(l.type===z.AST_NODE_TYPES.ObjectExpression){for(let f of l.properties)if(f.type===z.AST_NODE_TYPES.Property&&f.key.type===z.AST_NODE_TYPES.Identifier){let p=f.key.name,r=t.disallowMethods.find(a=>a.name===p);if(r){if(r.requireTrueProp){let a=r.requireTrueProp,o=!1;for(let i of l.properties)if(i.type===z.AST_NODE_TYPES.Property&&i.key.type===z.AST_NODE_TYPES.Identifier&&i.key.name===a&&i.value.type===z.AST_NODE_TYPES.Literal&&i.value.value===!0){o=!0;break}if(!o){e.report({node:f,messageId:"disallowedMethodWithMissingRequireTrueProp",data:{method:r.name,requireTrueProp:a}});continue}}r.replacement&&e.report({node:f,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:r.name,replacement:r.replacement},suggest:[{messageId:"replace",data:{replacement:r.replacement},fix:a=>a.replaceText(f.key,r.replacement)}]})}}}}}}:{}}}),et={name:zt,rule:Ar};var Ce=require("@typescript-eslint/utils"),Or=Ce.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Bt="require-description",Pr=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,Nr=/^eslint-disable-(next-)?line$/u,Dr=Or({name:Bt,meta:{type:"problem",docs:{description:"Require descriptions for eslint directives."},messages:{missingDescription:"Unexpected undescribed directive comment. Include descriptions to explain why the comment is necessary."},schema:[{type:"object",properties:{ignore:{type:"array",items:{type:"string",enum:["eslint","eslint-disable","eslint-disable-line","eslint-disable-next-line","eslint-enable","eslint-env","exported","global","globals"]},additionalItems:!1,uniqueItems:!0}},additionalProperties:!1}]},defaultOptions:[{ignore:[]}],create(e,[t]){let n=e.sourceCode,s=new Set(t.ignore||[]);return{Program(){for(let l of n.getAllComments()){let f=_r(l);f!=null&&(s.has(f.kind)||f.description||e.report({loc:$r(l.loc),messageId:"missingDescription"}))}}}}}),qt={name:Bt,rule:Dr};function _r(e){let{text:t,description:n}=Lr(e.value);if(!t)return null;let s=Pr.exec(t);if(!s)return null;let l=s[1];if(!l)return null;let f=Nr.test(l);if(e.type===Ce.TSESTree.AST_TOKEN_TYPES.Line&&!f||f&&e.loc.start.line!==e.loc.end.line)return null;let p=t.slice(s.index+l.length);return{kind:l,value:p.trim(),description:n}}function Lr(e){let t=e.split(/\s-{2,}\s/u);return{text:t[0]?.trim(),description:t.length>1?t[1]?.trim()??null:null}}function $r(e){return{start:{line:e.start.line,column:-1},end:e.end}}function Jt(e){return/^use[A-Z0-9]/.test(e)}function Ie(e){return e.type==="Identifier"?Jt(e.name):e.type==="MemberExpression"&&!e.computed&&Ie(e.property)?e.object.type==="Identifier":!1}function Gt(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function Zt(e,t){return e.name===t||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===t}function Qt(e){return!!(e.parent&&e.parent.callee&&Zt(e.parent.callee,"forwardRef"))}function en(e){return!!(e.parent&&e.parent.callee&&Zt(e.parent.callee,"memo"))}function tt(e){for(;e;){let t=nn(e);if(t&&(Gt(t)||Ie(t))||Qt(e)||en(e))return!0;e=e.parent}return!1}function Kt(e){return!1}function nt(e){return!1}var Fr=/eslint +react-compiler\/react-compiler: +\["error/,tn={meta:{type:"problem",docs:{description:"enforces the Rules of Hooks",recommended:!0,url:"https://reactjs.org/docs/hooks-rules.html"},schema:[{type:"object",ignoreIfReactCompilerIsEnabled:!1,properties:{ignoreIfReactCompilerIsEnabled:{type:"boolean"}}}]},create(e){if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let a of e.sourceCode.getAllComments())if(Fr.test(a.value))return{CallExpression(o){let i=null;o.callee.name==="useMemo"?i="useMemo":o.callee.name==="useCallback"&&(i="useCallback"),i&&e.report({node:o,message:`"${i}" is not necessary when using React Compiler.`})}}}let t=typeof e.getSource=="function"?a=>t(a):a=>e.sourceCode.getText(a),n=typeof e.getScope=="function"?()=>n():a=>e.sourceCode.getScope(a),s=null,l=[],f=[],p=new WeakSet;function r(a){for(let o of a.references){let i=o.identifier.parent;if(i.type==="VariableDeclarator"&&i.init&&i.init.type==="CallExpression"&&i.init.callee&&Kt(i.init.callee))for(let c of o.resolved.references)c!==o&&p.add(c.identifier)}}return{onCodePathSegmentStart:a=>f.push(a),onCodePathSegmentEnd:()=>f.pop(),onCodePathStart:()=>l.push(new Map),onCodePathEnd(a,o){let i=l.pop();if(i.size===0)return;let c=new Set;function g(h,w){let{cache:R}=g,k=R.get(h.id),D=new Set(w);if(D.has(h.id)){let A=[...D],W=A.slice(A.indexOf(h.id)+1);for(let X of W)c.add(X);return BigInt("0")}if(D.add(h.id),k!==void 0)return k;if(a.thrownSegments.includes(h))k=BigInt("0");else if(h.prevSegments.length===0)k=BigInt("1");else{k=BigInt("0");for(let A of h.prevSegments)k+=g(A,D)}return h.reachable&&k===BigInt("0")?R.delete(h.id):R.set(h.id,k),k}function T(h,w){let{cache:R}=T,k=R.get(h.id),D=new Set(w);if(D.has(h.id)){let A=Array.from(D),W=A.slice(A.indexOf(h.id)+1);for(let X of W)c.add(X);return BigInt("0")}if(D.add(h.id),k!==void 0)return k;if(a.thrownSegments.includes(h))k=BigInt("0");else if(h.nextSegments.length===0)k=BigInt("1");else{k=BigInt("0");for(let A of h.nextSegments)k+=T(A,D)}return R.set(h.id,k),k}function S(h){let{cache:w}=S,R=w.get(h.id);if(R===null)return 1/0;if(R!==void 0)return R;if(w.set(h.id,null),h.prevSegments.length===0)R=1;else{R=1/0;for(let k of h.prevSegments){let D=S(k);D<R&&(R=D)}R+=1}return w.set(h.id,R),R}g.cache=new Map,T.cache=new Map,S.cache=new Map;let d=T(a.initialSegment),b=nn(o),y=tt(o),N=b?Gt(b)||Ie(b):Qt(o)||en(o),v=1/0;for(let h of a.finalSegments){if(!h.reachable)continue;let w=S(h);w<v&&(v=w)}for(let[h,w]of i){if(!h.reachable)continue;let R=h.nextSegments.length===0?v<=S(h):v<S(h),k=g(h)*T(h),D=c.has(h.id);for(let A of w)if(D&&!nt(A)&&e.report({node:A,message:`React Hook "${t(A)}" 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.`}),N){if(o.async&&e.report({node:A,message:`React Hook "${t(A)}" cannot be called in an async function.`}),!D&&k!==d&&!nt(A)){let X=`React Hook "${t(A)}" is called conditionally. React Hooks must be called in the exact same order in every component render.`+(R?" Did you accidentally call a React Hook after an early return?":"");e.report({node:A,message:X})}}else if(o.parent&&(o.parent.type==="MethodDefinition"||o.parent.type==="ClassProperty")&&o.parent.value===o){let W=`React Hook "${t(A)}" 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:A,message:W})}else if(b){let W=`React Hook "${t(A)}" is called in function "${t(b)}" 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:A,message:W})}else if(o.type==="Program"){let W=`React Hook "${t(A)}" 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:A,message:W})}else if(y&&!nt(A)){if(o.parent.type==="CallExpression"&&o.parent.callee.type==="Identifier"&&o.parent.callee.name==="useCallback"){let X=o.parent;if(X.parent.type==="VariableDeclarator"&&Jt(X.parent.id.name))return}let W=`React Hook "${t(A)}" 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:A,message:W})}}},CallExpression(a){if(Ie(a.callee)){let o=Xt(l),i=Xt(f),c=o.get(i);c||(c=[],o.set(i,c)),c.push(a.callee)}a.callee.type==="Identifier"&&(a.callee.name==="useEffect"||Kt(a.callee))&&a.arguments.length>0&&(s=a)},Identifier(a){s==null&&p.has(a)&&a.parent.type!=="CallExpression"&&e.report({node:a,message:`\`${t(a)}\` is a function created with React Hook "useEffectEvent", and can only be called from the same component. They cannot be assigned to variables or passed down.`})},"CallExpression:exit"(a){a===s&&(s=null)},FunctionDeclaration(a){tt(a)&&r(n(a))},ArrowFunctionExpression(a){tt(a)&&r(n(a))}}}};function nn(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 Xt(e){return e[e.length-1]}var rn={[Ge.name]:Ge.rule,[We.name]:We.rule,[Ue.name]:Ue.rule,"rules-of-hooks":tn,"exhaustive-deps":St,"require-description":qt.rule,[He.name]:He.rule,[Ye.name]:Ye.rule,[Ze.name]:Ze.rule,[De.name]:De.rule,[Me.name]:Me.rule,[qe.name]:qe.rule,[Qe.name]:Qe.rule,[Be.name]:Be.rule,[Ve.name]:Ve.rule,[_e.name]:_e.rule,[et.name]:et.rule,[Ne.name]:Ne.rule,[je.name]:je.rule,[Xe.name]:Xe.rule};var jr={rules:rn};0&&(module.exports={extendedLintPlugin});
@@ -1,5 +1,6 @@
1
- import{AST_NODE_TYPES as V,ESLintUtils as ln}from"@typescript-eslint/utils";var be=Symbol.for("optional");function _(e){return{...e,[be]:!0}}function fe(e,t){return{enum:e,...t}}function ne(e){return{...e,type:"boolean"}}function L(e){return{...e,type:"string"}}function J(e){return{...e,type:"number"}}function it(e){return{...e,type:"integer"}}function H(e,t){return{...t,type:"array",items:e}}function $(e,t){let n={...t,type:"object",properties:e};if(e&&(n.additionalProperties||=!1,!n.required)){let o,l=[];for(o in e)e[o][be]?e[o][be]=void 0:l.push(o);l.length>0&&(n.required=l)}return n}function xe(...e){return{anyOf:e}}var cn=ln.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),ot="react-compiler-extra",pn=$({runOnlyWithEnableCompilerDirective:_(ne())}),un=/eslint +react-compiler\/react-compiler: +\["error/;function fn(e){return e.type===V.Identifier?e.name.startsWith("use"):e.type===V.MemberExpression&&e.property.type===V.Identifier?e.property.name.startsWith("use"):!1}var mn=/\bthis[.[]/;function st(e){return mn.test(e)}var dn=cn({name:ot,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:[pn]},defaultOptions:[{}],create(e,[t]){let n=!1;if(t.runOnlyWithEnableCompilerDirective){for(let f of e.sourceCode.getAllComments())if(un.test(f.value)){n=!0;break}if(!n)return{}}function o(f){for(let p of f.properties)if(p.type===V.Property&&p.method&&p.value.type===V.FunctionExpression){let r=e.sourceCode,a=r.getText(p.key),s=p.value,i=r.getText(s.body);if(st(i))e.report({node:p,messageId:"thisKeywordInMethod"});else{let c=s.params.map(h=>r.getText(h)).join(", "),y="";s.generator?y=`${a}: function* (${c}) ${i}`:y=`${a}: (${c}) => ${i}`,e.report({node:p,messageId:"objectMethodIsNotSupported",fix:h=>h.replaceText(p,y)})}}}function l(f){for(let p of f.properties)if(p.type===V.Property&&p.value.type===V.ObjectExpression){for(let r of p.value.properties)if(r.type===V.Property&&r.method&&r.value.type===V.FunctionExpression){let s=e.sourceCode.getText(r.value.body);st(s)&&e.report({node:r,messageId:"thisKeywordInMethod"})}}}return{CallExpression(f){if(fn(f.callee))for(let p of f.arguments){if(p.type===V.ObjectExpression&&(o(p),l(p)),p.type===V.ArrowFunctionExpression&&(p.body.type===V.ObjectExpression&&(o(p.body),l(p.body)),p.body.type===V.BlockStatement))for(let r of p.body.body)r.type===V.ReturnStatement&&r.argument?.type===V.ObjectExpression&&(o(r.argument),l(r.argument));if(p.type===V.FunctionExpression)for(let r of p.body.body)r.type===V.ReturnStatement&&r.argument?.type===V.ObjectExpression&&(o(r.argument),l(r.argument))}}}}}),Ce={name:ot,rule:dn};import{AST_NODE_TYPES as Ie,ESLintUtils as yn}from"@typescript-eslint/utils";var gn=yn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),hn=$({disallow:_(H($({selector:L(),message:L(),replace:_(xe(L(),$({regex:L(),with:L()}))),replaceType:_(fe(["suggestion","autofix"]))}))),__dev_simulateFileName:_(L()),mustMatchSyntax:_(H($({includeRegex:L(),mustCallFn:H($({anyCall:H($({fn:L(),withArgs:H($({atIndex:it(),literal:xe(L(),J(),ne())}))})),message:_(L())}))})))}),ct="advanced-no-restricted-syntax",Tn=gn({name:ct,meta:{type:"suggestion",docs:{description:"Disallow specific syntax patterns"},schema:[hn],messages:{default:"{{message}}"},fixable:"code",hasSuggestions:!0},defaultOptions:[{disallow:[]}],create(e,[t]){let n={},{mustMatchSyntax:o,__dev_simulateFileName:l,disallow:f}=t,p=l??e.filename,r=[],a=new Set;for(let{includeRegex:i,mustCallFn:c}of o??[]){let y=Sn(p,new RegExp(i));if(!y)continue;let h=S=>{let d=S;for(let{name:E,value:T}of y)d=d.replaceAll(E,T);return d};for(let{anyCall:S,message:d}of c){let E=`Expected file to call the function: ${S.map(({fn:T})=>T).join(" or ")}`;a.add(E),r.push(T=>{let{callee:N}=T;if(N.type===Ie.Identifier){for(let{fn:v,withArgs:g}of S)if(N.name===v){a.delete(E);for(let w of g){let R=T.arguments[w.atIndex],k=typeof w.literal=="string"?h(w.literal):w.literal;if(!R){e.report({node:T,messageId:"default",data:{message:`Missing argument with value "${k}" at index ${w.atIndex}${d?`: ${h(d)}`:""}`}});continue}if(R.type!==Ie.Literal){e.report({node:R,messageId:"default",data:{message:`Argument at position ${w.atIndex} should the literal "${k}"${d?`: ${h(d)}`:""}`}});continue}R.value!==k&&e.report({node:R,messageId:"default",data:{message:`Argument should have the value "${k}"${d?`: ${h(d)}`:""}`},fix:D=>D.replaceText(R,typeof k=="string"?`'${k}'`:String(k))})}break}}})}}for(let{selector:i,message:c,replace:y,replaceType:h="suggestion"}of f??[]){if(i==="CallExpression"){r.push(S=>{s(y,S,c,h)});continue}n[i]=S=>{s(y,S,c,h)}}return r.length>0&&(n.CallExpression=i=>{if(i.type===Ie.CallExpression)for(let c of r)c(i)}),n["Program:exit"]=i=>{for(let c of a)e.report({node:i,messageId:"default",data:{message:`${c}`}})},n;function s(i,c,y,h){let S=d=>{if(!i)return null;if(typeof i=="string")return d.replaceText(c,i);{let E=new RegExp(i.regex),T=e.sourceCode.getText(c);return d.replaceText(c,T.replace(E,i.with))}};e.report({node:c,messageId:"default",data:{message:y},fix:i&&h==="autofix"?S:void 0,suggest:i&&h==="suggestion"?[{messageId:"default",data:{message:`Replace with "${typeof i=="string"?i:i.with}"`},fix:S}]:void 0})}}});function Sn(e,t){let n=[],o=t.exec(e);if(!o)return null;let[l,...f]=o;n.push({name:"$0_lowercase",value:l.toLowerCase()}),n.push({name:"$0_capitalize",value:at(l)}),n.push({name:"$0_uncapitalize",value:lt(l)}),n.push({name:"$0",value:l});for(let p=0;p<f.length;p++){let r=`$${p+1}`,a=f[p];n.push({name:`${r}_lowercase`,value:a.toLowerCase()}),n.push({name:`${r}_capitalize`,value:at(a)}),n.push({name:`${r}_uncapitalize`,value:lt(a)}),n.push({name:r,value:a})}return n}function at(e){return e.charAt(0).toUpperCase()+e.slice(1)}function lt(e){return e.charAt(0).toLowerCase()+e.slice(1)}var we={name:ct,rule:Tn};import{AST_NODE_TYPES as j,AST_TOKEN_TYPES as Re,ESLintUtils as En}from"@typescript-eslint/utils";var bn=En.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),ut="collapse-simple-objs-in-one-line",xn=$({maxLineLength:_(J()),maxProperties:_(J()),nestedObjMaxLineLength:_(J()),nestedObjMaxProperties:_(J()),ignoreTypesWithSuffix:_(H(L()))}),Cn=bn({name:ut,meta:{type:"suggestion",fixable:"code",docs:{description:"Format simple objects and types in one line"},messages:{singleLineProp:"Object/type should be written in a single line"},schema:[xn]},defaultOptions:[{}],create(e,[t]){let n=e.sourceCode,o=t.ignoreTypesWithSuffix??[],l=t.maxProperties??2,f=t.nestedObjMaxLineLength??t.maxLineLength,p=t.nestedObjMaxProperties??3;function r(s){if(s.type===j.ObjectExpression){let i=s.parent.type===j.Property,c=i?p:l,y=s.properties.length;if(y>c)return!1;if(y===1){let S=s.properties[0];return S.type===j.Property&&(S.value.type===j.ObjectExpression||S.value.type===j.ArrayExpression)?!1:{text:n.getText(S),isNested:i,propsSize:y}}let h=[];for(let S of s.properties){if(S.type===j.Property){let d=S.value.type;if(!(d===j.Literal||d===j.Identifier||d===j.TemplateLiteral||d===j.TaggedTemplateExpression))return!1}h.push(n.getText(S))}return{text:h.join(", "),isNested:i,propsSize:y}}else{let i=s.parent.parent?.type===j.TSPropertySignature,c=i?p:l,y=s.members.length;if(y>c)return!1;if(o.length>0&&s.parent.type===j.TSTypeAliasDeclaration){let S=s.parent.id.name;if(o.some(d=>S.endsWith(d)))return!1}if(y===1){let S=s.members[0];return S.type===j.TSPropertySignature&&S.typeAnnotation?.typeAnnotation.type===j.TSTypeLiteral?!1:{text:n.getText(S),isNested:i,propsSize:1}}if(s.parent.type===j.TSIntersectionType||s.parent.type===j.TSUnionType)return!1;let h=[];for(let S of s.members){if(S.type!==j.TSPropertySignature)return!1;let d=S.typeAnnotation?.typeAnnotation;if(!d||d.type===j.TSTypeLiteral||!pt(d.type))return!1;if(d.type===j.TSTypeReference&&d.typeArguments){if(d.typeArguments.params.length>1)return!1;let T=d.typeArguments.params[0];if(!pt(T.type))return!1}let E=n.getText(S).trim();(E.endsWith(";")||E.endsWith(","))&&(E=E.slice(0,-1)),h.push(E)}return{text:h.join("; "),isNested:i,propsSize:y}}}function a(s){if(s.loc.start.line===s.loc.end.line||s.parent.type!==j.JSXExpressionContainer&&n.getTokenAfter(s,{filter:E=>{let T=E.type===Re.Punctuator&&E.value===",",N=E.type===Re.Punctuator&&E.value===";";return!T&&!N}})?.loc.start.line===s.loc.end.line)return;let i=r(s);if(!i)return;let c=i.text;if(c.includes(`
2
- `)||n.getCommentsInside(s).length>0)return;c.endsWith(";")&&(c=c.slice(0,-1));let y=`{ ${c} }`,h=wn(n,s),S=i.isNested&&i.propsSize>2?f:t.maxLineLength;S&&y.length+h.length+(In(s,n)?1:0)>S||e.report({node:s,messageId:"singleLineProp",fix:d=>d.replaceText(s,y)})}return{TSTypeLiteral:a,ObjectExpression:a}}});function pt(e){return e===j.TSLiteralType||e===j.TSTypeReference||e===j.TSNumberKeyword||e===j.TSStringKeyword||e===j.TSBooleanKeyword||e===j.TSNullKeyword||e===j.TSUndefinedKeyword}function In(e,t){let n=t.getTokenAfter(e);return n?.type===Re.Punctuator&&(n.value===","||n.value===";"||n.value==="}")&&n.loc.start.line===e.loc.end.line}function wn(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}var ve={name:ut,rule:Cn};var Rn=/eslint +react-compiler\/react-compiler: +\["error/,mt={meta:{type:"suggestion",docs:{description:"verifies the list of dependencies for Hooks like useEffect and similar",recommended:!0,url:"https://github.com/facebook/react/issues/14920"},fixable:"code",hasSuggestions:!0,schema:[{type:"object",additionalProperties:!1,ignoreIfReactCompilerIsEnabled:!1,enableDangerousAutofixThisMayCauseInfiniteLoops:!1,properties:{additionalHooks:{type:"string"},ignoreIfReactCompilerIsEnabled:{type:"boolean"},enableDangerousAutofixThisMayCauseInfiniteLoops:{type:"boolean"}}}]},create(e){let t=!1,n=typeof e.getSource=="function"?T=>n(T):T=>e.sourceCode.getText(T),o=typeof e.getScope=="function"?()=>o():T=>e.sourceCode.getScope(T),l=e.options&&e.options[0]&&e.options[0].additionalHooks?new RegExp(e.options[0].additionalHooks):void 0,f=e.options&&e.options[0]&&e.options[0].enableDangerousAutofixThisMayCauseInfiniteLoops||!1,p={additionalHooks:l,enableDangerousAutofixThisMayCauseInfiniteLoops:f};function r(T){f&&Array.isArray(T.suggest)&&T.suggest.length>0&&(T.fix=T.suggest[0].fix),e.report(T)}let a=e.getSourceCode().scopeManager,s=new WeakMap,i=new WeakSet,c=new WeakMap,y=new WeakMap,h=new WeakSet;function S(T,N){return function(v){if(N.has(v))return N.get(v);let g=T(v);return N.set(v,g),g}}function d(T,N,v,g,w){w&&T.async&&r({node:T,message:`Effect callbacks are synchronous to prevent race conditions. Put the async function inside:
1
+ import{AST_NODE_TYPES as V,ESLintUtils as an}from"@typescript-eslint/utils";var be=Symbol.for("optional");function _(e){return{...e,[be]:!0}}function fe(e,t){return{enum:e,...t}}function ne(e){return{...e,type:"boolean"}}function L(e){return{...e,type:"string"}}function J(e){return{...e,type:"number"}}function rt(e){return{...e,type:"integer"}}function H(e,t){return{...t,type:"array",items:e}}function $(e,t){let r={...t,type:"object",properties:e};if(e&&(r.additionalProperties||=!1,!r.required)){let o,l=[];for(o in e)e[o][be]?e[o][be]=void 0:l.push(o);l.length>0&&(r.required=l)}return r}function xe(...e){return{anyOf:e}}var ln=an.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),st="react-compiler-extra",cn=$({runOnlyWithEnableCompilerDirective:_(ne())}),pn=/eslint +react-compiler\/react-compiler: +\["error/;function un(e){return e.type===V.Identifier?e.name.startsWith("use"):e.type===V.MemberExpression&&e.property.type===V.Identifier?e.property.name.startsWith("use"):!1}var fn=/\bthis[.[]/;function it(e){return fn.test(e)}var mn=ln({name:st,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:[cn]},defaultOptions:[{}],create(e,[t]){let r=!1;if(t.runOnlyWithEnableCompilerDirective){for(let f of e.sourceCode.getAllComments())if(pn.test(f.value)){r=!0;break}if(!r)return{}}function o(f){for(let p of f.properties)if(p.type===V.Property&&p.method&&p.value.type===V.FunctionExpression){let n=e.sourceCode,a=n.getText(p.key),s=p.value,i=n.getText(s.body);if(it(i))e.report({node:p,messageId:"thisKeywordInMethod"});else{let c=s.params.map(T=>n.getText(T)).join(", "),g="";s.generator?g=`${a}: function* (${c}) ${i}`:g=`${a}: (${c}) => ${i}`,e.report({node:p,messageId:"objectMethodIsNotSupported",fix:T=>T.replaceText(p,g)})}}}function l(f){for(let p of f.properties)if(p.type===V.Property&&p.value.type===V.ObjectExpression){for(let n of p.value.properties)if(n.type===V.Property&&n.method&&n.value.type===V.FunctionExpression){let s=e.sourceCode.getText(n.value.body);it(s)&&e.report({node:n,messageId:"thisKeywordInMethod"})}}}return{CallExpression(f){if(un(f.callee))for(let p of f.arguments){if(p.type===V.ObjectExpression&&(o(p),l(p)),p.type===V.ArrowFunctionExpression&&(p.body.type===V.ObjectExpression&&(o(p.body),l(p.body)),p.body.type===V.BlockStatement))for(let n of p.body.body)n.type===V.ReturnStatement&&n.argument?.type===V.ObjectExpression&&(o(n.argument),l(n.argument));if(p.type===V.FunctionExpression)for(let n of p.body.body)n.type===V.ReturnStatement&&n.argument?.type===V.ObjectExpression&&(o(n.argument),l(n.argument))}}}}}),Ce={name:st,rule:mn};import{AST_NODE_TYPES as Ie,ESLintUtils as dn}from"@typescript-eslint/utils";var yn=dn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),gn=$({disallow:_(H($({selector:L(),message:L(),replace:_(xe(L(),$({regex:L(),with:L()}))),replaceType:_(fe(["suggestion","autofix"]))}))),__dev_simulateFileName:_(L()),mustMatchSyntax:_(H($({includeRegex:L(),mustCallFn:H($({anyCall:H($({fn:L(),withArgs:H($({atIndex:rt(),literal:xe(L(),J(),ne())}))})),message:_(L())}))})))}),lt="advanced-no-restricted-syntax",hn=yn({name:lt,meta:{type:"suggestion",docs:{description:"Disallow specific syntax patterns"},schema:[gn],messages:{default:"{{message}}"},fixable:"code",hasSuggestions:!0},defaultOptions:[{disallow:[]}],create(e,[t]){let r={},{mustMatchSyntax:o,__dev_simulateFileName:l,disallow:f}=t,p=l??e.filename,n=[],a=new Set;for(let{includeRegex:i,mustCallFn:c}of o??[]){let g=Tn(p,new RegExp(i));if(!g)continue;let T=S=>{let d=S;for(let{name:b,value:y}of g)d=d.replaceAll(b,y);return d};for(let{anyCall:S,message:d}of c){let b=`Expected file to call the function: ${S.map(({fn:y})=>y).join(" or ")}`;a.add(b),n.push(y=>{let{callee:N}=y;if(N.type===Ie.Identifier){for(let{fn:v,withArgs:h}of S)if(N.name===v){a.delete(b);for(let w of h){let R=y.arguments[w.atIndex],k=typeof w.literal=="string"?T(w.literal):w.literal;if(!R){e.report({node:y,messageId:"default",data:{message:`Missing argument with value "${k}" at index ${w.atIndex}${d?`: ${T(d)}`:""}`}});continue}if(R.type!==Ie.Literal){e.report({node:R,messageId:"default",data:{message:`Argument at position ${w.atIndex} should the literal "${k}"${d?`: ${T(d)}`:""}`}});continue}R.value!==k&&e.report({node:R,messageId:"default",data:{message:`Argument should have the value "${k}"${d?`: ${T(d)}`:""}`},fix:D=>D.replaceText(R,typeof k=="string"?`'${k}'`:String(k))})}break}}})}}for(let{selector:i,message:c,replace:g,replaceType:T="suggestion"}of f??[]){if(i==="CallExpression"){n.push(S=>{s(g,S,c,T)});continue}r[i]=S=>{s(g,S,c,T)}}return n.length>0&&(r.CallExpression=i=>{if(i.type===Ie.CallExpression)for(let c of n)c(i)}),r["Program:exit"]=i=>{for(let c of a)e.report({node:i,messageId:"default",data:{message:`${c}`}})},r;function s(i,c,g,T){let S=d=>{if(!i)return null;if(typeof i=="string")return d.replaceText(c,i);{let b=new RegExp(i.regex),y=e.sourceCode.getText(c);return d.replaceText(c,y.replace(b,i.with))}};e.report({node:c,messageId:"default",data:{message:g},fix:i&&T==="autofix"?S:void 0,suggest:i&&T==="suggestion"?[{messageId:"default",data:{message:`Replace with "${typeof i=="string"?i:i.with}"`},fix:S}]:void 0})}}});function Tn(e,t){let r=[],o=t.exec(e);if(!o)return null;let[l,...f]=o;r.push({name:"$0_lowercase",value:l.toLowerCase()}),r.push({name:"$0_capitalize",value:ot(l)}),r.push({name:"$0_uncapitalize",value:at(l)}),r.push({name:"$0",value:l});for(let p=0;p<f.length;p++){let n=`$${p+1}`,a=f[p];r.push({name:`${n}_lowercase`,value:a.toLowerCase()}),r.push({name:`${n}_capitalize`,value:ot(a)}),r.push({name:`${n}_uncapitalize`,value:at(a)}),r.push({name:n,value:a})}return r}function ot(e){return e.charAt(0).toUpperCase()+e.slice(1)}function at(e){return e.charAt(0).toLowerCase()+e.slice(1)}var we={name:lt,rule:hn};import{AST_NODE_TYPES as j,AST_TOKEN_TYPES as Sn,ESLintUtils as En}from"@typescript-eslint/utils";var bn=En.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),pt="collapse-simple-objs-in-one-line",xn=$({maxLineLength:_(J()),maxProperties:_(J()),nestedObjMaxLineLength:_(J()),nestedObjMaxProperties:_(J()),ignoreTypesWithSuffix:_(H(L()))}),Cn=bn({name:pt,meta:{type:"suggestion",fixable:"code",docs:{description:"Format simple objects and types in one line"},messages:{singleLineProp:"Object/type should be written in a single line"},schema:[xn]},defaultOptions:[{}],create(e,[t]){let r=e.sourceCode,o=t.ignoreTypesWithSuffix??[],l=t.maxProperties??2,f=t.nestedObjMaxLineLength??t.maxLineLength,p=t.nestedObjMaxProperties??3;function n(s){if(s.type===j.ObjectExpression){let i=s.parent.type===j.Property,c=i?p:l,g=s.properties.length;if(g>c)return!1;if(g===1){let S=s.properties[0];return S.type===j.Property&&(S.value.type===j.ObjectExpression||S.value.type===j.ArrayExpression)?!1:{text:r.getText(S),isNested:i,propsSize:g}}let T=[];for(let S of s.properties){if(S.type===j.Property){let d=S.value.type;if(!(d===j.Literal||d===j.Identifier||d===j.TemplateLiteral||d===j.TaggedTemplateExpression))return!1}T.push(r.getText(S))}return{text:T.join(", "),isNested:i,propsSize:g}}else{let i=s.parent.parent?.type===j.TSPropertySignature,c=i?p:l,g=s.members.length;if(g>c)return!1;if(o.length>0&&s.parent.type===j.TSTypeAliasDeclaration){let S=s.parent.id.name;if(o.some(d=>S.endsWith(d)))return!1}if(g===1){let S=s.members[0];return S.type===j.TSPropertySignature&&S.typeAnnotation?.typeAnnotation.type===j.TSTypeLiteral?!1:{text:r.getText(S),isNested:i,propsSize:1}}if(s.parent.type===j.TSIntersectionType||s.parent.type===j.TSUnionType)return!1;let T=[];for(let S of s.members){if(S.type!==j.TSPropertySignature)return!1;let d=S.typeAnnotation?.typeAnnotation;if(!d||d.type===j.TSTypeLiteral||!ct(d.type))return!1;if(d.type===j.TSTypeReference&&d.typeArguments){if(d.typeArguments.params.length>1)return!1;let y=d.typeArguments.params[0];if(!ct(y.type))return!1}let b=r.getText(S).trim();(b.endsWith(";")||b.endsWith(","))&&(b=b.slice(0,-1)),T.push(b)}return{text:T.join("; "),isNested:i,propsSize:g}}}function a(s){if(s.loc.start.line===s.loc.end.line)return;if(s.parent.type!==j.JSXExpressionContainer){let d=0,b=r.getTokenAfter(s,{filter:y=>y.type!==Sn.Punctuator?!0:y.value===","||y.value===";"||y.value===")"||y.value==="}"?(d++,!1):!0});if(d>2||b?.loc.start.line===s.loc.end.line)return}let i=n(s);if(!i)return;let c=i.text;if(c.includes(`
2
+ `)||r.getCommentsInside(s).length>0)return;c.endsWith(";")&&(c=c.slice(0,-1));let g=`{ ${c} }`,T=wn(r,s),S=i.isNested&&i.propsSize>2?f:t.maxLineLength;S&&g.length+T.length+In(s,r)>S||e.report({node:s,messageId:"singleLineProp",fix:d=>d.replaceText(s,g)})}return{TSTypeLiteral:a,ObjectExpression:a}}});function ct(e){return e===j.TSLiteralType||e===j.TSTypeReference||e===j.TSNumberKeyword||e===j.TSStringKeyword||e===j.TSBooleanKeyword||e===j.TSNullKeyword||e===j.TSUndefinedKeyword}function In(e,t){let r=t.getLastToken(e);if(!r)return 0;let o=t.text.indexOf(`
3
+ `,r.range[1]);return(o!==-1?o:t.text.length)-r.range[1]}function wn(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}var Re={name:pt,rule:Cn};var Rn=/eslint +react-compiler\/react-compiler: +\["error/,ft={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"?y=>r(y):y=>e.sourceCode.getText(y),o=typeof e.getScope=="function"?()=>o():y=>e.sourceCode.getScope(y),l=e.options&&e.options[0]&&e.options[0].additionalHooks?new RegExp(e.options[0].additionalHooks):void 0,f=e.options&&e.options[0]&&e.options[0].enableDangerousAutofixThisMayCauseInfiniteLoops||!1,p={additionalHooks:l,enableDangerousAutofixThisMayCauseInfiniteLoops:f};function n(y){f&&Array.isArray(y.suggest)&&y.suggest.length>0&&(y.fix=y.suggest[0].fix),e.report(y)}let a=e.getSourceCode().scopeManager,s=new WeakMap,i=new WeakSet,c=new WeakMap,g=new WeakMap,T=new WeakSet;function S(y,N){return function(v){if(N.has(v))return N.get(v);let h=y(v);return N.set(v,h),h}}function d(y,N,v,h,w){w&&y.async&&n({node:y,message:`Effect callbacks are synchronous to prevent race conditions. Put the async function inside:
3
4
 
4
5
  useEffect(() => {
5
6
  async function fetchData() {
@@ -10,5 +11,5 @@ useEffect(() => {
10
11
  fetchData();
11
12
  }, [someId]); // Or [] if effect doesn't need props or state
12
13
 
13
- Learn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching`});let R=a.acquire(T),k=new Set,D=null;{let u=R.upper;for(;u&&(k.add(u),u.type!=="function");)u=u.upper;if(!u)return;D=u}let A=Array.isArray;function U(u){if(!A(u.defs))return!1;let m=u.defs[0];if(m==null||m.node.type!=="VariableDeclarator")return!1;let b=m.node.init;if(b==null)return!1;for(;b.type==="TSAsExpression";)b=b.expression;let x=m.node.parent;if(x==null&&(Oe(D.block,m.node.id),x=m.node.parent,x==null))return!1;if(x.kind==="const"&&b.type==="Literal"&&(typeof b.value=="string"||typeof b.value=="number"||b.value===null))return!0;if(b.type!=="CallExpression")return!1;let I=b.callee;if(I.type==="MemberExpression"&&I.object.name==="React"&&I.property!=null&&!I.computed&&(I=I.property),I.type!=="Identifier")return!1;let C=m.node.id,{name:O}=I;if(O==="useRef"&&C.type==="Identifier")return!0;if(Pn(I)&&C.type==="Identifier"){for(let P of u.references)P!==C&&h.add(P.identifier);return!0}else if(O==="useState"||O==="useReducer"){if(C.type==="ArrayPattern"&&C.elements.length===2&&A(u.identifiers)){if(C.elements[1]===u.identifiers[0]){if(O==="useState"){let P=u.references,B=0;for(let Z=0;Z<P.length;Z++){if(P[Z].isWrite()&&B++,B>1)return!1;s.set(P[Z].identifier,C.elements[0])}}return!0}else if(C.elements[0]===u.identifiers[0]){if(O==="useState"){let P=u.references;for(let B=0;B<P.length;B++)i.add(P[B].identifier)}return!1}}}else if(O==="useTransition"&&C.type==="ArrayPattern"&&C.elements.length===2&&Array.isArray(u.identifiers)&&C.elements[1]===u.identifiers[0])return!0;return!1}function X(u){if(!A(u.defs))return!1;let m=u.defs[0];if(m==null||m.node==null||m.node.id==null)return!1;let b=m.node,x=D.childScopes,I=null,C;for(C=0;C<x.length;C++){let O=x[C],P=O.block;if(b.type==="FunctionDeclaration"&&P===b||b.type==="VariableDeclarator"&&P.parent===b){I=O;break}}if(I==null)return!1;for(C=0;C<I.through.length;C++){let O=I.through[C];if(O.resolved!=null&&k.has(O.resolved.scope)&&!Ze(O.resolved))return!1}return!0}let Ze=S(U,c),en=S(X,y),Qe=new Map;function tn(u){let m=u.from,b=!1;for(;m.block!==T;)m.type==="function"&&(b=m.block.parent!=null&&m.block.parent.type==="ReturnStatement"),m=m.upper;return b}let z=new Map,he=new Map;et(R);function et(u){for(let m of u.references){if(!m.resolved||!k.has(m.resolved.scope))continue;let b=Oe(T,m.identifier),x=dt(b),I=Q(x,he);if(w&&x.type==="Identifier"&&(x.parent.type==="MemberExpression"||x.parent.type==="OptionalMemberExpression")&&!x.parent.computed&&x.parent.property.type==="Identifier"&&x.parent.property.name==="current"&&tn(m)&&Qe.set(I,{reference:m,dependencyNode:x}),x.parent.type==="TSTypeQuery"||x.parent.type==="TSTypeReference")continue;let C=m.resolved.defs[0];if(C!=null&&!(C.node!=null&&C.node.init===T.parent)&&C.type!=="TypeParameter")if(z.has(I))z.get(I).references.push(m);else{let O=m.resolved,P=Ze(O)||en(O);z.set(I,{isStable:P,references:[m]})}}for(let m of u.childScopes)et(m)}Qe.forEach(({reference:u,dependencyNode:m},b)=>{let x=u.resolved.references,I=!1;for(let C=0;C<x.length;C++){let{identifier:O}=x[C],{parent:P}=O;if(P!=null&&P.type==="MemberExpression"&&!P.computed&&P.property.type==="Identifier"&&P.property.name==="current"&&P.parent.type==="AssignmentExpression"&&P.parent.left===P){I=!0;break}}I||r({node:m.parent.property,message:`The ref value '${b}.current' will likely have changed by the time this effect cleanup function runs. If this ref points to a node rendered by React, copy '${b}.current' to a variable inside the effect, and use that variable in the cleanup function.`})});let Te=new Set;function nn(u,m){Te.has(m)||(Te.add(m),r({node:u,message:`Assignments to the '${m}' variable from inside React Hook ${n(v)} will be lost after each render. To preserve the value over time, store it in a useRef Hook and keep the mutable value in the '.current' property. Otherwise, you can move this variable directly inside ${n(v)}.`}))}let ce=new Set;if(z.forEach(({isStable:u,references:m},b)=>{u&&ce.add(b),m.forEach(x=>{x.writeExpr&&nn(x.writeExpr,b)})}),Te.size>0)return;if(!N){let u=null;if(z.forEach(({isStable:m,references:b},x)=>{u||b.forEach(I=>{if(u)return;let C=I.identifier;if(!s.has(C))return;let P=I.from;for(;P.type!=="function";)P=P.upper;P.block===T&&(u=x)})}),u){let{suggestedDependencies:m}=ke({dependencies:z,declaredDependencies:[],stableDependencies:ce,externalDependencies:new Set,isEffect:!0});r({node:v,message:`React Hook ${g} contains a call to '${u}'. Without a list of dependencies, this can lead to an infinite chain of updates. To fix this, pass [`+m.join(", ")+`] as a second argument to the ${g} Hook.`,suggest:[{desc:`Add dependencies array: [${m.join(", ")}]`,fix(b){return b.insertTextAfter(T,`, [${m.join(", ")}]`)}}]})}return}let oe=[],ae=new Set;N.type!=="ArrayExpression"?r({node:N,message:`React Hook ${n(v)} 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.`}):N.elements.forEach(u=>{if(u===null)return;if(u.type==="SpreadElement"){r({node:u,message:`React Hook ${n(v)} has a spread element in its dependency array. This means we can't statically verify whether you've passed the correct dependencies.`});return}h.has(u)&&r({node:u,message:`Functions returned from \`useEffectEvent\` must not be included in the dependency array. Remove \`${n(u)}\` from the list.`,suggest:[{desc:`Remove the dependency \`${n(u)}\``,fix(I){return I.removeRange(u.range)}}]});let m;try{m=Q(u,he)}catch(I){if(/Unsupported node type/.test(I.message)){u.type==="Literal"?z.has(u.value)?r({node:u,message:`The ${u.raw} literal is not a valid dependency because it never changes. Did you mean to include ${u.value} in the array instead?`}):r({node:u,message:`The ${u.raw} literal is not a valid dependency because it never changes. You can safely remove it.`}):r({node:u,message:`React Hook ${n(v)} has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked.`});return}else throw I}let b=u;for(;b.type==="MemberExpression"||b.type==="OptionalMemberExpression"||b.type==="ChainExpression";)b=b.object||b.expression.object;let x=!D.through.some(I=>I.identifier===b);oe.push({key:m,node:u}),x||ae.add(m)});let{suggestedDependencies:rn,unnecessaryDependencies:pe,missingDependencies:ee,duplicateDependencies:tt}=ke({dependencies:z,declaredDependencies:oe,stableDependencies:ce,externalDependencies:ae,isEffect:w}),ue=rn;if(tt.size+ee.size+pe.size===0){if(t)return;vn({declaredDependencies:oe,declaredDependenciesNode:N,componentScope:D,scope:R}).forEach(({construction:m,isUsedOutsideOfHook:b,depType:x})=>{let I=x==="function"?"useCallback":"useMemo",C=x==="function"?"definition":"initialization",O=`wrap the ${C} of '${m.name.name}' in its own ${I}() Hook.`,P=b?`To fix this, ${O}`:`Move it inside the ${g} callback. Alternatively, ${O}`,B=x==="conditional"||x==="logical expression"?"could make":"makes",Z=`The '${m.name.name}' ${x} ${B} the dependencies of ${g} Hook (at line ${N.loc.start.line}) change on every render. ${P}`,nt;b&&m.type==="Variable"&&x==="function"&&(nt=[{desc:`Wrap the ${C} of '${m.name.name}' in its own ${I}() Hook.`,fix(rt){let[on,an]=I==="useMemo"?["useMemo(() => { return ","; })"]:["useCallback(",")"];return[rt.insertTextBefore(m.node.init,on),rt.insertTextAfter(m.node.init,an)]}}]),r({node:m.node,message:Z,suggest:nt})});return}!w&&ee.size>0&&(ue=ke({dependencies:z,declaredDependencies:[],stableDependencies:ce,externalDependencies:ae,isEffect:w}).suggestedDependencies);function sn(){if(oe.length===0)return!0;let u=oe.map(b=>b.key),m=u.slice().sort();return u.join(",")===m.join(",")}sn()&&ue.sort();function Se(u){let m=u.split("."),b="";for(let x=0;x<m.length;x++){if(x!==0){let I=m.slice(0,x+1).join("."),C=he.get(I)===!0;b+=C?"?.":"."}b+=m[x]}return b}function Ee(u,m,b,x){return u.size===0?null:(u.size>1?"":m+" ")+b+" "+(u.size>1?"dependencies":"dependency")+": "+An(Array.from(u).sort().map(I=>"'"+Se(I)+"'"))+`. Either ${x} ${u.size>1?"them":"it"} or remove the dependency array.`}let K="";if(pe.size>0){let u=null;if(Array.from(pe.keys()).forEach(m=>{u===null&&m.endsWith(".current")&&(u=m)}),u!==null)K=` Mutable values like '${u}' aren't valid dependencies because mutating them doesn't re-render the component.`;else if(ae.size>0){let m=Array.from(ae)[0];R.set.has(m)||(K=` Outer scope values like '${m}' aren't valid dependencies because mutating them doesn't re-render the component.`)}}if(!K&&ee.has("props")){let u=z.get("props");if(u==null)return;let m=u.references;if(!Array.isArray(m))return;let b=!0;for(let x=0;x<m.length;x++){let I=m[x],C=Oe(D.block,I.identifier);if(!C){b=!1;break}let O=C.parent;if(O==null){b=!1;break}if(O.type!=="MemberExpression"&&O.type!=="OptionalMemberExpression"){b=!1;break}}b&&(K=` 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 ${n(v)}.`)}if(!K&&ee.size>0){let u=null;ee.forEach(m=>{if(u)return;let b=D.set.get(m),x=z.get(m);if(x.references[0].resolved!==b)return;let I=b.defs[0];if(I==null||I.name==null||I.type!=="Parameter")return;let C=!1,O;for(let P=0;P<x.references.length;P++)if(O=x.references[P].identifier,O!=null&&O.parent!=null&&(O.parent.type==="CallExpression"||O.parent.type==="OptionalCallExpression")&&O.parent.callee===O){C=!0;break}C&&(u=m)}),u!==null&&(K=` If '${u}' changes too often, find the parent component that defines it and wrap that definition in useCallback.`)}if(!K&&ee.size>0){let u=null;if(ee.forEach(m=>{if(u!==null)return;let x=z.get(m).references,I,C;for(let O=0;O<x.length;O++){for(I=x[O].identifier,C=I.parent;C!=null&&C!==D.block;){if(C.type==="CallExpression"){let P=s.get(C.callee);if(P!=null){if(P.name===m)u={missingDep:m,setter:C.callee.name,form:"updater"};else if(i.has(I))u={missingDep:m,setter:C.callee.name,form:"reducer"};else{let B=x[O].resolved;if(B!=null){let Z=B.defs[0];Z!=null&&Z.type==="Parameter"&&(u={missingDep:m,setter:C.callee.name,form:"inlineReducer"})}}break}}C=C.parent}if(u!==null)break}}),u!==null)switch(u.form){case"reducer":K=` You can also replace multiple useState variables with useReducer if '${u.setter}' needs the current value of '${u.missingDep}'.`;break;case"inlineReducer":K=` If '${u.setter}' needs the current value of '${u.missingDep}', you can also switch to useReducer instead of useState and read '${u.missingDep}' in the reducer.`;break;case"updater":K=` You can also do a functional update '${u.setter}(${u.missingDep.slice(0,1)} => ...)' if you only need '${u.missingDep}' in the '${u.setter}' call.`;break;default:throw new Error("Unknown case.")}}r({node:N,message:`React Hook ${n(v)} has `+(Ee(ee,"a","missing","include")||Ee(pe,"an","unnecessary","exclude")||Ee(tt,"a","duplicate","omit"))+K,suggest:[{desc:`Update the dependencies array to be: [${ue.map(Se).join(", ")}]`,fix(u){return u.replaceText(N,`[${ue.map(Se).join(", ")}]`)}}]})}function E(T){let N=kn(T.callee,p);if(N===-1)return;let v=T.arguments[N],g=T.callee,w=yt(g).name,R=T.arguments[N+1],k=/Effect($|[^a-z])/g.test(w);if(!v){r({node:g,message:`React Hook ${w} requires an effect callback. Did you forget to pass a callback to the hook?`});return}if(!(t&&!k)){if(!R&&!k){(w==="useMemo"||w==="useCallback")&&r({node:g,message:`React Hook ${w} does nothing when called with only one argument. Did you forget to pass an array of dependencies?`});return}switch(v.type){case"FunctionExpression":case"ArrowFunctionExpression":d(v,R,g,w,k);return;case"Identifier":if(!R||R.elements&&R.elements.some(U=>U&&U.type==="Identifier"&&U.name===v.name))return;let D=o(T).set.get(v.name);if(D==null||D.defs==null)return;let A=D.defs[0];if(!A||!A.node||A.type!=="Variable"&&A.type!=="FunctionName")break;switch(A.node.type){case"FunctionDeclaration":d(A.node,R,g,w,k);return;case"VariableDeclarator":let U=A.node.init;if(!U)break;switch(U.type){case"ArrowFunctionExpression":case"FunctionExpression":d(U,R,g,w,k);return}break}break;default:r({node:g,message:`React Hook ${w} received a function whose dependencies are unknown. Pass an inline function instead.`});return}r({node:g,message:`React Hook ${w} has a missing dependency: '${v.name}'. Either include it or remove the dependency array.`,suggest:[{desc:`Update the dependencies array to be: [${v.name}]`,fix(D){return D.replaceText(R,`[${v.name}]`)}}]})}}if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let T of e.sourceCode.getAllComments())if(Rn.test(T.value))return t=!0,{CallExpression:N=>E(N,!0)}}return{CallExpression:T=>E(T)}}};function ke({dependencies:e,declaredDependencies:t,stableDependencies:n,externalDependencies:o,isEffect:l}){let f=p();function p(){return{isUsed:!1,isSatisfiedRecursively:!1,isSubtreeUsed:!1,children:new Map}}e.forEach((d,E)=>{let T=r(f,E);T.isUsed=!0,a(f,E,N=>{N.isSubtreeUsed=!0})}),t.forEach(({key:d})=>{let E=r(f,d);E.isSatisfiedRecursively=!0}),n.forEach(d=>{let E=r(f,d);E.isSatisfiedRecursively=!0});function r(d,E){let T=E.split("."),N=d;for(let v of T){let g=N.children.get(v);g||(g=p(),N.children.set(v,g)),N=g}return N}function a(d,E,T){let N=E.split("."),v=d;for(let g of N){let w=v.children.get(g);if(!w)return;T(w),v=w}}let s=new Set,i=new Set;c(f,s,i,d=>d);function c(d,E,T,N){d.children.forEach((v,g)=>{let w=N(g);if(v.isSatisfiedRecursively){v.isSubtreeUsed&&T.add(w);return}if(v.isUsed){E.add(w);return}c(v,E,T,R=>w+"."+R)})}let y=[],h=new Set,S=new Set;return t.forEach(({key:d})=>{i.has(d)?y.indexOf(d)===-1?y.push(d):S.add(d):h.add(d)}),s.forEach(d=>{y.push(d)}),{suggestedDependencies:y,unnecessaryDependencies:h,duplicateDependencies:S,missingDependencies:s}}function te(e){switch(e.type){case"ObjectExpression":return"object";case"ArrayExpression":return"array";case"ArrowFunctionExpression":case"FunctionExpression":return"function";case"ClassExpression":return"class";case"ConditionalExpression":return te(e.consequent)!=null||te(e.alternate)!=null?"conditional":null;case"LogicalExpression":return te(e.left)!=null||te(e.right)!=null?"logical expression":null;case"JSXFragment":return"JSX fragment";case"JSXElement":return"JSX element";case"AssignmentExpression":return te(e.right)!=null?"assignment expression":null;case"NewExpression":return"object construction";case"Literal":return e.value instanceof RegExp?"regular expression":null;case"TypeCastExpression":return te(e.expression);case"TSAsExpression":return te(e.expression)}return null}function vn({declaredDependencies:e,declaredDependenciesNode:t,componentScope:n,scope:o}){let l=e.map(({key:p})=>{let r=n.variables.find(s=>s.name===p);if(r==null)return null;let a=r.defs[0];if(a==null)return null;if(a.type==="Variable"&&a.node.type==="VariableDeclarator"&&a.node.id.type==="Identifier"&&a.node.init!=null){let s=te(a.node.init);if(s!=null)return[r,s]}return a.type==="FunctionName"&&a.node.type==="FunctionDeclaration"?[r,"function"]:a.type==="ClassName"&&a.node.type==="ClassDeclaration"?[r,"class"]:null}).filter(Boolean);function f(p){let r=!1;for(let a=0;a<p.references.length;a++){let s=p.references[a];if(s.writeExpr){if(r)return!0;r=!0;continue}let i=s.from;for(;i!==o&&i!=null;)i=i.upper;if(i!==o&&!gt(t,s.identifier))return!0}return!1}return l.map(([p,r])=>({construction:p.defs[0],depType:r,isUsedOutsideOfHook:f(p)}))}function dt(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)?dt(e.parent):e.type==="MemberExpression"&&e.parent&&e.parent.type==="AssignmentExpression"&&e.parent.left===e?e.object:e}function Ae(e,t,n){t&&(e.optional?t.has(n)||t.set(n,!0):t.has(n)||t.set(n,!1))}function Q(e,t){if(e.type==="Identifier"||e.type==="JSXIdentifier"){let n=e.name;return t&&t.set(n,!1),n}else if(e.type==="MemberExpression"&&!e.computed){let n=Q(e.object,t),o=Q(e.property,null),l=`${n}.${o}`;return Ae(e,t,l),l}else if(e.type==="OptionalMemberExpression"&&!e.computed){let n=Q(e.object,t),o=Q(e.property,null),l=`${n}.${o}`;return Ae(e,t,l),l}else if(e.type==="ChainExpression"&&!e.computed){let n=e.expression;if(n.type==="CallExpression")throw new Error(`Unsupported node type: ${n.type}`);let o=Q(n.object,t),l=Q(n.property,null),f=`${o}.${l}`;return Ae(n,t,f),f}else throw new Error(`Unsupported node type: ${e.type}`)}function yt(e,t){return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.object.name==="React"&&e.property.type==="Identifier"&&!e.computed?e.property:e}function kn(e,t){let n=yt(e);if(n.type!=="Identifier")return-1;switch(n.name){case"useEffect":case"useLayoutEffect":case"useCallback":case"useMemo":return 0;case"useImperativeHandle":return 1;default:if(n===e&&t&&t.additionalHooks){let o;try{o=Q(n,null)}catch(l){if(/Unsupported node type/.test(l.message))return 0;throw l}return t.additionalHooks.test(o)?0:-1}else return-1}}function Oe(e,t){let n=[e],o=null;for(;n.length;){if(o=n.shift(),On(o,t))return o;if(gt(o,t))for(let[l,f]of Object.entries(o))l!=="parent"&&(ft(f)?(f.parent=o,n.push(f)):Array.isArray(f)&&f.forEach(p=>{ft(p)&&(p.parent=o,n.push(p))}))}return null}function An(e){let t="";for(let n=0;n<e.length;n++)t+=e[n],n===0&&e.length===2?t+=" and ":n===e.length-2&&e.length>2?t+=", and ":n<e.length-1&&(t+=", ");return t}function ft(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function On(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 gt(e,t){return e.range[0]<=t.range[0]&&e.range[1]>=t.range[1]}function Pn(e){return!1}import{AST_NODE_TYPES as de,ESLintUtils as Tt}from"@typescript-eslint/utils";import Y from"typescript";var Nn=Tt.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),ht="improved-no-unnecessary-condition",Dn=$({}),_n=["string","number","bigint","boolean","symbol","undefined","object","function","never"],Ln=new Set(_n),Pe={name:ht,rule:Nn({name:ht,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:[Dn]},defaultOptions:[{}],create(e){let t=Tt.getParserServices(e,!0),n=t.program?.getTypeChecker();if(!n||!t.program)throw new Error("TypeScript services or program not available");function o(r){return r.type===de.UnaryExpression&&r.operator==="typeof"}function l(r){return r.flags&Y.TypeFlags.Any||r.flags&Y.TypeFlags.Unknown?null:r.flags&Y.TypeFlags.StringLike?["string"]:r.flags&Y.TypeFlags.NumberLike?["number"]:r.flags&Y.TypeFlags.BigIntLike?["bigint"]:r.flags&Y.TypeFlags.BooleanLike?["boolean"]:r.flags&Y.TypeFlags.ESSymbolLike?["symbol"]:r.flags&Y.TypeFlags.Undefined||r.flags&Y.TypeFlags.Void?["undefined"]:r.flags&Y.TypeFlags.Null?["object"]:r.getCallSignatures().length>0?["function"]:r.flags&Y.TypeFlags.Object?r.getProperties().length===0?["string","number","bigint","boolean","symbol","object","function"]:["object"]:r.flags&Y.TypeFlags.NonPrimitive?["object"]:r.flags&Y.TypeFlags.Never?["never"]:null}function f(r){if(!n)return null;let a=t.esTreeNodeToTSNodeMap.get(r),s=n.getTypeAtLocation(a.expression);if(s.flags&Y.TypeFlags.Any||s.flags&Y.TypeFlags.Unknown)return null;let i=[];if(s.isUnion()){for(let y of s.types){let h=l(y);if(h)i.push(...h);else return null}return i}let c=l(s);return c?(i.push(...c),i):null}function p(r){if(!(r.operator==="==="||r.operator==="!=="))return;let s=null,i=null;if(o(r.left)?(s=r.left,i=r.right.type===de.Literal&&typeof r.right.value=="string"?r.right.value:null):o(r.right)&&(s=r.right,i=r.left.type===de.Literal&&typeof r.left.value=="string"?r.left.value:null),!s||!i||!$n(i,Ln))return;let c=f(s);if(!c)return;let y=r.operator==="!==",h=c.includes(i);c.length===1?h&&!y?e.report({node:r,messageId:"unnecessaryTypeofCondition",data:{name:re(s,e),type:i}}):!h&&y?e.report({node:r,messageId:"unnecessaryTypeofCondition",data:{name:re(s,e),type:Array.from(c)[0]}}):!h&&!y?e.report({node:r,messageId:"alwaysFalseTypeofCondition",data:{name:re(s,e),actualType:me(c),conditionType:i}}):h&&y&&e.report({node:r,messageId:"alwaysFalseTypeofCondition",data:{name:re(s,e),actualType:me(c),conditionType:i}}):!h&&!y?e.report({node:r,messageId:"alwaysFalseTypeofCondition",data:{name:re(s,e),actualType:me(c),conditionType:i}}):!h&&y&&e.report({node:r,messageId:"unnecessaryTypeofCondition",data:{name:re(s,e),type:me(c)}})}return{BinaryExpression:p}}})};function me(e){return Array.from(new Set(e)).join(" | ")||"never"}function re(e,t){let n=e.argument;return n.type===de.Identifier?n.name:t.sourceCode.getText(n)}function $n(e,t){return t.has(e)}import{AST_NODE_TYPES as Fn,ESLintUtils as jn}from"@typescript-eslint/utils";var Mn=jn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),St="no-call-with-explicit-generics",Un=$({functions:H(L())}),Wn=Mn({name:St,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:[Un]},defaultOptions:[{functions:[]}],create(e,[t]){let n=new Set(t.functions);return{CallExpression(o){let{callee:l}=o;l.type===Fn.Identifier&&n.has(l.name)&&o.typeArguments&&e.report({node:o,messageId:"noExplicitGenerics",data:{functionName:l.name}})}}}}),Ne={name:St,rule:Wn};import{AST_NODE_TYPES as ye,ESLintUtils as Hn}from"@typescript-eslint/utils";var Vn=Hn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Et="no-call-with-inferred-generics",Yn=Vn({name:Et,meta:{type:"problem",docs:{description:"Disable calling configured functions with infered generics"},messages:{missingGenericDeclaration:"Function '{{ functionName }}' should be called with at least {{ minGenerics }} generic(s) (ex: `fn<Generic>()`) defined",anyUsedInGenerics:"Function '{{ functionName }}' should not be called with 'any' in generics"},schema:[{type:"object",properties:{functions:{type:"array",items:{type:"object",properties:{name:{type:"string"},minGenerics:{type:"number"},allowAny:{type:"boolean"},disallowTypes:{type:"array",items:{type:"string"}}},required:["name"]}},anyAliases:{type:"array",items:{type:"string"}}},required:["functions"]}]},defaultOptions:[{functions:[]}],create(e,[t]){let n=new Map(t.functions.map(o=>[o.name,o]));return{CallExpression(o){let{callee:l}=o;if(l.type!==ye.Identifier)return;let f=n.get(l.name);if(!f)return;let{minGenerics:p=1,allowAny:r,disallowTypes:a=t.disallowTypes}=f;(o.typeArguments?.params.length||0)<(p||0)&&e.report({node:o,messageId:"missingGenericDeclaration",data:{functionName:l.name,minGenerics:p||0}}),!(r&&!a)&&o.typeArguments?.params?.some(i=>!r&&i.type===ye.TSAnyKeyword||a&&i.type===ye.TSTypeReference&&i.typeName.type===ye.Identifier&&a.includes(i.typeName.name))&&e.report({node:o,messageId:"anyUsedInGenerics",data:{functionName:l.name}})}}}}),De={name:Et,rule:Yn};import{ESLintUtils as zn,TSESTree as bt}from"@typescript-eslint/utils";var Bn=zn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),xt="no-commented-out-code",qn=["function ","class ","interface ","type ","enum ","namespace ","import ","export ","const ","let ","var ","return "],Kn=[") {","return;","if (","else {","for (","switch (","/>","</","},",": {"," } = ","={",/\w=("|')/,");"],Xn=Bn({name:xt,meta:{type:"problem",docs:{description:"Disallow commented code"},messages:{commentedOutCode:"Commented code is not allowed. Detected pattern: `{{ wrongPattern }}` Use a comment starting with `INFO:` if you want to keep this code commented out."},schema:[]},defaultOptions:[],create(e){function t(n){if(n.startsWith("/"))return!1;let o=n.trimStart();if(n.startsWith("*")||o.startsWith("INFO:")||o.startsWith("TODO:")||o.startsWith("DOCS:")||o.startsWith("FIX:")||o.startsWith("eslint-disable")||n.includes("@deprecated")||n.includes("@example"))return!1;for(let l of qn)if(o.startsWith(l))return{wrongPattern:l};for(let l of Kn)if(typeof l=="string"){if(n.includes(l))return{wrongPattern:l}}else if(l.test(n))return{wrongPattern:`regex(${l.toString()})`};return!1}return{Program(){let o=e.sourceCode.getAllComments();for(let l of o)if(l.type===bt.AST_TOKEN_TYPES.Line||l.type===bt.AST_TOKEN_TYPES.Block){let f=t(l.value);f&&e.report({node:l,messageId:"commentedOutCode",data:{wrongPattern:f.wrongPattern}})}}}}}),_e={name:xt,rule:Xn};import{ESLintUtils as Jn,TSESTree as Gn}from"@typescript-eslint/utils";var Zn=Jn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ct="no-default-export",Qn=Zn({name:Ct,meta:{type:"problem",docs:{description:"Disallow default exports"},schema:[],messages:{noDefaultExport:"Default exports are not allowed, use named exports instead."}},defaultOptions:[],create(e){return{ExportDefaultDeclaration(t){e.report({node:t,messageId:"noDefaultExport"})},ExportNamedDeclaration(t){for(let n of t.specifiers)n.exported.type===Gn.AST_NODE_TYPES.Identifier&&n.exported.name==="default"&&e.report({node:t,messageId:"noDefaultExport"})}}}}),Le={name:Ct,rule:Qn};import{ESLintUtils as er}from"@typescript-eslint/utils";var tr=er.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),It="no-leaked-text-in-jsx",nr=[",",";","[","]","(",")"],rr=tr({name:It,meta:{type:"problem",docs:{description:"Prevents leaking of text in JSX that should be wrapped in an expression container"},messages:{leakedTextInJSX:'Text "{{ text }}" should be wrapped in a JSX expression container.'},schema:[],fixable:"code"},defaultOptions:[],create(e){return{JSXText(t){let n=t.value.trim();if(!n)return;let o="";nr.includes(n)?o=n:n.includes("&&")?o="&&":n.includes("||")?o="||":n.endsWith("? (")&&(o="? ("),o&&e.report({node:t,messageId:"leakedTextInJSX",data:{text:o}})}}}}),$e={name:It,rule:rr};import{AST_NODE_TYPES as ie,ESLintUtils as ir}from"@typescript-eslint/utils";var sr=ir.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Rt="no-non-camel-case-functions",or=/^[a-z][a-zA-Z0-9]*$/;function wt(e){return e.typeName.type===ie.TSQualifiedName&&e.typeName.left.type===ie.Identifier&&e.typeName.left.name==="JSX"&&e.typeName.right.type===ie.Identifier&&e.typeName.right.name==="Element"}var ar=sr({name:Rt,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&&!or.test(t.id.name)){let n=t.returnType?.typeAnnotation;if(n&&(n.type===ie.TSTypeReference?wt(n):n.type===ie.TSUnionType&&n.types.some(l=>l.type===ie.TSTypeReference&&wt(l))))return;e.report({node:t.id,messageId:"nonCamelCaseFunction",data:{functionName:t.id.name}})}}}}}),Fe={name:Rt,rule:ar};import{ESLintUtils as lr,TSESTree as M}from"@typescript-eslint/utils";function se(e,t,n=1/0){if(n!==0&&e.parent)return e.type===t?e:se(e.parent,t,n===1/0?n:n-1)}function*je(e){yield e,e.parent&&(yield*je(e.parent))}var cr=lr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),vt="no-optional-root-props",pr=cr({name:vt,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(l){return l?l.parent?.type===M.AST_NODE_TYPES.ExportNamedDeclaration||l.parent?.type===M.AST_NODE_TYPES.ExportDefaultDeclaration:!1}function n(l){let p=e.sourceCode.getDeclaredVariables(l)[0];if(!p||p.references.length!==1)return!1;let r=p.references[0];if(!r)return!1;for(let a of je(r.identifier)){if("returnType"in a||a.type===M.AST_NODE_TYPES.ExportNamedDeclaration)return!1;let s=a.parent;if(!s)return!1;if(s.type===M.AST_NODE_TYPES.TSTypeParameterInstantiation&&s.parent.type===M.AST_NODE_TYPES.TSTypeReference&&s.parent.typeName.type===M.AST_NODE_TYPES.Identifier&&s.parent.typeName.name==="FC"){let c=se(s.parent.parent,M.AST_NODE_TYPES.VariableDeclaration,4);if(c)return!(t(c)||e.sourceCode.getScope(c).references.some(h=>t(h.identifier.parent.parent)))}if(a.type===M.AST_NODE_TYPES.AssignmentPattern)return!1;if(s.type===M.AST_NODE_TYPES.ArrowFunctionExpression){let i=se(s,M.AST_NODE_TYPES.VariableDeclaration);return i&&t(i)||i&&e.sourceCode.getScope(i).references.some(y=>y.identifier.parent.parent?.parent?.type===M.AST_NODE_TYPES.ExportNamedDeclaration)?!1:s.params.some(c=>c===a)}if(s.type===M.AST_NODE_TYPES.FunctionDeclaration)return t(s)||e.sourceCode.getScope(s).upper?.references.some(c=>t(c.identifier.parent.parent))?!1:s.params.some(c=>c===a)}return!1}function o(l){l.key.type!==M.AST_NODE_TYPES.Identifier||!l.optional||e.report({node:l.key,messageId:"optionalNotAllowed",data:{propertyName:l.key.name},suggest:[{messageId:"suggestion",fix:f=>{let p=se(l,M.AST_NODE_TYPES.TSPropertySignature);if(!p)return null;let r=e.sourceCode.getText(p);return f.replaceText(p,r.replace("?:",": undefined |"))}}]})}return{TSTypeAliasDeclaration(l){if(l.typeAnnotation.type===M.AST_NODE_TYPES.TSTypeLiteral&&!(t(l)||!n(l)))for(let f of l.typeAnnotation.members)f.type===M.AST_NODE_TYPES.TSPropertySignature&&o(f)},TSInterfaceDeclaration(l){if(!(t(l)||!n(l)))for(let f of l.body.body)f.type===M.AST_NODE_TYPES.TSPropertySignature&&o(f)},TSTypeReference(l){if(l.typeName.type!==M.AST_NODE_TYPES.Identifier||l.typeName.name!=="FC"||!l.typeArguments?.params[0])return;let f=l.typeArguments.params[0];if(f.type!==M.AST_NODE_TYPES.TSTypeLiteral)return;let p=se(l.parent,M.AST_NODE_TYPES.VariableDeclaration,4);if(!p||t(p)||e.sourceCode.getScope(p).references.some(i=>i.identifier.parent.parent?.parent?.type===M.AST_NODE_TYPES.ExportNamedDeclaration))return;let a=p.declarations[0].id.type===M.AST_NODE_TYPES.Identifier?p.declarations[0].id:null,s=e.sourceCode.getScope(p).variables.find(i=>i.name===a?.name)?.references.filter(i=>i.identifier!==a);if(!(s&&s.length>1))for(let i of f.members)i.type===M.AST_NODE_TYPES.TSPropertySignature&&o(i)}}}}),Me={name:vt,rule:pr};import{ESLintUtils as ur}from"@typescript-eslint/utils";import Ue from"node:path";var fr=ur.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),kt="no-relative-imports",mr=$({find:L(),replacement:L()}),dr=$({aliases:H(mr),rootDir:_(L()),allowNotFoundAliases:_(ne()),_dev_simulateFileName:_(L())}),yr=fr({name:kt,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:[dr]},defaultOptions:[{aliases:[],rootDir:void 0}],create(e,[t]){let n=t._dev_simulateFileName??e.filename;function o(p){return p.startsWith(".")||p.startsWith("..")}function l(p,r){let a=Ue.dirname(r);return Ue.resolve(a,p)}function f(p){let r=t.rootDir??process.cwd(),a=Ue.relative(r,p);if(a.startsWith("."))return null;a.startsWith("/")||(a=`/${a}`);for(let{find:s,replacement:i}of t.aliases)if(a.startsWith(i)){let c=a.replace(i,s);return{alias:s,newPath:c}}return null}return{ImportDeclaration(p){let r=p.source.value;if(!o(r))return;let a=l(r,n),s=f(a);!s&&t.allowNotFoundAliases||e.report({node:p,messageId:s?"noRelativeImportsWithAlias":"noRelativeImports",data:{alias:s?.alias},fix:s?i=>i.replaceText(p.source,`'${s.newPath}'`):void 0})}}}}),We={name:kt,rule:yr};import{AST_NODE_TYPES as le,ESLintUtils as Ot}from"@typescript-eslint/utils";import*as He from"typescript";var gr=Ot.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),At="no-unnecessary-casting",hr=$({additionalCastFunctions:_(H($({name:L(),expectedType:fe(["string","number"])})))}),Ve={name:At,rule:gr({name:At,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:[hr],fixable:"code"},defaultOptions:[{}],create(e){let n=e.options[0].additionalCastFunctions||[],o=[{name:"Number",expectedType:"number"},{name:"String",expectedType:"string"},...n],l=Ot.getParserServices(e,!0),f=l.program?.getTypeChecker();if(!f||!l.program)throw new Error("TypeScript services or program not available");function p(i,c){switch(i.type){case le.Literal:return c==="number"?typeof i.value=="number":typeof i.value=="string";case le.TemplateLiteral:return c==="string";case le.UnaryExpression:return c==="number"?i.operator==="+"||i.operator==="-"||i.operator==="~":!1;default:return!1}}function r(i,c){return c==="number"?!!(i.flags&He.TypeFlags.NumberLike):!!(i.flags&He.TypeFlags.StringLike)}function a(i,c){return y=>y.replaceText(i,e.sourceCode.getText(c))}function s(i){if(!f||i.arguments.length!==1)return;let c=i.arguments[0];if(!c||c.type===le.SpreadElement)return;let{callee:y}=i;if(y.type!==le.Identifier)return;let h=y.name,S=o.find(E=>E.name===h);if(!S)return;if(p(c,S.expectedType)||r(f.getTypeAtLocation(l.esTreeNodeToTSNodeMap.get(c)),S.expectedType)){let E,T;h==="Number"?E="unnecessaryNumberCasting":h==="String"?E="unnecessaryStringCasting":(E="unnecessaryCustomCasting",T={name:S.name,type:S.expectedType}),e.report({node:i,messageId:E,...T?{data:T}:{},fix:a(i,c)})}}return{CallExpression:s}}})};import{AST_NODE_TYPES as F,ESLintUtils as Tr}from"@typescript-eslint/utils";var Sr=Tr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function Pt(e){let t=[];for(let n of e.members)n.type===F.TSPropertySignature&&n.key.type===F.Identifier&&t.push([n.key.name,n]);return t}function Nt(e,...t){for(let n of t)e.set(...n);return e}var Er=$({forceCheckOnFCPropTypesWithName:_(H(L()))}),Dt="no-unused-type-props-in-args",Ye=null,br=Sr({name:Dt,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:[Er],fixable:"code"},defaultOptions:[{}],create(e,[t]){let{forceCheckOnFCPropTypesWithName:n}=t;n&&!Ye&&(Ye=n.map(r=>new RegExp(r)));function o(r,a,s,i,c=!0){let y=s.name,h=e.sourceCode.getScope(a).references.find(E=>E.identifier.name===y)?.resolved,S=r&&Ye?.some(E=>E.test(y));if(!h||!S&&h.references.filter(E=>E.isTypeReference).length>1)return;let d=h?.defs[0]?.node;if(!(c&&d?.parent?.type===F.ExportNamedDeclaration)){if(d?.type===F.TSTypeAliasDeclaration){l(r,a,i,d.typeAnnotation,!0);return}if(d?.type===F.TSInterfaceDeclaration){l(r,a,i,d.body,!0);return}}}function l(r,a,s,i,c){if(i.type===F.TSInterfaceBody){for(let y of i.body)y.type===F.TSPropertySignature&&y.key.type===F.Identifier&&s.set(y.key.name,y);return}if(i.type===F.TSTypeLiteral){Nt(s,...Pt(i));return}if(i.type===F.TSIntersectionType){for(let y of i.types)l(r,a,s,y,!0);return}c||i.type===F.TSTypeReference&&i.typeName.type===F.Identifier&&o(r,a,i.typeName,s)}function f(r,a,s){for(let i of s)if(i.type==="ObjectPattern"&&i.typeAnnotation){let c=new Map;if(l(r,a,c,i.typeAnnotation.typeAnnotation,!1),c.size===0)continue;p(i,c)}else i.type===F.AssignmentPattern&&i.left.type===F.ObjectPattern&&f(r,a,[i.left])}function p(r,a){let s=[];if(r.properties.at(-1)?.type===F.RestElement)return;for(let h of r.properties)h.type===F.Property&&h.key.type===F.Identifier&&s.push(h.key.name);let c=[],y=[];for(let[h,S]of a)s.includes(h)||(y.push(h),c.push({node:S,messageId:"unusedObjectTypeProperty",data:{propertyName:h}}));for(let[h,S]of c.entries())e.report({...S,fix:h===c.length-1?d=>{let E=r.properties.at(-1),T=y.join(", ");return E?E?.type===F.RestElement?null:d.insertTextAfter(E,`, ${T}`):d.insertTextBeforeRange([r.range[0]+1,r.range[1]],`${T}`)}:void 0})}return{VariableDeclaration(r){let a=r.declarations[0];if(!a)return;let s=new Map,i=a.id.type===F.Identifier&&a.id.typeAnnotation?.typeAnnotation.type===F.TSTypeReference&&a.id.typeAnnotation.typeAnnotation.typeName.type===F.Identifier&&a.id.typeAnnotation.typeAnnotation.typeName.name==="FC"&&a.id.typeAnnotation.typeAnnotation.typeArguments?.params[0];if(i){if(i.type===F.TSTypeReference&&i.typeName.type===F.Identifier)o(!0,r,i.typeName,s,!1);else if(i.type===F.TSTypeLiteral)Nt(s,...Pt(i));else if(i.type===F.TSIntersectionType)for(let c of i.types)c.type===F.TSTypeReference&&c.typeName.type===F.Identifier?o(!0,r,c.typeName,s,!1):l(!0,r,s,c,!0);if(s.size!==0&&a.init?.type===F.ArrowFunctionExpression){let c=a.init.params[0];if(!c){e.report({node:a.init,messageId:"missingComponentParam"});return}c.type===F.ObjectPattern&&p(c,s)}}},FunctionDeclaration:function(r){f(!1,r,r.params)},ArrowFunctionExpression(r){f(!1,r,r.params)}}}}),ze={name:Dt,rule:br};import{AST_NODE_TYPES as Be,ESLintUtils as xr}from"@typescript-eslint/utils";var Cr=xr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Lt="prefer-named-functions",_t=new Map,Ir=Cr({name:Lt,meta:{hasSuggestions:!0,type:"suggestion",docs:{description:"Prevent using arrow functions when a named function can be used instead"},schema:[{type:"object",properties:{ignoreRegex:{type:"string"},disallowArrowFnWithImplicitReturns:{type:"boolean"}}}],messages:{suggestion:"Convert to named function",default:'Function {{functionName}} should be defined as a named function "function {{functionName}} () {}" instead of an arrow function',withIgnoreRegex:'Function {{functionName}} should be defined as a named function "function {{functionName}} () {}", if not possible to use `function` you can also use a name that matches the rule ignore regex'}},defaultOptions:[{}],create(e,[t]){let n=null;if(t.ignoreRegex){let o=_t.get(t.ignoreRegex);o?n=o:(n=new RegExp(t.ignoreRegex),_t.set(t.ignoreRegex,n))}return{VariableDeclarator(o){if(o.init&&o.init.type===Be.ArrowFunctionExpression&&o.id.type===Be.Identifier){let l=o.id.name;if(o.id.typeAnnotation||n&&n.test(l)||!t.disallowArrowFnWithImplicitReturns&&o.init.body.type!==Be.BlockStatement)return;let f=o.parent,p=o.init.params,r=o.init.body,a=o.init;e.report({node:o.id,messageId:n?"withIgnoreRegex":"default",data:{functionName:l,ignoreRegex:t.ignoreRegex},suggest:[{messageId:"suggestion",fix:s=>s.replaceText(f,`${a.async?"async ":""}function ${l}(${p.map(i=>e.sourceCode.getText(i)).join(", ")||""}) ${e.sourceCode.getText(r)}`)}]})}}}}}),qe={name:Lt,rule:Ir};import{AST_NODE_TYPES as W,AST_TOKEN_TYPES as $t,ESLintUtils as wr}from"@typescript-eslint/utils";var Rr=wr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),jt="prefer-single-line-if",vr=$({maxLineLength:_(J()),maxNonSimpleConditionLength:_(J())}),kr=Rr({name:jt,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:[vr]},defaultOptions:[{}],create(e,[t]){let n=e.sourceCode;return{IfStatement(o){if(o.consequent.type!==W.BlockStatement||o.loc.start.line===o.loc.end.line||n.getCommentsInside(o.consequent).length>0||o.alternate||o.consequent.body.length!==1)return;let f=o.consequent.body[0];if(f.type===W.ReturnStatement){if(!Ut(f))return}else if(!(f.type===W.ContinueStatement||f.type===W.BreakStatement))return;if(o.test.type===W.LogicalExpression||o.test.type===W.ConditionalExpression)return;let p;if(t.maxNonSimpleConditionLength){let c=Ft(o.test);if(!c&&o.test.type===W.UnaryExpression&&o.test.operator==="!"){let y=o.test.argument;Ft(y)&&(c=!0)}if(c&&(p=n.getText(o.test),p.length>t.maxNonSimpleConditionLength))return}p||(p=n.getText(o.test));let r=n.getText(f);if(p.includes(`
14
- `))return;let a=n.getTokenAfter(o);if(a&&a.type===$t.Punctuator&&a.value==="}"){let c=n.getTokenAfter(a);if(c&&c.type===$t.Keyword&&(c.value==="else"||c.value==="catch"))return}let s=Ar(n,o),i=`if (${p}) ${r}`;t.maxLineLength&&i.length+s.length>t.maxLineLength||e.report({node:o,messageId:"noSingleLineCurly",fix:c=>c.replaceText(o,i)})}}}});function Ft(e){return e.type===W.CallExpression||e.type===W.BinaryExpression||e.type===W.MemberExpression&&Mt(e)}function Mt(e){return e.object.type===W.MemberExpression?Mt(e.object):e.object.type!==W.Identifier}function Ar(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}function Ut(e){if(!e.argument)return!0;let t=e.argument;return t.type===W.ArrayExpression&&t.elements.length===0||t.type===W.ObjectExpression&&t.properties.length===0||t.type===W.Literal||t.type===W.Identifier||t.type===W.TemplateLiteral||t.type===W.TaggedTemplateExpression?!0:t.type===W.CallExpression?t.arguments.length===0:t.type===W.UnaryExpression?Ut(t):!1}var Ke={name:jt,rule:kr};import{AST_NODE_TYPES as q,ESLintUtils as Or}from"@typescript-eslint/utils";var Pr=Or.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Wt="react-compiler-migration",Nr=$({disallowHooks:_(H($({name:L(),replacement:L()}))),disallowMethods:_(H($({name:L(),replacement:_(L()),requireTrueProp:_(L())})))}),Dr=/eslint +react-compiler\/react-compiler: +\["error/;function _r(e){return e.type===q.Identifier?e.name.startsWith("use"):e.type===q.MemberExpression&&e.property.type===q.Identifier?e.property.name.startsWith("use"):!1}var Lr=Pr({name:Wt,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:[Nr]},defaultOptions:[{}],create(e,[t]){let n=!1;for(let o of e.sourceCode.getAllComments())if(Dr.test(o.value)){n=!0;break}return n?{CallExpression(o){if(t.disallowHooks?.length){let l=null,f=null;if(o.callee.type===q.Identifier?(l=o.callee.name,f=o.callee):o.callee.type===q.MemberExpression&&o.callee.property.type===q.Identifier&&(l=o.callee.property.name,f=o.callee.property),l){let p=t.disallowHooks.find(r=>r.name===l);p&&f&&e.report({node:o,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:p.name,replacement:p.replacement},suggest:[{messageId:"replace",data:{replacement:p.replacement},fix:r=>r.replaceText(f,p.replacement)}]})}}if(t.disallowMethods?.length&&_r(o.callee)){for(let l of o.arguments)if(l.type===q.ObjectExpression){for(let f of l.properties)if(f.type===q.Property&&f.key.type===q.Identifier){let p=f.key.name,r=t.disallowMethods.find(a=>a.name===p);if(r){if(r.requireTrueProp){let a=r.requireTrueProp,s=!1;for(let i of l.properties)if(i.type===q.Property&&i.key.type===q.Identifier&&i.key.name===a&&i.value.type===q.Literal&&i.value.value===!0){s=!0;break}if(!s){e.report({node:f,messageId:"disallowedMethodWithMissingRequireTrueProp",data:{method:r.name,requireTrueProp:a}});continue}}r.replacement&&e.report({node:f,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:r.name,replacement:r.replacement},suggest:[{messageId:"replace",data:{replacement:r.replacement},fix:a=>a.replaceText(f.key,r.replacement)}]})}}}}}}:{}}}),Xe={name:Wt,rule:Lr};import{ESLintUtils as $r,TSESTree as Fr}from"@typescript-eslint/utils";var jr=$r.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ht="require-description",Mr=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,Ur=/^eslint-disable-(next-)?line$/u,Wr=jr({name:Ht,meta:{type:"problem",docs:{description:"Require descriptions for eslint directives."},messages:{missingDescription:"Unexpected undescribed directive comment. Include descriptions to explain why the comment is necessary."},schema:[{type:"object",properties:{ignore:{type:"array",items:{type:"string",enum:["eslint","eslint-disable","eslint-disable-line","eslint-disable-next-line","eslint-enable","eslint-env","exported","global","globals"]},additionalItems:!1,uniqueItems:!0}},additionalProperties:!1}]},defaultOptions:[{ignore:[]}],create(e,[t]){let n=e.sourceCode,o=new Set(t.ignore||[]);return{Program(){for(let l of n.getAllComments()){let f=Hr(l);f!=null&&(o.has(f.kind)||f.description||e.report({loc:Yr(l.loc),messageId:"missingDescription"}))}}}}}),Vt={name:Ht,rule:Wr};function Hr(e){let{text:t,description:n}=Vr(e.value);if(!t)return null;let o=Mr.exec(t);if(!o)return null;let l=o[1];if(!l)return null;let f=Ur.test(l);if(e.type===Fr.AST_TOKEN_TYPES.Line&&!f||f&&e.loc.start.line!==e.loc.end.line)return null;let p=t.slice(o.index+l.length);return{kind:l,value:p.trim(),description:n}}function Vr(e){let t=e.split(/\s-{2,}\s/u);return{text:t[0]?.trim(),description:t.length>1?t[1]?.trim()??null:null}}function Yr(e){return{start:{line:e.start.line,column:-1},end:e.end}}function Bt(e){return/^use[A-Z0-9]/.test(e)}function ge(e){return e.type==="Identifier"?Bt(e.name):e.type==="MemberExpression"&&!e.computed&&ge(e.property)?e.object.type==="Identifier":!1}function qt(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function Kt(e,t){return e.name===t||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===t}function Xt(e){return!!(e.parent&&e.parent.callee&&Kt(e.parent.callee,"forwardRef"))}function Jt(e){return!!(e.parent&&e.parent.callee&&Kt(e.parent.callee,"memo"))}function Je(e){for(;e;){let t=Zt(e);if(t&&(qt(t)||ge(t))||Xt(e)||Jt(e))return!0;e=e.parent}return!1}function Yt(e){return!1}function Ge(e){return!1}var zr=/eslint +react-compiler\/react-compiler: +\["error/,Gt={meta:{type:"problem",docs:{description:"enforces the Rules of Hooks",recommended:!0,url:"https://reactjs.org/docs/hooks-rules.html"},schema:[{type:"object",ignoreIfReactCompilerIsEnabled:!1,properties:{ignoreIfReactCompilerIsEnabled:{type:"boolean"}}}]},create(e){if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let a of e.sourceCode.getAllComments())if(zr.test(a.value))return{CallExpression(s){let i=null;s.callee.name==="useMemo"?i="useMemo":s.callee.name==="useCallback"&&(i="useCallback"),i&&e.report({node:s,message:`"${i}" is not necessary when using React Compiler.`})}}}let t=typeof e.getSource=="function"?a=>t(a):a=>e.sourceCode.getText(a),n=typeof e.getScope=="function"?()=>n():a=>e.sourceCode.getScope(a),o=null,l=[],f=[],p=new WeakSet;function r(a){for(let s of a.references){let i=s.identifier.parent;if(i.type==="VariableDeclarator"&&i.init&&i.init.type==="CallExpression"&&i.init.callee&&Yt(i.init.callee))for(let c of s.resolved.references)c!==s&&p.add(c.identifier)}}return{onCodePathSegmentStart:a=>f.push(a),onCodePathSegmentEnd:()=>f.pop(),onCodePathStart:()=>l.push(new Map),onCodePathEnd(a,s){let i=l.pop();if(i.size===0)return;let c=new Set;function y(g,w){let{cache:R}=y,k=R.get(g.id),D=new Set(w);if(D.has(g.id)){let A=[...D],U=A.slice(A.indexOf(g.id)+1);for(let X of U)c.add(X);return BigInt("0")}if(D.add(g.id),k!==void 0)return k;if(a.thrownSegments.includes(g))k=BigInt("0");else if(g.prevSegments.length===0)k=BigInt("1");else{k=BigInt("0");for(let A of g.prevSegments)k+=y(A,D)}return g.reachable&&k===BigInt("0")?R.delete(g.id):R.set(g.id,k),k}function h(g,w){let{cache:R}=h,k=R.get(g.id),D=new Set(w);if(D.has(g.id)){let A=Array.from(D),U=A.slice(A.indexOf(g.id)+1);for(let X of U)c.add(X);return BigInt("0")}if(D.add(g.id),k!==void 0)return k;if(a.thrownSegments.includes(g))k=BigInt("0");else if(g.nextSegments.length===0)k=BigInt("1");else{k=BigInt("0");for(let A of g.nextSegments)k+=h(A,D)}return R.set(g.id,k),k}function S(g){let{cache:w}=S,R=w.get(g.id);if(R===null)return 1/0;if(R!==void 0)return R;if(w.set(g.id,null),g.prevSegments.length===0)R=1;else{R=1/0;for(let k of g.prevSegments){let D=S(k);D<R&&(R=D)}R+=1}return w.set(g.id,R),R}y.cache=new Map,h.cache=new Map,S.cache=new Map;let d=h(a.initialSegment),E=Zt(s),T=Je(s),N=E?qt(E)||ge(E):Xt(s)||Jt(s),v=1/0;for(let g of a.finalSegments){if(!g.reachable)continue;let w=S(g);w<v&&(v=w)}for(let[g,w]of i){if(!g.reachable)continue;let R=g.nextSegments.length===0?v<=S(g):v<S(g),k=y(g)*h(g),D=c.has(g.id);for(let A of w)if(D&&!Ge(A)&&e.report({node:A,message:`React Hook "${t(A)}" 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.`}),N){if(s.async&&e.report({node:A,message:`React Hook "${t(A)}" cannot be called in an async function.`}),!D&&k!==d&&!Ge(A)){let X=`React Hook "${t(A)}" is called conditionally. React Hooks must be called in the exact same order in every component render.`+(R?" Did you accidentally call a React Hook after an early return?":"");e.report({node:A,message:X})}}else if(s.parent&&(s.parent.type==="MethodDefinition"||s.parent.type==="ClassProperty")&&s.parent.value===s){let U=`React Hook "${t(A)}" 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:A,message:U})}else if(E){let U=`React Hook "${t(A)}" 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:A,message:U})}else if(s.type==="Program"){let U=`React Hook "${t(A)}" 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:A,message:U})}else if(T&&!Ge(A)){if(s.parent.type==="CallExpression"&&s.parent.callee.type==="Identifier"&&s.parent.callee.name==="useCallback"){let X=s.parent;if(X.parent.type==="VariableDeclarator"&&Bt(X.parent.id.name))return}let U=`React Hook "${t(A)}" 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:A,message:U})}}},CallExpression(a){if(ge(a.callee)){let s=zt(l),i=zt(f),c=s.get(i);c||(c=[],s.set(i,c)),c.push(a.callee)}a.callee.type==="Identifier"&&(a.callee.name==="useEffect"||Yt(a.callee))&&a.arguments.length>0&&(o=a)},Identifier(a){o==null&&p.has(a)&&a.parent.type!=="CallExpression"&&e.report({node:a,message:`\`${t(a)}\` is a function created with React Hook "useEffectEvent", and can only be called from the same component. They cannot be assigned to variables or passed down.`})},"CallExpression:exit"(a){a===o&&(o=null)},FunctionDeclaration(a){Je(a)&&r(n(a))},ArrowFunctionExpression(a){Je(a)&&r(n(a))}}}};function Zt(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 zt(e){return e[e.length-1]}var Qt={[ze.name]:ze.rule,[_e.name]:_e.rule,[De.name]:De.rule,"rules-of-hooks":Gt,"exhaustive-deps":mt,"require-description":Vt.rule,[Le.name]:Le.rule,[Fe.name]:Fe.rule,[qe.name]:qe.rule,[we.name]:we.rule,[Ne.name]:Ne.rule,[We.name]:We.rule,[Ke.name]:Ke.rule,[Me.name]:Me.rule,[$e.name]:$e.rule,[ve.name]:ve.rule,[Xe.name]:Xe.rule,[Ce.name]:Ce.rule,[Pe.name]:Pe.rule,[Ve.name]:Ve.rule};var Ts={rules:Qt};export{Ts as extendedLintPlugin};
14
+ Learn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching`});let R=a.acquire(y),k=new Set,D=null;{let u=R.upper;for(;u&&(k.add(u),u.type!=="function");)u=u.upper;if(!u)return;D=u}let A=Array.isArray;function U(u){if(!A(u.defs))return!1;let m=u.defs[0];if(m==null||m.node.type!=="VariableDeclarator")return!1;let E=m.node.init;if(E==null)return!1;for(;E.type==="TSAsExpression";)E=E.expression;let x=m.node.parent;if(x==null&&(Ae(D.block,m.node.id),x=m.node.parent,x==null))return!1;if(x.kind==="const"&&E.type==="Literal"&&(typeof E.value=="string"||typeof E.value=="number"||E.value===null))return!0;if(E.type!=="CallExpression")return!1;let I=E.callee;if(I.type==="MemberExpression"&&I.object.name==="React"&&I.property!=null&&!I.computed&&(I=I.property),I.type!=="Identifier")return!1;let C=m.node.id,{name:O}=I;if(O==="useRef"&&C.type==="Identifier")return!0;if(Pn(I)&&C.type==="Identifier"){for(let P of u.references)P!==C&&T.add(P.identifier);return!0}else if(O==="useState"||O==="useReducer"){if(C.type==="ArrayPattern"&&C.elements.length===2&&A(u.identifiers)){if(C.elements[1]===u.identifiers[0]){if(O==="useState"){let P=u.references,B=0;for(let Z=0;Z<P.length;Z++){if(P[Z].isWrite()&&B++,B>1)return!1;s.set(P[Z].identifier,C.elements[0])}}return!0}else if(C.elements[0]===u.identifiers[0]){if(O==="useState"){let P=u.references;for(let B=0;B<P.length;B++)i.add(P[B].identifier)}return!1}}}else if(O==="useTransition"&&C.type==="ArrayPattern"&&C.elements.length===2&&Array.isArray(u.identifiers)&&C.elements[1]===u.identifiers[0])return!0;return!1}function X(u){if(!A(u.defs))return!1;let m=u.defs[0];if(m==null||m.node==null||m.node.id==null)return!1;let E=m.node,x=D.childScopes,I=null,C;for(C=0;C<x.length;C++){let O=x[C],P=O.block;if(E.type==="FunctionDeclaration"&&P===E||E.type==="VariableDeclarator"&&P.parent===E){I=O;break}}if(I==null)return!1;for(C=0;C<I.through.length;C++){let O=I.through[C];if(O.resolved!=null&&k.has(O.resolved.scope)&&!Ge(O.resolved))return!1}return!0}let Ge=S(U,c),Qt=S(X,g),Ze=new Map;function en(u){let m=u.from,E=!1;for(;m.block!==y;)m.type==="function"&&(E=m.block.parent!=null&&m.block.parent.type==="ReturnStatement"),m=m.upper;return E}let z=new Map,he=new Map;Qe(R);function Qe(u){for(let m of u.references){if(!m.resolved||!k.has(m.resolved.scope))continue;let E=Ae(y,m.identifier),x=mt(E),I=Q(x,he);if(w&&x.type==="Identifier"&&(x.parent.type==="MemberExpression"||x.parent.type==="OptionalMemberExpression")&&!x.parent.computed&&x.parent.property.type==="Identifier"&&x.parent.property.name==="current"&&en(m)&&Ze.set(I,{reference:m,dependencyNode:x}),x.parent.type==="TSTypeQuery"||x.parent.type==="TSTypeReference")continue;let C=m.resolved.defs[0];if(C!=null&&!(C.node!=null&&C.node.init===y.parent)&&C.type!=="TypeParameter")if(z.has(I))z.get(I).references.push(m);else{let O=m.resolved,P=Ge(O)||Qt(O);z.set(I,{isStable:P,references:[m]})}}for(let m of u.childScopes)Qe(m)}Ze.forEach(({reference:u,dependencyNode:m},E)=>{let x=u.resolved.references,I=!1;for(let C=0;C<x.length;C++){let{identifier:O}=x[C],{parent:P}=O;if(P!=null&&P.type==="MemberExpression"&&!P.computed&&P.property.type==="Identifier"&&P.property.name==="current"&&P.parent.type==="AssignmentExpression"&&P.parent.left===P){I=!0;break}}I||n({node:m.parent.property,message:`The ref value '${E}.current' will likely have changed by the time this effect cleanup function runs. If this ref points to a node rendered by React, copy '${E}.current' to a variable inside the effect, and use that variable in the cleanup function.`})});let Te=new Set;function tn(u,m){Te.has(m)||(Te.add(m),n({node:u,message:`Assignments to the '${m}' variable from inside React Hook ${r(v)} 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(v)}.`}))}let ce=new Set;if(z.forEach(({isStable:u,references:m},E)=>{u&&ce.add(E),m.forEach(x=>{x.writeExpr&&tn(x.writeExpr,E)})}),Te.size>0)return;if(!N){let u=null;if(z.forEach(({isStable:m,references:E},x)=>{u||E.forEach(I=>{if(u)return;let C=I.identifier;if(!s.has(C))return;let P=I.from;for(;P.type!=="function";)P=P.upper;P.block===y&&(u=x)})}),u){let{suggestedDependencies:m}=ve({dependencies:z,declaredDependencies:[],stableDependencies:ce,externalDependencies:new Set,isEffect:!0});n({node:v,message:`React Hook ${h} contains a call to '${u}'. Without a list of dependencies, this can lead to an infinite chain of updates. To fix this, pass [`+m.join(", ")+`] as a second argument to the ${h} Hook.`,suggest:[{desc:`Add dependencies array: [${m.join(", ")}]`,fix(E){return E.insertTextAfter(y,`, [${m.join(", ")}]`)}}]})}return}let oe=[],ae=new Set;N.type!=="ArrayExpression"?n({node:N,message:`React Hook ${r(v)} 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.`}):N.elements.forEach(u=>{if(u===null)return;if(u.type==="SpreadElement"){n({node:u,message:`React Hook ${r(v)} 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(u)&&n({node:u,message:`Functions returned from \`useEffectEvent\` must not be included in the dependency array. Remove \`${r(u)}\` from the list.`,suggest:[{desc:`Remove the dependency \`${r(u)}\``,fix(I){return I.removeRange(u.range)}}]});let m;try{m=Q(u,he)}catch(I){if(/Unsupported node type/.test(I.message)){u.type==="Literal"?z.has(u.value)?n({node:u,message:`The ${u.raw} literal is not a valid dependency because it never changes. Did you mean to include ${u.value} in the array instead?`}):n({node:u,message:`The ${u.raw} literal is not a valid dependency because it never changes. You can safely remove it.`}):n({node:u,message:`React Hook ${r(v)} has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked.`});return}else throw I}let E=u;for(;E.type==="MemberExpression"||E.type==="OptionalMemberExpression"||E.type==="ChainExpression";)E=E.object||E.expression.object;let x=!D.through.some(I=>I.identifier===E);oe.push({key:m,node:u}),x||ae.add(m)});let{suggestedDependencies:nn,unnecessaryDependencies:pe,missingDependencies:ee,duplicateDependencies:et}=ve({dependencies:z,declaredDependencies:oe,stableDependencies:ce,externalDependencies:ae,isEffect:w}),ue=nn;if(et.size+ee.size+pe.size===0){if(t)return;vn({declaredDependencies:oe,declaredDependenciesNode:N,componentScope:D,scope:R}).forEach(({construction:m,isUsedOutsideOfHook:E,depType:x})=>{let I=x==="function"?"useCallback":"useMemo",C=x==="function"?"definition":"initialization",O=`wrap the ${C} of '${m.name.name}' in its own ${I}() Hook.`,P=E?`To fix this, ${O}`:`Move it inside the ${h} callback. Alternatively, ${O}`,B=x==="conditional"||x==="logical expression"?"could make":"makes",Z=`The '${m.name.name}' ${x} ${B} the dependencies of ${h} Hook (at line ${N.loc.start.line}) change on every render. ${P}`,tt;E&&m.type==="Variable"&&x==="function"&&(tt=[{desc:`Wrap the ${C} of '${m.name.name}' in its own ${I}() Hook.`,fix(nt){let[sn,on]=I==="useMemo"?["useMemo(() => { return ","; })"]:["useCallback(",")"];return[nt.insertTextBefore(m.node.init,sn),nt.insertTextAfter(m.node.init,on)]}}]),n({node:m.node,message:Z,suggest:tt})});return}!w&&ee.size>0&&(ue=ve({dependencies:z,declaredDependencies:[],stableDependencies:ce,externalDependencies:ae,isEffect:w}).suggestedDependencies);function rn(){if(oe.length===0)return!0;let u=oe.map(E=>E.key),m=u.slice().sort();return u.join(",")===m.join(",")}rn()&&ue.sort();function Se(u){let m=u.split("."),E="";for(let x=0;x<m.length;x++){if(x!==0){let I=m.slice(0,x+1).join("."),C=he.get(I)===!0;E+=C?"?.":"."}E+=m[x]}return E}function Ee(u,m,E,x){return u.size===0?null:(u.size>1?"":m+" ")+E+" "+(u.size>1?"dependencies":"dependency")+": "+An(Array.from(u).sort().map(I=>"'"+Se(I)+"'"))+`. Either ${x} ${u.size>1?"them":"it"} or remove the dependency array.`}let K="";if(pe.size>0){let u=null;if(Array.from(pe.keys()).forEach(m=>{u===null&&m.endsWith(".current")&&(u=m)}),u!==null)K=` Mutable values like '${u}' aren't valid dependencies because mutating them doesn't re-render the component.`;else if(ae.size>0){let m=Array.from(ae)[0];R.set.has(m)||(K=` Outer scope values like '${m}' aren't valid dependencies because mutating them doesn't re-render the component.`)}}if(!K&&ee.has("props")){let u=z.get("props");if(u==null)return;let m=u.references;if(!Array.isArray(m))return;let E=!0;for(let x=0;x<m.length;x++){let I=m[x],C=Ae(D.block,I.identifier);if(!C){E=!1;break}let O=C.parent;if(O==null){E=!1;break}if(O.type!=="MemberExpression"&&O.type!=="OptionalMemberExpression"){E=!1;break}}E&&(K=` However, 'props' will change when *any* prop changes, so the preferred fix is to destructure the 'props' object outside of the ${h} call and refer to those specific props inside ${r(v)}.`)}if(!K&&ee.size>0){let u=null;ee.forEach(m=>{if(u)return;let E=D.set.get(m),x=z.get(m);if(x.references[0].resolved!==E)return;let I=E.defs[0];if(I==null||I.name==null||I.type!=="Parameter")return;let C=!1,O;for(let P=0;P<x.references.length;P++)if(O=x.references[P].identifier,O!=null&&O.parent!=null&&(O.parent.type==="CallExpression"||O.parent.type==="OptionalCallExpression")&&O.parent.callee===O){C=!0;break}C&&(u=m)}),u!==null&&(K=` If '${u}' changes too often, find the parent component that defines it and wrap that definition in useCallback.`)}if(!K&&ee.size>0){let u=null;if(ee.forEach(m=>{if(u!==null)return;let x=z.get(m).references,I,C;for(let O=0;O<x.length;O++){for(I=x[O].identifier,C=I.parent;C!=null&&C!==D.block;){if(C.type==="CallExpression"){let P=s.get(C.callee);if(P!=null){if(P.name===m)u={missingDep:m,setter:C.callee.name,form:"updater"};else if(i.has(I))u={missingDep:m,setter:C.callee.name,form:"reducer"};else{let B=x[O].resolved;if(B!=null){let Z=B.defs[0];Z!=null&&Z.type==="Parameter"&&(u={missingDep:m,setter:C.callee.name,form:"inlineReducer"})}}break}}C=C.parent}if(u!==null)break}}),u!==null)switch(u.form){case"reducer":K=` You can also replace multiple useState variables with useReducer if '${u.setter}' needs the current value of '${u.missingDep}'.`;break;case"inlineReducer":K=` If '${u.setter}' needs the current value of '${u.missingDep}', you can also switch to useReducer instead of useState and read '${u.missingDep}' in the reducer.`;break;case"updater":K=` You can also do a functional update '${u.setter}(${u.missingDep.slice(0,1)} => ...)' if you only need '${u.missingDep}' in the '${u.setter}' call.`;break;default:throw new Error("Unknown case.")}}n({node:N,message:`React Hook ${r(v)} has `+(Ee(ee,"a","missing","include")||Ee(pe,"an","unnecessary","exclude")||Ee(et,"a","duplicate","omit"))+K,suggest:[{desc:`Update the dependencies array to be: [${ue.map(Se).join(", ")}]`,fix(u){return u.replaceText(N,`[${ue.map(Se).join(", ")}]`)}}]})}function b(y){let N=kn(y.callee,p);if(N===-1)return;let v=y.arguments[N],h=y.callee,w=dt(h).name,R=y.arguments[N+1],k=/Effect($|[^a-z])/g.test(w);if(!v){n({node:h,message:`React Hook ${w} requires an effect callback. Did you forget to pass a callback to the hook?`});return}if(!(t&&!k)){if(!R&&!k){(w==="useMemo"||w==="useCallback")&&n({node:h,message:`React Hook ${w} does nothing when called with only one argument. Did you forget to pass an array of dependencies?`});return}switch(v.type){case"FunctionExpression":case"ArrowFunctionExpression":d(v,R,h,w,k);return;case"Identifier":if(!R||R.elements&&R.elements.some(U=>U&&U.type==="Identifier"&&U.name===v.name))return;let D=o(y).set.get(v.name);if(D==null||D.defs==null)return;let A=D.defs[0];if(!A||!A.node||A.type!=="Variable"&&A.type!=="FunctionName")break;switch(A.node.type){case"FunctionDeclaration":d(A.node,R,h,w,k);return;case"VariableDeclarator":let U=A.node.init;if(!U)break;switch(U.type){case"ArrowFunctionExpression":case"FunctionExpression":d(U,R,h,w,k);return}break}break;default:n({node:h,message:`React Hook ${w} received a function whose dependencies are unknown. Pass an inline function instead.`});return}n({node:h,message:`React Hook ${w} has a missing dependency: '${v.name}'. Either include it or remove the dependency array.`,suggest:[{desc:`Update the dependencies array to be: [${v.name}]`,fix(D){return D.replaceText(R,`[${v.name}]`)}}]})}}if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let y of e.sourceCode.getAllComments())if(Rn.test(y.value))return t=!0,{CallExpression:N=>b(N,!0)}}return{CallExpression:y=>b(y)}}};function ve({dependencies:e,declaredDependencies:t,stableDependencies:r,externalDependencies:o,isEffect:l}){let f=p();function p(){return{isUsed:!1,isSatisfiedRecursively:!1,isSubtreeUsed:!1,children:new Map}}e.forEach((d,b)=>{let y=n(f,b);y.isUsed=!0,a(f,b,N=>{N.isSubtreeUsed=!0})}),t.forEach(({key:d})=>{let b=n(f,d);b.isSatisfiedRecursively=!0}),r.forEach(d=>{let b=n(f,d);b.isSatisfiedRecursively=!0});function n(d,b){let y=b.split("."),N=d;for(let v of y){let h=N.children.get(v);h||(h=p(),N.children.set(v,h)),N=h}return N}function a(d,b,y){let N=b.split("."),v=d;for(let h of N){let w=v.children.get(h);if(!w)return;y(w),v=w}}let s=new Set,i=new Set;c(f,s,i,d=>d);function c(d,b,y,N){d.children.forEach((v,h)=>{let w=N(h);if(v.isSatisfiedRecursively){v.isSubtreeUsed&&y.add(w);return}if(v.isUsed){b.add(w);return}c(v,b,y,R=>w+"."+R)})}let g=[],T=new Set,S=new Set;return t.forEach(({key:d})=>{i.has(d)?g.indexOf(d)===-1?g.push(d):S.add(d):T.add(d)}),s.forEach(d=>{g.push(d)}),{suggestedDependencies:g,unnecessaryDependencies:T,duplicateDependencies:S,missingDependencies:s}}function te(e){switch(e.type){case"ObjectExpression":return"object";case"ArrayExpression":return"array";case"ArrowFunctionExpression":case"FunctionExpression":return"function";case"ClassExpression":return"class";case"ConditionalExpression":return te(e.consequent)!=null||te(e.alternate)!=null?"conditional":null;case"LogicalExpression":return te(e.left)!=null||te(e.right)!=null?"logical expression":null;case"JSXFragment":return"JSX fragment";case"JSXElement":return"JSX element";case"AssignmentExpression":return te(e.right)!=null?"assignment expression":null;case"NewExpression":return"object construction";case"Literal":return e.value instanceof RegExp?"regular expression":null;case"TypeCastExpression":return te(e.expression);case"TSAsExpression":return te(e.expression)}return null}function vn({declaredDependencies:e,declaredDependenciesNode:t,componentScope:r,scope:o}){let l=e.map(({key:p})=>{let n=r.variables.find(s=>s.name===p);if(n==null)return null;let a=n.defs[0];if(a==null)return null;if(a.type==="Variable"&&a.node.type==="VariableDeclarator"&&a.node.id.type==="Identifier"&&a.node.init!=null){let s=te(a.node.init);if(s!=null)return[n,s]}return a.type==="FunctionName"&&a.node.type==="FunctionDeclaration"?[n,"function"]:a.type==="ClassName"&&a.node.type==="ClassDeclaration"?[n,"class"]:null}).filter(Boolean);function f(p){let n=!1;for(let a=0;a<p.references.length;a++){let s=p.references[a];if(s.writeExpr){if(n)return!0;n=!0;continue}let i=s.from;for(;i!==o&&i!=null;)i=i.upper;if(i!==o&&!yt(t,s.identifier))return!0}return!1}return l.map(([p,n])=>({construction:p.defs[0],depType:n,isUsedOutsideOfHook:f(p)}))}function mt(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)?mt(e.parent):e.type==="MemberExpression"&&e.parent&&e.parent.type==="AssignmentExpression"&&e.parent.left===e?e.object:e}function ke(e,t,r){t&&(e.optional?t.has(r)||t.set(r,!0):t.has(r)||t.set(r,!1))}function Q(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=Q(e.object,t),o=Q(e.property,null),l=`${r}.${o}`;return ke(e,t,l),l}else if(e.type==="OptionalMemberExpression"&&!e.computed){let r=Q(e.object,t),o=Q(e.property,null),l=`${r}.${o}`;return ke(e,t,l),l}else if(e.type==="ChainExpression"&&!e.computed){let r=e.expression;if(r.type==="CallExpression")throw new Error(`Unsupported node type: ${r.type}`);let o=Q(r.object,t),l=Q(r.property,null),f=`${o}.${l}`;return ke(r,t,f),f}else throw new Error(`Unsupported node type: ${e.type}`)}function dt(e,t){return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.object.name==="React"&&e.property.type==="Identifier"&&!e.computed?e.property:e}function kn(e,t){let r=dt(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 o;try{o=Q(r,null)}catch(l){if(/Unsupported node type/.test(l.message))return 0;throw l}return t.additionalHooks.test(o)?0:-1}else return-1}}function Ae(e,t){let r=[e],o=null;for(;r.length;){if(o=r.shift(),On(o,t))return o;if(yt(o,t))for(let[l,f]of Object.entries(o))l!=="parent"&&(ut(f)?(f.parent=o,r.push(f)):Array.isArray(f)&&f.forEach(p=>{ut(p)&&(p.parent=o,r.push(p))}))}return null}function An(e){let t="";for(let r=0;r<e.length;r++)t+=e[r],r===0&&e.length===2?t+=" and ":r===e.length-2&&e.length>2?t+=", and ":r<e.length-1&&(t+=", ");return t}function ut(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function On(e,t){return(e.type==="Identifier"||e.type==="JSXIdentifier")&&e.type===t.type&&e.name===t.name&&e.range[0]===t.range[0]&&e.range[1]===t.range[1]}function yt(e,t){return e.range[0]<=t.range[0]&&e.range[1]>=t.range[1]}function Pn(e){return!1}import{AST_NODE_TYPES as de,ESLintUtils as ht}from"@typescript-eslint/utils";import Y from"typescript";var Nn=ht.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),gt="improved-no-unnecessary-condition",Dn=$({}),_n=["string","number","bigint","boolean","symbol","undefined","object","function","never"],Ln=new Set(_n),Oe={name:gt,rule:Nn({name:gt,meta:{type:"suggestion",docs:{description:"Extends checks of `no-unnecessary-condition` rule"},messages:{unnecessaryTypeofCondition:'This condition is unnecessary. The type of "{{name}}" is always "{{type}}".',alwaysFalseTypeofCondition:'This condition will always be false. The type of "{{name}}" is "{{actualType}}" so the condition has no overlap with "{{conditionType}}".'},schema:[Dn]},defaultOptions:[{}],create(e){let t=ht.getParserServices(e,!0),r=t.program?.getTypeChecker();if(!r||!t.program)throw new Error("TypeScript services or program not available");function o(n){return n.type===de.UnaryExpression&&n.operator==="typeof"}function l(n){return n.flags&Y.TypeFlags.Any||n.flags&Y.TypeFlags.Unknown?null:n.flags&Y.TypeFlags.StringLike?["string"]:n.flags&Y.TypeFlags.NumberLike?["number"]:n.flags&Y.TypeFlags.BigIntLike?["bigint"]:n.flags&Y.TypeFlags.BooleanLike?["boolean"]:n.flags&Y.TypeFlags.ESSymbolLike?["symbol"]:n.flags&Y.TypeFlags.Undefined||n.flags&Y.TypeFlags.Void?["undefined"]:n.flags&Y.TypeFlags.Null?["object"]:n.getCallSignatures().length>0?["function"]:n.flags&Y.TypeFlags.Object?n.getProperties().length===0?["string","number","bigint","boolean","symbol","object","function"]:["object"]:n.flags&Y.TypeFlags.NonPrimitive?["object"]:n.flags&Y.TypeFlags.Never?["never"]:null}function f(n){if(!r)return null;let a=t.esTreeNodeToTSNodeMap.get(n),s=r.getTypeAtLocation(a.expression);if(s.flags&Y.TypeFlags.Any||s.flags&Y.TypeFlags.Unknown)return null;let i=[];if(s.isUnion()){for(let g of s.types){let T=l(g);if(T)i.push(...T);else return null}return i}let c=l(s);return c?(i.push(...c),i):null}function p(n){if(!(n.operator==="==="||n.operator==="!=="))return;let s=null,i=null;if(o(n.left)?(s=n.left,i=n.right.type===de.Literal&&typeof n.right.value=="string"?n.right.value:null):o(n.right)&&(s=n.right,i=n.left.type===de.Literal&&typeof n.left.value=="string"?n.left.value:null),!s||!i||!$n(i,Ln))return;let c=f(s);if(!c)return;let g=n.operator==="!==",T=c.includes(i);c.length===1?T&&!g?e.report({node:n,messageId:"unnecessaryTypeofCondition",data:{name:re(s,e),type:i}}):!T&&g?e.report({node:n,messageId:"unnecessaryTypeofCondition",data:{name:re(s,e),type:Array.from(c)[0]}}):!T&&!g?e.report({node:n,messageId:"alwaysFalseTypeofCondition",data:{name:re(s,e),actualType:me(c),conditionType:i}}):T&&g&&e.report({node:n,messageId:"alwaysFalseTypeofCondition",data:{name:re(s,e),actualType:me(c),conditionType:i}}):!T&&!g?e.report({node:n,messageId:"alwaysFalseTypeofCondition",data:{name:re(s,e),actualType:me(c),conditionType:i}}):!T&&g&&e.report({node:n,messageId:"unnecessaryTypeofCondition",data:{name:re(s,e),type:me(c)}})}return{BinaryExpression:p}}})};function me(e){return Array.from(new Set(e)).join(" | ")||"never"}function re(e,t){let r=e.argument;return r.type===de.Identifier?r.name:t.sourceCode.getText(r)}function $n(e,t){return t.has(e)}import{AST_NODE_TYPES as Fn,ESLintUtils as jn}from"@typescript-eslint/utils";var Mn=jn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Tt="no-call-with-explicit-generics",Un=$({functions:H(L())}),Wn=Mn({name:Tt,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:[Un]},defaultOptions:[{functions:[]}],create(e,[t]){let r=new Set(t.functions);return{CallExpression(o){let{callee:l}=o;l.type===Fn.Identifier&&r.has(l.name)&&o.typeArguments&&e.report({node:o,messageId:"noExplicitGenerics",data:{functionName:l.name}})}}}}),Pe={name:Tt,rule:Wn};import{AST_NODE_TYPES as ye,ESLintUtils as Hn}from"@typescript-eslint/utils";var Vn=Hn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),St="no-call-with-inferred-generics",Yn=Vn({name:St,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(o=>[o.name,o]));return{CallExpression(o){let{callee:l}=o;if(l.type!==ye.Identifier)return;let f=r.get(l.name);if(!f)return;let{minGenerics:p=1,allowAny:n,disallowTypes:a=t.disallowTypes}=f;(o.typeArguments?.params.length||0)<(p||0)&&e.report({node:o,messageId:"missingGenericDeclaration",data:{functionName:l.name,minGenerics:p||0}}),!(n&&!a)&&o.typeArguments?.params?.some(i=>!n&&i.type===ye.TSAnyKeyword||a&&i.type===ye.TSTypeReference&&i.typeName.type===ye.Identifier&&a.includes(i.typeName.name))&&e.report({node:o,messageId:"anyUsedInGenerics",data:{functionName:l.name}})}}}}),Ne={name:St,rule:Yn};import{ESLintUtils as zn,TSESTree as Et}from"@typescript-eslint/utils";var Bn=zn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),bt="no-commented-out-code",qn=["function ","class ","interface ","type ","enum ","namespace ","import ","export ","const ","let ","var ","return "],Kn=[") {","return;","if (","else {","for (","switch (","/>","</","},",": {"," } = ","={",/\w=("|')/,");"],Xn=Bn({name:bt,meta:{type:"problem",docs:{description:"Disallow commented code"},messages:{commentedOutCode:"Commented code is not allowed. Detected pattern: `{{ wrongPattern }}` Use a comment starting with `INFO:` if you want to keep this code commented out."},schema:[]},defaultOptions:[],create(e){function t(r){if(r.startsWith("/"))return!1;let o=r.trimStart();if(r.startsWith("*")||o.startsWith("INFO:")||o.startsWith("TODO:")||o.startsWith("DOCS:")||o.startsWith("FIX:")||o.startsWith("eslint-disable")||r.includes("@deprecated")||r.includes("@example"))return!1;for(let l of qn)if(o.startsWith(l))return{wrongPattern:l};for(let l of Kn)if(typeof l=="string"){if(r.includes(l))return{wrongPattern:l}}else if(l.test(r))return{wrongPattern:`regex(${l.toString()})`};return!1}return{Program(){let o=e.sourceCode.getAllComments();for(let l of o)if(l.type===Et.AST_TOKEN_TYPES.Line||l.type===Et.AST_TOKEN_TYPES.Block){let f=t(l.value);f&&e.report({node:l,messageId:"commentedOutCode",data:{wrongPattern:f.wrongPattern}})}}}}}),De={name:bt,rule:Xn};import{ESLintUtils as Jn,TSESTree as Gn}from"@typescript-eslint/utils";var Zn=Jn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),xt="no-default-export",Qn=Zn({name:xt,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===Gn.AST_NODE_TYPES.Identifier&&r.exported.name==="default"&&e.report({node:t,messageId:"noDefaultExport"})}}}}),_e={name:xt,rule:Qn};import{ESLintUtils as er}from"@typescript-eslint/utils";var tr=er.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ct="no-leaked-text-in-jsx",nr=[",",";","[","]","(",")"],rr=tr({name:Ct,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 o="";nr.includes(r)?o=r:r.includes("&&")?o="&&":r.includes("||")?o="||":r.endsWith("? (")&&(o="? ("),o&&e.report({node:t,messageId:"leakedTextInJSX",data:{text:o}})}}}}),Le={name:Ct,rule:rr};import{AST_NODE_TYPES as ie,ESLintUtils as ir}from"@typescript-eslint/utils";var sr=ir.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),wt="no-non-camel-case-functions",or=/^[a-z][a-zA-Z0-9]*$/;function It(e){return e.typeName.type===ie.TSQualifiedName&&e.typeName.left.type===ie.Identifier&&e.typeName.left.name==="JSX"&&e.typeName.right.type===ie.Identifier&&e.typeName.right.name==="Element"}var ar=sr({name:wt,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&&!or.test(t.id.name)){let r=t.returnType?.typeAnnotation;if(r&&(r.type===ie.TSTypeReference?It(r):r.type===ie.TSUnionType&&r.types.some(l=>l.type===ie.TSTypeReference&&It(l))))return;e.report({node:t.id,messageId:"nonCamelCaseFunction",data:{functionName:t.id.name}})}}}}}),$e={name:wt,rule:ar};import{ESLintUtils as lr,TSESTree as M}from"@typescript-eslint/utils";function se(e,t,r=1/0){if(r!==0&&e.parent)return e.type===t?e:se(e.parent,t,r===1/0?r:r-1)}function*Fe(e){yield e,e.parent&&(yield*Fe(e.parent))}var cr=lr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Rt="no-optional-root-props",pr=cr({name:Rt,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(l){return l?l.parent?.type===M.AST_NODE_TYPES.ExportNamedDeclaration||l.parent?.type===M.AST_NODE_TYPES.ExportDefaultDeclaration:!1}function r(l){let p=e.sourceCode.getDeclaredVariables(l)[0];if(!p||p.references.length!==1)return!1;let n=p.references[0];if(!n)return!1;for(let a of Fe(n.identifier)){if("returnType"in a||a.type===M.AST_NODE_TYPES.ExportNamedDeclaration)return!1;let s=a.parent;if(!s)return!1;if(s.type===M.AST_NODE_TYPES.TSTypeParameterInstantiation&&s.parent.type===M.AST_NODE_TYPES.TSTypeReference&&s.parent.typeName.type===M.AST_NODE_TYPES.Identifier&&s.parent.typeName.name==="FC"){let c=se(s.parent.parent,M.AST_NODE_TYPES.VariableDeclaration,4);if(c)return!(t(c)||e.sourceCode.getScope(c).references.some(T=>t(T.identifier.parent.parent)))}if(a.type===M.AST_NODE_TYPES.AssignmentPattern)return!1;if(s.type===M.AST_NODE_TYPES.ArrowFunctionExpression){let i=se(s,M.AST_NODE_TYPES.VariableDeclaration);return i&&t(i)||i&&e.sourceCode.getScope(i).references.some(g=>g.identifier.parent.parent?.parent?.type===M.AST_NODE_TYPES.ExportNamedDeclaration)?!1:s.params.some(c=>c===a)}if(s.type===M.AST_NODE_TYPES.FunctionDeclaration)return t(s)||e.sourceCode.getScope(s).upper?.references.some(c=>t(c.identifier.parent.parent))?!1:s.params.some(c=>c===a)}return!1}function o(l){l.key.type!==M.AST_NODE_TYPES.Identifier||!l.optional||e.report({node:l.key,messageId:"optionalNotAllowed",data:{propertyName:l.key.name},suggest:[{messageId:"suggestion",fix:f=>{let p=se(l,M.AST_NODE_TYPES.TSPropertySignature);if(!p)return null;let n=e.sourceCode.getText(p);return f.replaceText(p,n.replace("?:",": undefined |"))}}]})}return{TSTypeAliasDeclaration(l){if(l.typeAnnotation.type===M.AST_NODE_TYPES.TSTypeLiteral&&!(t(l)||!r(l)))for(let f of l.typeAnnotation.members)f.type===M.AST_NODE_TYPES.TSPropertySignature&&o(f)},TSInterfaceDeclaration(l){if(!(t(l)||!r(l)))for(let f of l.body.body)f.type===M.AST_NODE_TYPES.TSPropertySignature&&o(f)},TSTypeReference(l){if(l.typeName.type!==M.AST_NODE_TYPES.Identifier||l.typeName.name!=="FC"||!l.typeArguments?.params[0])return;let f=l.typeArguments.params[0];if(f.type!==M.AST_NODE_TYPES.TSTypeLiteral)return;let p=se(l.parent,M.AST_NODE_TYPES.VariableDeclaration,4);if(!p||t(p)||e.sourceCode.getScope(p).references.some(i=>i.identifier.parent.parent?.parent?.type===M.AST_NODE_TYPES.ExportNamedDeclaration))return;let a=p.declarations[0].id.type===M.AST_NODE_TYPES.Identifier?p.declarations[0].id:null,s=e.sourceCode.getScope(p).variables.find(i=>i.name===a?.name)?.references.filter(i=>i.identifier!==a);if(!(s&&s.length>1))for(let i of f.members)i.type===M.AST_NODE_TYPES.TSPropertySignature&&o(i)}}}}),je={name:Rt,rule:pr};import{ESLintUtils as ur}from"@typescript-eslint/utils";import Me from"node:path";var fr=ur.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),vt="no-relative-imports",mr=$({find:L(),replacement:L()}),dr=$({aliases:H(mr),rootDir:_(L()),allowNotFoundAliases:_(ne()),_dev_simulateFileName:_(L())}),yr=fr({name:vt,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:[dr]},defaultOptions:[{aliases:[],rootDir:void 0}],create(e,[t]){let r=t._dev_simulateFileName??e.filename;function o(p){return p.startsWith(".")||p.startsWith("..")}function l(p,n){let a=Me.dirname(n);return Me.resolve(a,p)}function f(p){let n=t.rootDir??process.cwd(),a=Me.relative(n,p);if(a.startsWith("."))return null;a.startsWith("/")||(a=`/${a}`);for(let{find:s,replacement:i}of t.aliases)if(a.startsWith(i)){let c=a.replace(i,s);return{alias:s,newPath:c}}return null}return{ImportDeclaration(p){let n=p.source.value;if(!o(n))return;let a=l(n,r),s=f(a);!s&&t.allowNotFoundAliases||e.report({node:p,messageId:s?"noRelativeImportsWithAlias":"noRelativeImports",data:{alias:s?.alias},fix:s?i=>i.replaceText(p.source,`'${s.newPath}'`):void 0})}}}}),Ue={name:vt,rule:yr};import{AST_NODE_TYPES as le,ESLintUtils as At}from"@typescript-eslint/utils";import*as We from"typescript";var gr=At.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),kt="no-unnecessary-casting",hr=$({additionalCastFunctions:_(H($({name:L(),expectedType:fe(["string","number"])})))}),He={name:kt,rule:gr({name:kt,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:[hr],fixable:"code"},defaultOptions:[{}],create(e){let r=e.options[0].additionalCastFunctions||[],o=[{name:"Number",expectedType:"number"},{name:"String",expectedType:"string"},...r],l=At.getParserServices(e,!0),f=l.program?.getTypeChecker();if(!f||!l.program)throw new Error("TypeScript services or program not available");function p(i,c){switch(i.type){case le.Literal:return c==="number"?typeof i.value=="number":typeof i.value=="string";case le.TemplateLiteral:return c==="string";case le.UnaryExpression:return c==="number"?i.operator==="+"||i.operator==="-"||i.operator==="~":!1;default:return!1}}function n(i,c){return c==="number"?!!(i.flags&We.TypeFlags.NumberLike):!!(i.flags&We.TypeFlags.StringLike)}function a(i,c){return g=>g.replaceText(i,e.sourceCode.getText(c))}function s(i){if(!f||i.arguments.length!==1)return;let c=i.arguments[0];if(!c||c.type===le.SpreadElement)return;let{callee:g}=i;if(g.type!==le.Identifier)return;let T=g.name,S=o.find(b=>b.name===T);if(!S)return;if(p(c,S.expectedType)||n(f.getTypeAtLocation(l.esTreeNodeToTSNodeMap.get(c)),S.expectedType)){let b,y;T==="Number"?b="unnecessaryNumberCasting":T==="String"?b="unnecessaryStringCasting":(b="unnecessaryCustomCasting",y={name:S.name,type:S.expectedType}),e.report({node:i,messageId:b,...y?{data:y}:{},fix:a(i,c)})}}return{CallExpression:s}}})};import{AST_NODE_TYPES as F,ESLintUtils as Tr}from"@typescript-eslint/utils";var Sr=Tr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function Ot(e){let t=[];for(let r of e.members)r.type===F.TSPropertySignature&&r.key.type===F.Identifier&&t.push([r.key.name,r]);return t}function Pt(e,...t){for(let r of t)e.set(...r);return e}var Er=$({forceCheckOnFCPropTypesWithName:_(H(L()))}),Nt="no-unused-type-props-in-args",Ve=null,br=Sr({name:Nt,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:[Er],fixable:"code"},defaultOptions:[{}],create(e,[t]){let{forceCheckOnFCPropTypesWithName:r}=t;r&&!Ve&&(Ve=r.map(n=>new RegExp(n)));function o(n,a,s,i,c=!0){let g=s.name,T=e.sourceCode.getScope(a).references.find(b=>b.identifier.name===g)?.resolved,S=n&&Ve?.some(b=>b.test(g));if(!T||!S&&T.references.filter(b=>b.isTypeReference).length>1)return;let d=T?.defs[0]?.node;if(!(c&&d?.parent?.type===F.ExportNamedDeclaration)){if(d?.type===F.TSTypeAliasDeclaration){l(n,a,i,d.typeAnnotation,!0);return}if(d?.type===F.TSInterfaceDeclaration){l(n,a,i,d.body,!0);return}}}function l(n,a,s,i,c){if(i.type===F.TSInterfaceBody){for(let g of i.body)g.type===F.TSPropertySignature&&g.key.type===F.Identifier&&s.set(g.key.name,g);return}if(i.type===F.TSTypeLiteral){Pt(s,...Ot(i));return}if(i.type===F.TSIntersectionType){for(let g of i.types)l(n,a,s,g,!0);return}c||i.type===F.TSTypeReference&&i.typeName.type===F.Identifier&&o(n,a,i.typeName,s)}function f(n,a,s){for(let i of s)if(i.type==="ObjectPattern"&&i.typeAnnotation){let c=new Map;if(l(n,a,c,i.typeAnnotation.typeAnnotation,!1),c.size===0)continue;p(i,c)}else i.type===F.AssignmentPattern&&i.left.type===F.ObjectPattern&&f(n,a,[i.left])}function p(n,a){let s=[];if(n.properties.at(-1)?.type===F.RestElement)return;for(let T of n.properties)T.type===F.Property&&T.key.type===F.Identifier&&s.push(T.key.name);let c=[],g=[];for(let[T,S]of a)s.includes(T)||(g.push(T),c.push({node:S,messageId:"unusedObjectTypeProperty",data:{propertyName:T}}));for(let[T,S]of c.entries())e.report({...S,fix:T===c.length-1?d=>{let b=n.properties.at(-1),y=g.join(", ");return b?b?.type===F.RestElement?null:d.insertTextAfter(b,`, ${y}`):d.insertTextBeforeRange([n.range[0]+1,n.range[1]],`${y}`)}:void 0})}return{VariableDeclaration(n){let a=n.declarations[0];if(!a)return;let s=new Map,i=a.id.type===F.Identifier&&a.id.typeAnnotation?.typeAnnotation.type===F.TSTypeReference&&a.id.typeAnnotation.typeAnnotation.typeName.type===F.Identifier&&a.id.typeAnnotation.typeAnnotation.typeName.name==="FC"&&a.id.typeAnnotation.typeAnnotation.typeArguments?.params[0];if(i){if(i.type===F.TSTypeReference&&i.typeName.type===F.Identifier)o(!0,n,i.typeName,s,!1);else if(i.type===F.TSTypeLiteral)Pt(s,...Ot(i));else if(i.type===F.TSIntersectionType)for(let c of i.types)c.type===F.TSTypeReference&&c.typeName.type===F.Identifier?o(!0,n,c.typeName,s,!1):l(!0,n,s,c,!0);if(s.size!==0&&a.init?.type===F.ArrowFunctionExpression){let c=a.init.params[0];if(!c){e.report({node:a.init,messageId:"missingComponentParam"});return}c.type===F.ObjectPattern&&p(c,s)}}},FunctionDeclaration:function(n){f(!1,n,n.params)},ArrowFunctionExpression(n){f(!1,n,n.params)}}}}),Ye={name:Nt,rule:br};import{AST_NODE_TYPES as ze,ESLintUtils as xr}from"@typescript-eslint/utils";var Cr=xr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),_t="prefer-named-functions",Dt=new Map,Ir=Cr({name:_t,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 o=Dt.get(t.ignoreRegex);o?r=o:(r=new RegExp(t.ignoreRegex),Dt.set(t.ignoreRegex,r))}return{VariableDeclarator(o){if(o.init&&o.init.type===ze.ArrowFunctionExpression&&o.id.type===ze.Identifier){let l=o.id.name;if(o.id.typeAnnotation||r&&r.test(l)||!t.disallowArrowFnWithImplicitReturns&&o.init.body.type!==ze.BlockStatement)return;let f=o.parent,p=o.init.params,n=o.init.body,a=o.init;e.report({node:o.id,messageId:r?"withIgnoreRegex":"default",data:{functionName:l,ignoreRegex:t.ignoreRegex},suggest:[{messageId:"suggestion",fix:s=>s.replaceText(f,`${a.async?"async ":""}function ${l}(${p.map(i=>e.sourceCode.getText(i)).join(", ")||""}) ${e.sourceCode.getText(n)}`)}]})}}}}}),Be={name:_t,rule:Ir};import{AST_NODE_TYPES as W,AST_TOKEN_TYPES as Lt,ESLintUtils as wr}from"@typescript-eslint/utils";var Rr=wr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ft="prefer-single-line-if",vr=$({maxLineLength:_(J()),maxNonSimpleConditionLength:_(J())}),kr=Rr({name:Ft,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:[vr]},defaultOptions:[{}],create(e,[t]){let r=e.sourceCode;return{IfStatement(o){if(o.consequent.type!==W.BlockStatement||o.loc.start.line===o.loc.end.line||r.getCommentsInside(o.consequent).length>0||o.alternate||o.consequent.body.length!==1)return;let f=o.consequent.body[0];if(f.type===W.ReturnStatement){if(!Mt(f))return}else if(!(f.type===W.ContinueStatement||f.type===W.BreakStatement))return;if(o.test.type===W.LogicalExpression||o.test.type===W.ConditionalExpression)return;let p;if(t.maxNonSimpleConditionLength){let c=$t(o.test);if(!c&&o.test.type===W.UnaryExpression&&o.test.operator==="!"){let g=o.test.argument;$t(g)&&(c=!0)}if(c&&(p=r.getText(o.test),p.length>t.maxNonSimpleConditionLength))return}p||(p=r.getText(o.test));let n=r.getText(f);if(p.includes(`
15
+ `))return;let a=r.getTokenAfter(o);if(a&&a.type===Lt.Punctuator&&a.value==="}"){let c=r.getTokenAfter(a);if(c&&c.type===Lt.Keyword&&(c.value==="else"||c.value==="catch"))return}let s=Ar(r,o),i=`if (${p}) ${n}`;t.maxLineLength&&i.length+s.length>t.maxLineLength||e.report({node:o,messageId:"noSingleLineCurly",fix:c=>c.replaceText(o,i)})}}}});function $t(e){return e.type===W.CallExpression||e.type===W.BinaryExpression||e.type===W.MemberExpression&&jt(e)}function jt(e){return e.object.type===W.MemberExpression?jt(e.object):e.object.type!==W.Identifier}function Ar(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}function Mt(e){if(!e.argument)return!0;let t=e.argument;return t.type===W.ArrayExpression&&t.elements.length===0||t.type===W.ObjectExpression&&t.properties.length===0||t.type===W.Literal||t.type===W.Identifier||t.type===W.TemplateLiteral||t.type===W.TaggedTemplateExpression?!0:t.type===W.CallExpression?t.arguments.length===0:t.type===W.UnaryExpression?Mt(t):!1}var qe={name:Ft,rule:kr};import{AST_NODE_TYPES as q,ESLintUtils as Or}from"@typescript-eslint/utils";var Pr=Or.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ut="react-compiler-migration",Nr=$({disallowHooks:_(H($({name:L(),replacement:L()}))),disallowMethods:_(H($({name:L(),replacement:_(L()),requireTrueProp:_(L())})))}),Dr=/eslint +react-compiler\/react-compiler: +\["error/;function _r(e){return e.type===q.Identifier?e.name.startsWith("use"):e.type===q.MemberExpression&&e.property.type===q.Identifier?e.property.name.startsWith("use"):!1}var Lr=Pr({name:Ut,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:[Nr]},defaultOptions:[{}],create(e,[t]){let r=!1;for(let o of e.sourceCode.getAllComments())if(Dr.test(o.value)){r=!0;break}return r?{CallExpression(o){if(t.disallowHooks?.length){let l=null,f=null;if(o.callee.type===q.Identifier?(l=o.callee.name,f=o.callee):o.callee.type===q.MemberExpression&&o.callee.property.type===q.Identifier&&(l=o.callee.property.name,f=o.callee.property),l){let p=t.disallowHooks.find(n=>n.name===l);p&&f&&e.report({node:o,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:p.name,replacement:p.replacement},suggest:[{messageId:"replace",data:{replacement:p.replacement},fix:n=>n.replaceText(f,p.replacement)}]})}}if(t.disallowMethods?.length&&_r(o.callee)){for(let l of o.arguments)if(l.type===q.ObjectExpression){for(let f of l.properties)if(f.type===q.Property&&f.key.type===q.Identifier){let p=f.key.name,n=t.disallowMethods.find(a=>a.name===p);if(n){if(n.requireTrueProp){let a=n.requireTrueProp,s=!1;for(let i of l.properties)if(i.type===q.Property&&i.key.type===q.Identifier&&i.key.name===a&&i.value.type===q.Literal&&i.value.value===!0){s=!0;break}if(!s){e.report({node:f,messageId:"disallowedMethodWithMissingRequireTrueProp",data:{method:n.name,requireTrueProp:a}});continue}}n.replacement&&e.report({node:f,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:n.name,replacement:n.replacement},suggest:[{messageId:"replace",data:{replacement:n.replacement},fix:a=>a.replaceText(f.key,n.replacement)}]})}}}}}}:{}}}),Ke={name:Ut,rule:Lr};import{ESLintUtils as $r,TSESTree as Fr}from"@typescript-eslint/utils";var jr=$r.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Wt="require-description",Mr=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,Ur=/^eslint-disable-(next-)?line$/u,Wr=jr({name:Wt,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,o=new Set(t.ignore||[]);return{Program(){for(let l of r.getAllComments()){let f=Hr(l);f!=null&&(o.has(f.kind)||f.description||e.report({loc:Yr(l.loc),messageId:"missingDescription"}))}}}}}),Ht={name:Wt,rule:Wr};function Hr(e){let{text:t,description:r}=Vr(e.value);if(!t)return null;let o=Mr.exec(t);if(!o)return null;let l=o[1];if(!l)return null;let f=Ur.test(l);if(e.type===Fr.AST_TOKEN_TYPES.Line&&!f||f&&e.loc.start.line!==e.loc.end.line)return null;let p=t.slice(o.index+l.length);return{kind:l,value:p.trim(),description:r}}function Vr(e){let t=e.split(/\s-{2,}\s/u);return{text:t[0]?.trim(),description:t.length>1?t[1]?.trim()??null:null}}function Yr(e){return{start:{line:e.start.line,column:-1},end:e.end}}function zt(e){return/^use[A-Z0-9]/.test(e)}function ge(e){return e.type==="Identifier"?zt(e.name):e.type==="MemberExpression"&&!e.computed&&ge(e.property)?e.object.type==="Identifier":!1}function Bt(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function qt(e,t){return e.name===t||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===t}function Kt(e){return!!(e.parent&&e.parent.callee&&qt(e.parent.callee,"forwardRef"))}function Xt(e){return!!(e.parent&&e.parent.callee&&qt(e.parent.callee,"memo"))}function Xe(e){for(;e;){let t=Gt(e);if(t&&(Bt(t)||ge(t))||Kt(e)||Xt(e))return!0;e=e.parent}return!1}function Vt(e){return!1}function Je(e){return!1}var zr=/eslint +react-compiler\/react-compiler: +\["error/,Jt={meta:{type:"problem",docs:{description:"enforces the Rules of Hooks",recommended:!0,url:"https://reactjs.org/docs/hooks-rules.html"},schema:[{type:"object",ignoreIfReactCompilerIsEnabled:!1,properties:{ignoreIfReactCompilerIsEnabled:{type:"boolean"}}}]},create(e){if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let a of e.sourceCode.getAllComments())if(zr.test(a.value))return{CallExpression(s){let i=null;s.callee.name==="useMemo"?i="useMemo":s.callee.name==="useCallback"&&(i="useCallback"),i&&e.report({node:s,message:`"${i}" is not necessary when using React Compiler.`})}}}let t=typeof e.getSource=="function"?a=>t(a):a=>e.sourceCode.getText(a),r=typeof e.getScope=="function"?()=>r():a=>e.sourceCode.getScope(a),o=null,l=[],f=[],p=new WeakSet;function n(a){for(let s of a.references){let i=s.identifier.parent;if(i.type==="VariableDeclarator"&&i.init&&i.init.type==="CallExpression"&&i.init.callee&&Vt(i.init.callee))for(let c of s.resolved.references)c!==s&&p.add(c.identifier)}}return{onCodePathSegmentStart:a=>f.push(a),onCodePathSegmentEnd:()=>f.pop(),onCodePathStart:()=>l.push(new Map),onCodePathEnd(a,s){let i=l.pop();if(i.size===0)return;let c=new Set;function g(h,w){let{cache:R}=g,k=R.get(h.id),D=new Set(w);if(D.has(h.id)){let A=[...D],U=A.slice(A.indexOf(h.id)+1);for(let X of U)c.add(X);return BigInt("0")}if(D.add(h.id),k!==void 0)return k;if(a.thrownSegments.includes(h))k=BigInt("0");else if(h.prevSegments.length===0)k=BigInt("1");else{k=BigInt("0");for(let A of h.prevSegments)k+=g(A,D)}return h.reachable&&k===BigInt("0")?R.delete(h.id):R.set(h.id,k),k}function T(h,w){let{cache:R}=T,k=R.get(h.id),D=new Set(w);if(D.has(h.id)){let A=Array.from(D),U=A.slice(A.indexOf(h.id)+1);for(let X of U)c.add(X);return BigInt("0")}if(D.add(h.id),k!==void 0)return k;if(a.thrownSegments.includes(h))k=BigInt("0");else if(h.nextSegments.length===0)k=BigInt("1");else{k=BigInt("0");for(let A of h.nextSegments)k+=T(A,D)}return R.set(h.id,k),k}function S(h){let{cache:w}=S,R=w.get(h.id);if(R===null)return 1/0;if(R!==void 0)return R;if(w.set(h.id,null),h.prevSegments.length===0)R=1;else{R=1/0;for(let k of h.prevSegments){let D=S(k);D<R&&(R=D)}R+=1}return w.set(h.id,R),R}g.cache=new Map,T.cache=new Map,S.cache=new Map;let d=T(a.initialSegment),b=Gt(s),y=Xe(s),N=b?Bt(b)||ge(b):Kt(s)||Xt(s),v=1/0;for(let h of a.finalSegments){if(!h.reachable)continue;let w=S(h);w<v&&(v=w)}for(let[h,w]of i){if(!h.reachable)continue;let R=h.nextSegments.length===0?v<=S(h):v<S(h),k=g(h)*T(h),D=c.has(h.id);for(let A of w)if(D&&!Je(A)&&e.report({node:A,message:`React Hook "${t(A)}" 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.`}),N){if(s.async&&e.report({node:A,message:`React Hook "${t(A)}" cannot be called in an async function.`}),!D&&k!==d&&!Je(A)){let X=`React Hook "${t(A)}" is called conditionally. React Hooks must be called in the exact same order in every component render.`+(R?" Did you accidentally call a React Hook after an early return?":"");e.report({node:A,message:X})}}else if(s.parent&&(s.parent.type==="MethodDefinition"||s.parent.type==="ClassProperty")&&s.parent.value===s){let U=`React Hook "${t(A)}" 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:A,message:U})}else if(b){let U=`React Hook "${t(A)}" is called in function "${t(b)}" 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:A,message:U})}else if(s.type==="Program"){let U=`React Hook "${t(A)}" 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:A,message:U})}else if(y&&!Je(A)){if(s.parent.type==="CallExpression"&&s.parent.callee.type==="Identifier"&&s.parent.callee.name==="useCallback"){let X=s.parent;if(X.parent.type==="VariableDeclarator"&&zt(X.parent.id.name))return}let U=`React Hook "${t(A)}" 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:A,message:U})}}},CallExpression(a){if(ge(a.callee)){let s=Yt(l),i=Yt(f),c=s.get(i);c||(c=[],s.set(i,c)),c.push(a.callee)}a.callee.type==="Identifier"&&(a.callee.name==="useEffect"||Vt(a.callee))&&a.arguments.length>0&&(o=a)},Identifier(a){o==null&&p.has(a)&&a.parent.type!=="CallExpression"&&e.report({node:a,message:`\`${t(a)}\` is a function created with React Hook "useEffectEvent", and can only be called from the same component. They cannot be assigned to variables or passed down.`})},"CallExpression:exit"(a){a===o&&(o=null)},FunctionDeclaration(a){Xe(a)&&n(r(a))},ArrowFunctionExpression(a){Xe(a)&&n(r(a))}}}};function Gt(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 Yt(e){return e[e.length-1]}var Zt={[Ye.name]:Ye.rule,[De.name]:De.rule,[Ne.name]:Ne.rule,"rules-of-hooks":Jt,"exhaustive-deps":ft,"require-description":Ht.rule,[_e.name]:_e.rule,[$e.name]:$e.rule,[Be.name]:Be.rule,[we.name]:we.rule,[Pe.name]:Pe.rule,[Ue.name]:Ue.rule,[qe.name]:qe.rule,[je.name]:je.rule,[Le.name]:Le.rule,[Re.name]:Re.rule,[Ke.name]:Ke.rule,[Ce.name]:Ce.rule,[Oe.name]:Oe.rule,[He.name]:He.rule};var Ts={rules:Zt};export{Ts as extendedLintPlugin};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ls-stack/extended-lint",
3
- "version": "0.35.1",
3
+ "version": "0.36.0",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "dist"
@@ -23,10 +23,10 @@
23
23
  "@ls-stack/utils": "^2.4.0",
24
24
  "@types/eslint": "^9.6.1",
25
25
  "@types/node": "^22.13.0",
26
- "@typescript-eslint/parser": "^8.22.0",
27
- "@typescript-eslint/rule-tester": "^8.22.0",
26
+ "@typescript-eslint/parser": "^8.26.0",
27
+ "@typescript-eslint/rule-tester": "^8.26.0",
28
28
  "@vitest/ui": "^3.0.4",
29
- "eslint": "^9.19.0",
29
+ "eslint": "^9.22.0",
30
30
  "tschema": "^3.2.0",
31
31
  "tsm": "^2.3.0",
32
32
  "tsup": "^8.3.6",