@ls-stack/extended-lint 0.37.0 → 0.39.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/extended-lint.js +5 -5
- package/dist/extended-lint.mjs +5 -5
- package/package.json +1 -1
package/dist/extended-lint.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`)||n.getCommentsInside(
|
|
3
|
-
`,n.range[1]);return(r!==-1?r:t.text.length)-n.range[1]}function
|
|
1
|
+
"use strict";var Tn=Object.create;var he=Object.defineProperty;var En=Object.getOwnPropertyDescriptor;var bn=Object.getOwnPropertyNames;var xn=Object.getPrototypeOf,Cn=Object.prototype.hasOwnProperty;var In=(e,t)=>{for(var n in t)he(e,n,{get:t[n],enumerable:!0})},dt=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of bn(t))!Cn.call(e,o)&&o!==n&&he(e,o,{get:()=>t[o],enumerable:!(r=En(t,o))||r.enumerable});return e};var Ne=(e,t,n)=>(n=e!=null?Tn(xn(e)):{},dt(t||!e||!e.__esModule?he(n,"default",{value:e,enumerable:!0}):n,e)),wn=e=>dt(he({},"__esModule",{value:!0}),e);var Zr={};In(Zr,{extendedLintPlugin:()=>Gr});module.exports=wn(Zr);var Y=require("@typescript-eslint/utils");var _e=Symbol.for("optional");function N(e){return{...e,[_e]:!0}}function Te(e,t){return{enum:e,...t}}function ae(e){return{...e,type:"boolean"}}function F(e){return{...e,type:"string"}}function X(e){return{...e,type:"number"}}function yt(e){return{...e,type:"integer"}}function H(e,t){return{...t,type:"array",items:e}}function L(e,t){let n={...t,type:"object",properties:e};if(e&&(n.additionalProperties||=!1,!n.required)){let r,o=[];for(r in e)e[r][_e]?e[r][_e]=void 0:o.push(r);o.length>0&&(n.required=o)}return n}function Fe(...e){return{anyOf:e}}var Rn=Y.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),St="react-compiler-extra",vn=L({runOnlyWithEnableCompilerDirective:N(ae())}),On=/eslint +react-compiler\/react-compiler: +\["error/;function kn(e){return e.type===Y.AST_NODE_TYPES.Identifier?e.name.startsWith("use"):e.type===Y.AST_NODE_TYPES.MemberExpression&&e.property.type===Y.AST_NODE_TYPES.Identifier?e.property.name.startsWith("use"):!1}var An=/\bthis[.[]/;function gt(e){return An.test(e)}var Pn=Rn({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:[vn]},defaultOptions:[{}],create(e,[t]){let n=!1;if(t.runOnlyWithEnableCompilerDirective){for(let u of e.sourceCode.getAllComments())if(On.test(u.value)){n=!0;break}if(!n)return{}}function r(u){for(let c of u.properties)if(c.type===Y.AST_NODE_TYPES.Property&&c.method&&c.value.type===Y.AST_NODE_TYPES.FunctionExpression){let i=e.sourceCode,a=i.getText(c.key),l=c.value,s=i.getText(l.body);if(gt(s))e.report({node:c,messageId:"thisKeywordInMethod"});else{let p=l.params.map(y=>i.getText(y)).join(", "),g="";l.generator?g=`${a}: function* (${p}) ${s}`:g=`${a}: (${p}) => ${s}`,e.report({node:c,messageId:"objectMethodIsNotSupported",fix:y=>y.replaceText(c,g)})}}}function o(u){for(let c of u.properties)if(c.type===Y.AST_NODE_TYPES.Property&&c.value.type===Y.AST_NODE_TYPES.ObjectExpression){for(let i of c.value.properties)if(i.type===Y.AST_NODE_TYPES.Property&&i.method&&i.value.type===Y.AST_NODE_TYPES.FunctionExpression){let l=e.sourceCode.getText(i.value.body);gt(l)&&e.report({node:i,messageId:"thisKeywordInMethod"})}}}return{CallExpression(u){if(kn(u.callee))for(let c of u.arguments){if(c.type===Y.AST_NODE_TYPES.ObjectExpression&&(r(c),o(c)),c.type===Y.AST_NODE_TYPES.ArrowFunctionExpression&&(c.body.type===Y.AST_NODE_TYPES.ObjectExpression&&(r(c.body),o(c.body)),c.body.type===Y.AST_NODE_TYPES.BlockStatement))for(let i of c.body.body)i.type===Y.AST_NODE_TYPES.ReturnStatement&&i.argument?.type===Y.AST_NODE_TYPES.ObjectExpression&&(r(i.argument),o(i.argument));if(c.type===Y.AST_NODE_TYPES.FunctionExpression)for(let i of c.body.body)i.type===Y.AST_NODE_TYPES.ReturnStatement&&i.argument?.type===Y.AST_NODE_TYPES.ObjectExpression&&(r(i.argument),o(i.argument))}}}}}),De={name:St,rule:Pn};var le=require("@typescript-eslint/utils");var Nn=le.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),_n=L({disallow:N(H(L({selector:F(),message:F(),replace:N(Fe(F(),L({regex:F(),with:F()}))),replaceType:N(Te(["suggestion","autofix"]))}))),__dev_simulateFileName:N(F()),mustMatchSyntax:N(H(L({includeRegex:F(),mustCallFn:H(L({anyCall:H(L({fn:F(),withArgs:H(L({atIndex:yt(),literal:Fe(F(),X(),ae())}))})),message:N(F())}))})))}),Et="advanced-no-restricted-syntax",Fn=Nn({name:Et,meta:{type:"suggestion",docs:{description:"Disallow specific syntax patterns"},schema:[_n],messages:{default:"{{message}}"},fixable:"code",hasSuggestions:!0},defaultOptions:[{disallow:[]}],create(e,[t]){let n={},{mustMatchSyntax:r,__dev_simulateFileName:o,disallow:u}=t,c=o??e.filename,i=[],a=new Set;for(let{includeRegex:s,mustCallFn:p}of r??[]){let g=Dn(c,new RegExp(s));if(!g)continue;let y=S=>{let d=S;for(let{name:b,value:h}of g)d=d.replaceAll(b,h);return d};for(let{anyCall:S,message:d}of p){let b=`Expected file to call the function: ${S.map(({fn:h})=>h).join(" or ")}`;a.add(b),i.push(h=>{let{callee:_}=h;if(_.type===le.AST_NODE_TYPES.Identifier){for(let{fn:v,withArgs:T}of S)if(_.name===v){a.delete(b);for(let w of T){let R=h.arguments[w.atIndex],O=typeof w.literal=="string"?y(w.literal):w.literal;if(!R){e.report({node:h,messageId:"default",data:{message:`Missing argument with value "${O}" at index ${w.atIndex}${d?`: ${y(d)}`:""}`}});continue}if(R.type!==le.AST_NODE_TYPES.Literal){e.report({node:R,messageId:"default",data:{message:`Argument at position ${w.atIndex} should the literal "${O}"${d?`: ${y(d)}`:""}`}});continue}R.value!==O&&e.report({node:R,messageId:"default",data:{message:`Argument should have the value "${O}"${d?`: ${y(d)}`:""}`},fix:$=>$.replaceText(R,typeof O=="string"?`'${O}'`:String(O))})}break}}})}}for(let{selector:s,message:p,replace:g,replaceType:y="suggestion"}of u??[]){if(s==="CallExpression"){i.push(S=>{l(g,S,p,y)});continue}n[s]=S=>{l(g,S,p,y)}}return i.length>0&&(n.CallExpression=s=>{if(s.type===le.AST_NODE_TYPES.CallExpression)for(let p of i)p(s)}),n["Program:exit"]=s=>{for(let p of a)e.report({node:s,messageId:"default",data:{message:`${p}`}})},n;function l(s,p,g,y){let S=d=>{if(!s)return null;if(typeof s=="string")return d.replaceText(p,s);{let b=new RegExp(s.regex),h=e.sourceCode.getText(p);return d.replaceText(p,h.replace(b,s.with))}};e.report({node:p,messageId:"default",data:{message:g},fix:s&&y==="autofix"?S:void 0,suggest:s&&y==="suggestion"?[{messageId:"default",data:{message:`Replace with "${typeof s=="string"?s:s.with}"`},fix:S}]:void 0})}}});function Dn(e,t){let n=[],r=t.exec(e);if(!r)return null;let[o,...u]=r;n.push({name:"$0_lowercase",value:o.toLowerCase()}),n.push({name:"$0_capitalize",value:ht(o)}),n.push({name:"$0_uncapitalize",value:Tt(o)}),n.push({name:"$0",value:o});for(let c=0;c<u.length;c++){let i=`$${c+1}`,a=u[c];n.push({name:`${i}_lowercase`,value:a.toLowerCase()}),n.push({name:`${i}_capitalize`,value:ht(a)}),n.push({name:`${i}_uncapitalize`,value:Tt(a)}),n.push({name:i,value:a})}return n}function ht(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Tt(e){return e.charAt(0).toLowerCase()+e.slice(1)}var Le={name:Et,rule:Fn};var D=require("@typescript-eslint/utils");var Ln=D.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),xt="collapse-simple-objs-in-one-line",$n=L({maxLineLength:N(X()),maxProperties:N(X()),nestedObjMaxLineLength:N(X()),nestedObjMaxProperties:N(X()),ignoreTypesWithSuffix:N(H(F()))}),jn=Ln({name:xt,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:[$n]},defaultOptions:[{}],create(e,[t]){let n=e.sourceCode,r=t.ignoreTypesWithSuffix??[],o=t.maxProperties??2,u=t.nestedObjMaxLineLength??t.maxLineLength,c=t.nestedObjMaxProperties??3;function i(l){if(l.type===D.AST_NODE_TYPES.ObjectExpression){let s=l.parent.type===D.AST_NODE_TYPES.Property,p=s?c:o,g=l.properties.length;if(g>p)return!1;if(g===1){let S=l.properties[0];return S.type===D.AST_NODE_TYPES.Property&&S.value.type===D.AST_NODE_TYPES.ObjectExpression||S.type===D.AST_NODE_TYPES.Property&&S.value.type===D.AST_NODE_TYPES.ArrayExpression&&!S.value.elements.every(b=>b&&$e(b))?!1:{text:n.getText(S),isNested:s,propsSize:g}}let y=[];for(let S of l.properties){if(S.type===D.AST_NODE_TYPES.Property&&!$e(S.value))return!1;y.push(n.getText(S))}return{text:y.join(", "),isNested:s,propsSize:g}}else{let s=l.parent.parent?.type===D.AST_NODE_TYPES.TSPropertySignature,p=s?c:o,g=l.members.length;if(g>p)return!1;if(r.length>0&&l.parent.type===D.AST_NODE_TYPES.TSTypeAliasDeclaration){let S=l.parent.id.name;if(r.some(d=>S.endsWith(d)))return!1}if(g===1){let S=l.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:s,propsSize:1}}if(l.parent.type===D.AST_NODE_TYPES.TSIntersectionType||l.parent.type===D.AST_NODE_TYPES.TSUnionType)return!1;let y=[];for(let S of l.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||!bt(d))return!1;if(d.type===D.AST_NODE_TYPES.TSTypeReference&&d.typeArguments){if(d.typeArguments.params.length>1)return!1;let h=d.typeArguments.params[0];if(!bt(h))return!1}let b=n.getText(S).trim();(b.endsWith(";")||b.endsWith(","))&&(b=b.slice(0,-1)),y.push(b)}return{text:y.join("; "),isNested:s,propsSize:g}}}function a(l){if(l.loc.start.line===l.loc.end.line)return;if(l.parent.type!==D.AST_NODE_TYPES.JSXExpressionContainer){let d=0,b=n.getTokenAfter(l,{filter:h=>h.type!==D.AST_TOKEN_TYPES.Punctuator?!0:h.value===","||h.value===";"||h.value===")"||h.value==="}"?(d++,!1):!0});if(d>4||b?.loc.start.line===l.loc.end.line)return}let s=i(l);if(!s)return;let p=s.text;if(p.includes(`
|
|
2
|
+
`)||n.getCommentsInside(l).length>0)return;p.endsWith(";")&&(p=p.slice(0,-1));let g=`{ ${p} }`,y=Un(n,l),S=s.isNested&&s.propsSize>2?u:t.maxLineLength;S&&g.length+y.length+Mn(l,n)>S||e.report({node:l,messageId:"singleLineProp",fix:d=>d.replaceText(l,g)})}return{TSTypeLiteral:a,ObjectExpression:a}}});function bt(e){return e.type===D.AST_NODE_TYPES.TSLiteralType||e.type===D.AST_NODE_TYPES.TSTypeReference||e.type===D.AST_NODE_TYPES.TSNumberKeyword||e.type===D.AST_NODE_TYPES.TSStringKeyword||e.type===D.AST_NODE_TYPES.TSBooleanKeyword||e.type===D.AST_NODE_TYPES.TSNullKeyword||e.type===D.AST_NODE_TYPES.TSUndefinedKeyword}function $e(e,t){return!!(e.type===D.AST_NODE_TYPES.Literal||e.type===D.AST_NODE_TYPES.Identifier||e.type===D.AST_NODE_TYPES.TemplateLiteral||e.type===D.AST_NODE_TYPES.TaggedTemplateExpression||!t&&e.type===D.AST_NODE_TYPES.ArrayExpression&&e.elements.every(n=>n&&$e(n,!0)))}function Mn(e,t){let n=t.getLastToken(e);if(!n)return 0;let r=t.text.indexOf(`
|
|
3
|
+
`,n.range[1]);return(r!==-1?r:t.text.length)-n.range[1]}function Un(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}var je={name:xt,rule:jn};var Vn=/eslint +react-compiler\/react-compiler: +\["error/,It={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"?h=>n(h):h=>e.sourceCode.getText(h),r=typeof e.getScope=="function"?()=>r():h=>e.sourceCode.getScope(h),o=e.options&&e.options[0]&&e.options[0].additionalHooks?new RegExp(e.options[0].additionalHooks):void 0,u=e.options&&e.options[0]&&e.options[0].enableDangerousAutofixThisMayCauseInfiniteLoops||!1,c={additionalHooks:o,enableDangerousAutofixThisMayCauseInfiniteLoops:u};function i(h){u&&Array.isArray(h.suggest)&&h.suggest.length>0&&(h.fix=h.suggest[0].fix),e.report(h)}let a=e.getSourceCode().scopeManager,l=new WeakMap,s=new WeakSet,p=new WeakMap,g=new WeakMap,y=new WeakSet;function S(h,_){return function(v){if(_.has(v))return _.get(v);let T=h(v);return _.set(v,T),T}}function d(h,_,v,T,w){w&&h.async&&i({node:h,message:`Effect callbacks are synchronous to prevent race conditions. Put the async function inside:
|
|
4
4
|
|
|
5
5
|
useEffect(() => {
|
|
6
6
|
async function fetchData() {
|
|
@@ -11,5 +11,5 @@ useEffect(() => {
|
|
|
11
11
|
fetchData();
|
|
12
12
|
}, [someId]); // Or [] if effect doesn't need props or state
|
|
13
13
|
|
|
14
|
-
Learn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching`});let R=o.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&&(Ue(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(Vn(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;a.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++)s.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)&&!ot(O.resolved))return!1}return!0}let ot=S(W,c),ln=S(X,g),at=new Map;function cn(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,ve=new Map;lt(R);function lt(u){for(let m of u.references){if(!m.resolved||!k.has(m.resolved.scope))continue;let E=Ue(y,m.identifier),x=Ct(E),I=Q(x,ve);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"&&cn(m)&&at.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=ot(O)||ln(O);B.set(I,{isStable:P,references:[m]})}}for(let m of u.childScopes)lt(m)}at.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||i({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 ke=new Set;function pn(u,m){ke.has(m)||(ke.add(m),i({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&&pn(x.writeExpr,E)})}),ke.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(!a.has(C))return;let P=I.from;for(;P.type!=="function";)P=P.upper;P.block===y&&(u=x)})}),u){let{suggestedDependencies:m}=je({dependencies:B,declaredDependencies:[],stableDependencies:de,externalDependencies:new Set,isEffect:!0});i({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"?i({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"){i({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)&&i({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,ve)}catch(I){if(/Unsupported node type/.test(I.message)){u.type==="Literal"?B.has(u.value)?i({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?`}):i({node:u,message:`The ${u.raw} literal is not a valid dependency because it never changes. You can safely remove it.`}):i({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:un,unnecessaryDependencies:ye,missingDependencies:ne,duplicateDependencies:ct}=je({dependencies:B,declaredDependencies:ue,stableDependencies:de,externalDependencies:fe,isEffect:w}),ge=un;if(ct.size+ne.size+ye.size===0){if(t)return;jn({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}`,pt;E&&m.type==="Variable"&&x==="function"&&(pt=[{desc:`Wrap the ${C} of '${m.name.name}' in its own ${I}() Hook.`,fix(ut){let[mn,dn]=I==="useMemo"?["useMemo(() => { return ","; })"]:["useCallback(",")"];return[ut.insertTextBefore(m.node.init,mn),ut.insertTextAfter(m.node.init,dn)]}}]),i({node:m.node,message:Z,suggest:pt})});return}!w&&ne.size>0&&(ge=je({dependencies:B,declaredDependencies:[],stableDependencies:de,externalDependencies:fe,isEffect:w}).suggestedDependencies);function fn(){if(ue.length===0)return!0;let u=ue.map(E=>E.key),m=u.slice().sort();return u.join(",")===m.join(",")}fn()&&ge.sort();function Ae(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=ve.get(I)===!0;E+=C?"?.":"."}E+=m[x]}return E}function Oe(u,m,E,x){return u.size===0?null:(u.size>1?"":m+" ")+E+" "+(u.size>1?"dependencies":"dependency")+": "+Un(Array.from(u).sort().map(I=>"'"+Ae(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=Ue(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=a.get(C.callee);if(P!=null){if(P.name===m)u={missingDep:m,setter:C.callee.name,form:"updater"};else if(s.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.")}}i({node:N,message:`React Hook ${n(v)} has `+(Oe(ne,"a","missing","include")||Oe(ye,"an","unnecessary","exclude")||Oe(ct,"a","duplicate","omit"))+K,suggest:[{desc:`Update the dependencies array to be: [${ge.map(Ae).join(", ")}]`,fix(u){return u.replaceText(N,`[${ge.map(Ae).join(", ")}]`)}}]})}function b(y){let N=Mn(y.callee,p);if(N===-1)return;let v=y.arguments[N],h=y.callee,w=It(h).name,R=y.arguments[N+1],k=/Effect($|[^a-z])/g.test(w);if(!v){i({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")&&i({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=r(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:i({node:h,message:`React Hook ${w} received a function whose dependencies are unknown. Pass an inline function instead.`});return}i({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(Fn.test(y.value))return t=!0,{CallExpression:N=>b(N,!0)}}return{CallExpression:y=>b(y)}}};function je({dependencies:e,declaredDependencies:t,stableDependencies:n,externalDependencies:r,isEffect:l}){let f=p();function p(){return{isUsed:!1,isSatisfiedRecursively:!1,isSubtreeUsed:!1,children:new Map}}e.forEach((d,b)=>{let y=i(f,b);y.isUsed=!0,o(f,b,N=>{N.isSubtreeUsed=!0})}),t.forEach(({key:d})=>{let b=i(f,d);b.isSatisfiedRecursively=!0}),n.forEach(d=>{let b=i(f,d);b.isSatisfiedRecursively=!0});function i(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 o(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 a=new Set,s=new Set;c(f,a,s,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})=>{s.has(d)?g.indexOf(d)===-1?g.push(d):S.add(d):T.add(d)}),a.forEach(d=>{g.push(d)}),{suggestedDependencies:g,unnecessaryDependencies:T,duplicateDependencies:S,missingDependencies:a}}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 jn({declaredDependencies:e,declaredDependenciesNode:t,componentScope:n,scope:r}){let l=e.map(({key:p})=>{let i=n.variables.find(a=>a.name===p);if(i==null)return null;let o=i.defs[0];if(o==null)return null;if(o.type==="Variable"&&o.node.type==="VariableDeclarator"&&o.node.id.type==="Identifier"&&o.node.init!=null){let a=re(o.node.init);if(a!=null)return[i,a]}return o.type==="FunctionName"&&o.node.type==="FunctionDeclaration"?[i,"function"]:o.type==="ClassName"&&o.node.type==="ClassDeclaration"?[i,"class"]:null}).filter(Boolean);function f(p){let i=!1;for(let o=0;o<p.references.length;o++){let a=p.references[o];if(a.writeExpr){if(i)return!0;i=!0;continue}let s=a.from;for(;s!==r&&s!=null;)s=s.upper;if(s!==r&&!wt(t,a.identifier))return!0}return!1}return l.map(([p,i])=>({construction:p.defs[0],depType:i,isUsedOutsideOfHook:f(p)}))}function Ct(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)?Ct(e.parent):e.type==="MemberExpression"&&e.parent&&e.parent.type==="AssignmentExpression"&&e.parent.left===e?e.object:e}function Me(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),r=Q(e.property,null),l=`${n}.${r}`;return Me(e,t,l),l}else if(e.type==="OptionalMemberExpression"&&!e.computed){let n=Q(e.object,t),r=Q(e.property,null),l=`${n}.${r}`;return Me(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 r=Q(n.object,t),l=Q(n.property,null),f=`${r}.${l}`;return Me(n,t,f),f}else throw new Error(`Unsupported node type: ${e.type}`)}function It(e,t){return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.object.name==="React"&&e.property.type==="Identifier"&&!e.computed?e.property:e}function Mn(e,t){let n=It(e);if(n.type!=="Identifier")return-1;switch(n.name){case"useEffect":case"useLayoutEffect":case"useCallback":case"useMemo":return 0;case"useImperativeHandle":return 1;default:if(n===e&&t&&t.additionalHooks){let r;try{r=Q(n,null)}catch(l){if(/Unsupported node type/.test(l.message))return 0;throw l}return t.additionalHooks.test(r)?0:-1}else return-1}}function Ue(e,t){let n=[e],r=null;for(;n.length;){if(r=n.shift(),Wn(r,t))return r;if(wt(r,t))for(let[l,f]of Object.entries(r))l!=="parent"&&(bt(f)?(f.parent=r,n.push(f)):Array.isArray(f)&&f.forEach(p=>{bt(p)&&(p.parent=r,n.push(p))}))}return null}function Un(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 bt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function Wn(e,t){return(e.type==="Identifier"||e.type==="JSXIdentifier")&&e.type===t.type&&e.name===t.name&&e.range[0]===t.range[0]&&e.range[1]===t.range[1]}function wt(e,t){return e.range[0]<=t.range[0]&&e.range[1]>=t.range[1]}function Vn(e){return!1}var ie=require("@typescript-eslint/utils");var Y=Pe(require("typescript")),Hn=ie.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Rt="improved-no-unnecessary-condition",Yn=j({}),zn=["string","number","bigint","boolean","symbol","undefined","object","function","never"],Bn=new Set(zn),We={name:Rt,rule:Hn({name:Rt,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:[Yn]},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 r(i){return i.type===ie.AST_NODE_TYPES.UnaryExpression&&i.operator==="typeof"}function l(i){return i.flags&Y.default.TypeFlags.Any||i.flags&Y.default.TypeFlags.Unknown?null:i.flags&Y.default.TypeFlags.StringLike?["string"]:i.flags&Y.default.TypeFlags.NumberLike?["number"]:i.flags&Y.default.TypeFlags.BigIntLike?["bigint"]:i.flags&Y.default.TypeFlags.BooleanLike?["boolean"]:i.flags&Y.default.TypeFlags.ESSymbolLike?["symbol"]:i.flags&Y.default.TypeFlags.Undefined||i.flags&Y.default.TypeFlags.Void?["undefined"]:i.flags&Y.default.TypeFlags.Null?["object"]:i.getCallSignatures().length>0?["function"]:i.flags&Y.default.TypeFlags.Object?i.getProperties().length===0?["string","number","bigint","boolean","symbol","object","function"]:["object"]:i.flags&Y.default.TypeFlags.NonPrimitive?["object"]:i.flags&Y.default.TypeFlags.Never?["never"]:null}function f(i){if(!n)return null;let o=t.esTreeNodeToTSNodeMap.get(i),a=n.getTypeAtLocation(o.expression);if(a.flags&Y.default.TypeFlags.Any||a.flags&Y.default.TypeFlags.Unknown)return null;let s=[];if(a.isUnion()){for(let g of a.types){let T=l(g);if(T)s.push(...T);else return null}return s}let c=l(a);return c?(s.push(...c),s):null}function p(i){if(!(i.operator==="==="||i.operator==="!=="))return;let a=null,s=null;if(r(i.left)?(a=i.left,s=i.right.type===ie.AST_NODE_TYPES.Literal&&typeof i.right.value=="string"?i.right.value:null):r(i.right)&&(a=i.right,s=i.left.type===ie.AST_NODE_TYPES.Literal&&typeof i.left.value=="string"?i.left.value:null),!a||!s||!qn(s,Bn))return;let c=f(a);if(!c)return;let g=i.operator==="!==",T=c.includes(s);c.length===1?T&&!g?e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:le(a,e),type:s}}):!T&&g?e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:le(a,e),type:Array.from(c)[0]}}):!T&&!g?e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:le(a,e),actualType:Se(c),conditionType:s}}):T&&g&&e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:le(a,e),actualType:Se(c),conditionType:s}}):!T&&!g?e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:le(a,e),actualType:Se(c),conditionType:s}}):!T&&g&&e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:le(a,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 qn(e,t){return t.has(e)}var Ee=require("@typescript-eslint/utils");var Kn=Ee.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),vt="no-call-with-explicit-generics",Xn=j({functions:H(F())}),Jn=Kn({name:vt,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:[Xn]},defaultOptions:[{functions:[]}],create(e,[t]){let n=new Set(t.functions);return{CallExpression(r){let{callee:l}=r;l.type===Ee.AST_NODE_TYPES.Identifier&&n.has(l.name)&&r.typeArguments&&e.report({node:r,messageId:"noExplicitGenerics",data:{functionName:l.name}})}}}}),Ve={name:vt,rule:Jn};var se=require("@typescript-eslint/utils"),Gn=se.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),kt="no-call-with-inferred-generics",Zn=Gn({name:kt,meta:{type:"problem",docs:{description:"Disable calling configured functions with infered generics"},messages:{missingGenericDeclaration:"Function '{{ functionName }}' should be called with at least {{ minGenerics }} generic(s) (ex: `fn<Generic>()`) defined",anyUsedInGenerics:"Function '{{ functionName }}' should not be called with 'any' in generics"},schema:[{type:"object",properties:{functions:{type:"array",items:{type:"object",properties:{name:{type:"string"},minGenerics:{type:"number"},allowAny:{type:"boolean"},disallowTypes:{type:"array",items:{type:"string"}}},required:["name"]}},anyAliases:{type:"array",items:{type:"string"}}},required:["functions"]}]},defaultOptions:[{functions:[]}],create(e,[t]){let n=new Map(t.functions.map(r=>[r.name,r]));return{CallExpression(r){let{callee:l}=r;if(l.type!==se.AST_NODE_TYPES.Identifier)return;let f=n.get(l.name);if(!f)return;let{minGenerics:p=1,allowAny:i,disallowTypes:o=t.disallowTypes}=f;(r.typeArguments?.params.length||0)<(p||0)&&e.report({node:r,messageId:"missingGenericDeclaration",data:{functionName:l.name,minGenerics:p||0}}),!(i&&!o)&&r.typeArguments?.params?.some(s=>!i&&s.type===se.AST_NODE_TYPES.TSAnyKeyword||o&&s.type===se.AST_NODE_TYPES.TSTypeReference&&s.typeName.type===se.AST_NODE_TYPES.Identifier&&o.includes(s.typeName.name))&&e.report({node:r,messageId:"anyUsedInGenerics",data:{functionName:l.name}})}}}}),He={name:kt,rule:Zn};var me=require("@typescript-eslint/utils"),Qn=me.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),At="no-commented-out-code",er=["function ","class ","interface ","type ","enum ","namespace ","import ","export ","const ","let ","var ","return "],tr=[") {","return;","if (","else {","for (","switch (","/>","</","},",": {"," } = ","={",/\w=("|')/,");"],nr=Qn({name:At,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 r=n.trimStart();if(n.startsWith("*")||r.startsWith("INFO:")||r.startsWith("TODO:")||r.startsWith("DOCS:")||r.startsWith("FIX:")||r.startsWith("eslint-disable")||n.includes("@deprecated")||n.includes("@example"))return!1;for(let l of er)if(r.startsWith(l))return{wrongPattern:l};for(let l of tr)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 r=e.sourceCode.getAllComments();for(let l of r)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}})}}}}}),Ye={name:At,rule:nr};var be=require("@typescript-eslint/utils"),rr=be.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ot="no-default-export",ir=rr({name:Ot,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"})}}}}),ze={name:Ot,rule:ir};var Pt=require("@typescript-eslint/utils"),sr=Pt.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Nt="no-leaked-text-in-jsx",or=[",",";","[","]","(",")"],ar=sr({name:Nt,meta:{type:"problem",docs:{description:"Prevents leaking of text in JSX that should be wrapped in an expression container"},messages:{leakedTextInJSX:'Text "{{ text }}" should be wrapped in a JSX expression container.'},schema:[],fixable:"code"},defaultOptions:[],create(e){return{JSXText(t){let n=t.value.trim();if(!n)return;let r="";or.includes(n)?r=n:n.includes("&&")?r="&&":n.includes("||")?r="||":n.endsWith("? (")&&(r="? ("),r&&e.report({node:t,messageId:"leakedTextInJSX",data:{text:r}})}}}}),Be={name:Nt,rule:ar};var ee=require("@typescript-eslint/utils"),lr=ee.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Dt="no-non-camel-case-functions",cr=/^[a-z][a-zA-Z0-9]*$/;function _t(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 pr=lr({name:Dt,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&&!cr.test(t.id.name)){let n=t.returnType?.typeAnnotation;if(n&&(n.type===ee.AST_NODE_TYPES.TSTypeReference?_t(n):n.type===ee.AST_NODE_TYPES.TSUnionType&&n.types.some(l=>l.type===ee.AST_NODE_TYPES.TSTypeReference&&_t(l))))return;e.report({node:t.id,messageId:"nonCamelCaseFunction",data:{functionName:t.id.name}})}}}}}),qe={name:Dt,rule:pr};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*Ke(e){yield e,e.parent&&(yield*Ke(e.parent))}var ur=M.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Lt="no-optional-root-props",fr=ur({name:Lt,meta:{type:"problem",docs:{description:"Prevents usage of optional properties at the root of a type if that type is a local type alias or interface referenced only once"},messages:{optionalNotAllowed:'Optional property "{{ propertyName }}" is not allowed on a local type used only once. Use `prop: undefined | ...` instead.',suggestion:"Use `prop: undefined | ...` instead."},hasSuggestions:!0,schema:[]},defaultOptions:[],create(e){function t(r){let f=e.sourceCode.getDeclaredVariables(r)[0];if(!f||f.references.length!==1)return!1;let p=f.references[0];if(!p)return!1;for(let i of Ke(p.identifier)){if("returnType"in i||i.type===M.TSESTree.AST_NODE_TYPES.ExportNamedDeclaration)return!1;let o=i.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 s=ce(o.parent.parent,M.TSESTree.AST_NODE_TYPES.VariableDeclaration,4);if(!s)return!1;let c=xe(s,e.sourceCode);return c?!(c.parent.type===M.TSESTree.AST_NODE_TYPES.CallExpression&&c.parent.callee.type===M.TSESTree.AST_NODE_TYPES.Identifier&&c.parent.callee.name==="memo"):!1}if(i.type===M.TSESTree.AST_NODE_TYPES.AssignmentPattern)return!1;if(o.type===M.TSESTree.AST_NODE_TYPES.ArrowFunctionExpression){let a=ce(o,M.TSESTree.AST_NODE_TYPES.VariableDeclaration);return a?!!xe(a,e.sourceCode):!1}if(o.type===M.TSESTree.AST_NODE_TYPES.FunctionDeclaration)return!!xe(o,e.sourceCode)}return!1}function n(r){r.key.type!==M.TSESTree.AST_NODE_TYPES.Identifier||!r.optional||e.report({node:r.key,messageId:"optionalNotAllowed",data:{propertyName:r.key.name},suggest:[{messageId:"suggestion",fix:l=>{let f=ce(r,M.TSESTree.AST_NODE_TYPES.TSPropertySignature);if(!f)return null;let p=e.sourceCode.getText(f);return l.replaceText(f,p.replace("?:",": undefined |"))}}]})}return{TSTypeAliasDeclaration(r){if(r.typeAnnotation.type===M.TSESTree.AST_NODE_TYPES.TSTypeLiteral&&!(Ce(r)||!t(r)))for(let l of r.typeAnnotation.members)l.type===M.TSESTree.AST_NODE_TYPES.TSPropertySignature&&n(l)},TSInterfaceDeclaration(r){if(!(Ce(r)||!t(r)))for(let l of r.body.body)l.type===M.TSESTree.AST_NODE_TYPES.TSPropertySignature&&n(l)},TSTypeReference(r){if(r.typeName.type!==M.TSESTree.AST_NODE_TYPES.Identifier||r.typeName.name!=="FC"||!r.typeArguments?.params[0])return;let l=r.typeArguments.params[0];if(l.type!==M.TSESTree.AST_NODE_TYPES.TSTypeLiteral)return;let f=ce(r.parent,M.TSESTree.AST_NODE_TYPES.VariableDeclaration,4);if(!f)return;let p=xe(f,e.sourceCode);if(!(!p||p.parent.type===M.TSESTree.AST_NODE_TYPES.CallExpression&&p.parent.callee.type===M.TSESTree.AST_NODE_TYPES.Identifier&&p.parent.callee.name==="memo"))for(let o of l.members)o.type===M.TSESTree.AST_NODE_TYPES.TSPropertySignature&&n(o)}}}});function Ce(e){return e?e.parent?.type===M.TSESTree.AST_NODE_TYPES.ExportNamedDeclaration||e.parent?.type===M.TSESTree.AST_NODE_TYPES.ExportDefaultDeclaration:!1}function xe(e,t){if(Ce(e))return;let n;if(e.type===M.TSESTree.AST_NODE_TYPES.VariableDeclaration){if(e.declarations.length!==1)return;e.declarations[0].id.type===M.TSESTree.AST_NODE_TYPES.Identifier&&(n=e.declarations[0].id)}else{if(!e.id)return;n=e.id}if(!n)return;let r=t.getScope(e);e.type===M.TSESTree.AST_NODE_TYPES.FunctionDeclaration&&r.upper&&(r=r.upper);let l=r.variables.find(p=>p.identifiers.includes(n));if(!l)return;let f=l.references.filter(p=>p.identifier!==n);if(!(f.length!==1||!f[0])&&!Ce(f[0].identifier.parent.parent))return f[0].identifier}var Xe={name:Lt,rule:fr};var $t=require("@typescript-eslint/utils"),Ie=Pe(require("path"));var mr=$t.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ft="no-relative-imports",dr=j({find:F(),replacement:F()}),yr=j({aliases:H(dr),rootDir:$(F()),allowNotFoundAliases:$(oe()),_dev_simulateFileName:$(F())}),gr=mr({name:Ft,meta:{type:"problem",fixable:"code",docs:{description:"Prevent relative imports and auto-fix them using configured aliases"},messages:{noRelativeImports:"Relative imports are not allowed. Use one of the valid aliases in tsconfig.json instead.",noRelativeImportsWithAlias:'Relative imports are not allowed. Use the "{{ alias }}" alias instead.'},schema:[yr]},defaultOptions:[{aliases:[],rootDir:void 0}],create(e,[t]){let n=t._dev_simulateFileName??e.filename;function r(p){return p.startsWith(".")||p.startsWith("..")}function l(p,i){let o=Ie.default.dirname(i);return Ie.default.resolve(o,p)}function f(p){let i=t.rootDir??process.cwd(),o=Ie.default.relative(i,p);if(o.startsWith("."))return null;o.startsWith("/")||(o=`/${o}`);for(let{find:a,replacement:s}of t.aliases)if(o.startsWith(s)){let c=o.replace(s,a);return{alias:a,newPath:c}}return null}return{ImportDeclaration(p){let i=p.source.value;if(!r(i))return;let o=l(i,n),a=f(o);!a&&t.allowNotFoundAliases||e.report({node:p,messageId:a?"noRelativeImportsWithAlias":"noRelativeImports",data:{alias:a?.alias},fix:a?s=>s.replaceText(p.source,`'${a.newPath}'`):void 0})}}}}),Je={name:Ft,rule:gr};var te=require("@typescript-eslint/utils");var Ge=Pe(require("typescript")),hr=te.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),jt="no-unnecessary-casting",Tr=j({additionalCastFunctions:$(H(j({name:F(),expectedType:Te(["string","number"])})))}),Ze={name:jt,rule:hr({name:jt,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:[Tr],fixable:"code"},defaultOptions:[{}],create(e){let n=e.options[0].additionalCastFunctions||[],r=[{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(s,c){switch(s.type){case te.AST_NODE_TYPES.Literal:return c==="number"?typeof s.value=="number":typeof s.value=="string";case te.AST_NODE_TYPES.TemplateLiteral:return c==="string";case te.AST_NODE_TYPES.UnaryExpression:return c==="number"?s.operator==="+"||s.operator==="-"||s.operator==="~":!1;default:return!1}}function i(s,c){return c==="number"?!!(s.flags&Ge.TypeFlags.NumberLike):!!(s.flags&Ge.TypeFlags.StringLike)}function o(s,c){return g=>g.replaceText(s,e.sourceCode.getText(c))}function a(s){if(!f||s.arguments.length!==1)return;let c=s.arguments[0];if(!c||c.type===te.AST_NODE_TYPES.SpreadElement)return;let{callee:g}=s;if(g.type!==te.AST_NODE_TYPES.Identifier)return;let T=g.name,S=r.find(b=>b.name===T);if(!S)return;if(p(c,S.expectedType)||i(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:s,messageId:b,...y?{data:y}:{},fix:o(s,c)})}}return{CallExpression:a}}})};var L=require("@typescript-eslint/utils");var Sr=L.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function Mt(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 Ut(e,...t){for(let n of t)e.set(...n);return e}var Er=j({forceCheckOnFCPropTypesWithName:$(H(F()))}),Wt="no-unused-type-props-in-args",Qe=null,br=Sr({name:Wt,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&&!Qe&&(Qe=n.map(i=>new RegExp(i)));function r(i,o,a,s,c=!0){let g=a.name,T=e.sourceCode.getScope(o).references.find(b=>b.identifier.name===g)?.resolved,S=i&&Qe?.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(i,o,s,d.typeAnnotation,!0);return}if(d?.type===L.AST_NODE_TYPES.TSInterfaceDeclaration){l(i,o,s,d.body,!0);return}}}function l(i,o,a,s,c){if(s.type===L.AST_NODE_TYPES.TSInterfaceBody){for(let g of s.body)g.type===L.AST_NODE_TYPES.TSPropertySignature&&g.key.type===L.AST_NODE_TYPES.Identifier&&a.set(g.key.name,g);return}if(s.type===L.AST_NODE_TYPES.TSTypeLiteral){Ut(a,...Mt(s));return}if(s.type===L.AST_NODE_TYPES.TSIntersectionType){for(let g of s.types)l(i,o,a,g,!0);return}c||s.type===L.AST_NODE_TYPES.TSTypeReference&&s.typeName.type===L.AST_NODE_TYPES.Identifier&&r(i,o,s.typeName,a)}function f(i,o,a){for(let s of a)if(s.type==="ObjectPattern"&&s.typeAnnotation){let c=new Map;if(l(i,o,c,s.typeAnnotation.typeAnnotation,!1),c.size===0)continue;p(s,c)}else s.type===L.AST_NODE_TYPES.AssignmentPattern&&s.left.type===L.AST_NODE_TYPES.ObjectPattern&&f(i,o,[s.left])}function p(i,o){let a=[];if(i.properties.at(-1)?.type===L.AST_NODE_TYPES.RestElement)return;for(let T of i.properties)T.type===L.AST_NODE_TYPES.Property&&T.key.type===L.AST_NODE_TYPES.Identifier&&a.push(T.key.name);let c=[],g=[];for(let[T,S]of o)a.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=i.properties.at(-1),y=g.join(", ");return b?b?.type===L.AST_NODE_TYPES.RestElement?null:d.insertTextAfter(b,`, ${y}`):d.insertTextBeforeRange([i.range[0]+1,i.range[1]],`${y}`)}:void 0})}return{VariableDeclaration(i){let o=i.declarations[0];if(!o)return;let a=new Map,s=o.id.type===L.AST_NODE_TYPES.Identifier&&o.id.typeAnnotation?.typeAnnotation.type===L.AST_NODE_TYPES.TSTypeReference&&o.id.typeAnnotation.typeAnnotation.typeName.type===L.AST_NODE_TYPES.Identifier&&o.id.typeAnnotation.typeAnnotation.typeName.name==="FC"&&o.id.typeAnnotation.typeAnnotation.typeArguments?.params[0];if(s){if(s.type===L.AST_NODE_TYPES.TSTypeReference&&s.typeName.type===L.AST_NODE_TYPES.Identifier)r(!0,i,s.typeName,a,!1);else if(s.type===L.AST_NODE_TYPES.TSTypeLiteral)Ut(a,...Mt(s));else if(s.type===L.AST_NODE_TYPES.TSIntersectionType)for(let c of s.types)c.type===L.AST_NODE_TYPES.TSTypeReference&&c.typeName.type===L.AST_NODE_TYPES.Identifier?r(!0,i,c.typeName,a,!1):l(!0,i,a,c,!0);if(a.size!==0&&o.init?.type===L.AST_NODE_TYPES.ArrowFunctionExpression){let c=o.init.params[0];if(!c){e.report({node:o.init,messageId:"missingComponentParam"});return}c.type===L.AST_NODE_TYPES.ObjectPattern&&p(c,a)}}},FunctionDeclaration:function(i){f(!1,i,i.params)},ArrowFunctionExpression(i){f(!1,i,i.params)}}}}),et={name:Wt,rule:br};var pe=require("@typescript-eslint/utils"),xr=pe.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ht="prefer-named-functions",Vt=new Map,Cr=xr({name:Ht,meta:{hasSuggestions:!0,type:"suggestion",docs:{description:"Prevent using arrow functions when a named function can be used instead"},schema:[{type:"object",properties:{ignoreRegex:{type:"string"},disallowArrowFnWithImplicitReturns:{type:"boolean"}}}],messages:{suggestion:"Convert to named function",default:'Function {{functionName}} should be defined as a named function "function {{functionName}} () {}" instead of an arrow function',withIgnoreRegex:'Function {{functionName}} should be defined as a named function "function {{functionName}} () {}", if not possible to use `function` you can also use a name that matches the rule ignore regex'}},defaultOptions:[{}],create(e,[t]){let n=null;if(t.ignoreRegex){let r=Vt.get(t.ignoreRegex);r?n=r:(n=new RegExp(t.ignoreRegex),Vt.set(t.ignoreRegex,n))}return{VariableDeclarator(r){if(r.init&&r.init.type===pe.AST_NODE_TYPES.ArrowFunctionExpression&&r.id.type===pe.AST_NODE_TYPES.Identifier){let l=r.id.name;if(r.id.typeAnnotation||n&&n.test(l)||!t.disallowArrowFnWithImplicitReturns&&r.init.body.type!==pe.AST_NODE_TYPES.BlockStatement)return;let f=r.parent,p=r.init.params,i=r.init.body,o=r.init;e.report({node:r.id,messageId:n?"withIgnoreRegex":"default",data:{functionName:l,ignoreRegex:t.ignoreRegex},suggest:[{messageId:"suggestion",fix:a=>a.replaceText(f,`${o.async?"async ":""}function ${l}(${p.map(s=>e.sourceCode.getText(s)).join(", ")||""}) ${e.sourceCode.getText(i)}`)}]})}}}}}),tt={name:Ht,rule:Cr};var U=require("@typescript-eslint/utils");var Ir=U.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),zt="prefer-single-line-if",wr=j({maxLineLength:$(J()),maxNonSimpleConditionLength:$(J())}),Rr=Ir({name:zt,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:[wr]},defaultOptions:[{}],create(e,[t]){let n=e.sourceCode;return{IfStatement(r){if(r.consequent.type!==U.AST_NODE_TYPES.BlockStatement||r.loc.start.line===r.loc.end.line||n.getCommentsInside(r.consequent).length>0||r.alternate||r.consequent.body.length!==1)return;let f=r.consequent.body[0];if(f.type===U.AST_NODE_TYPES.ReturnStatement){if(!qt(f))return}else if(!(f.type===U.AST_NODE_TYPES.ContinueStatement||f.type===U.AST_NODE_TYPES.BreakStatement))return;if(r.test.type===U.AST_NODE_TYPES.LogicalExpression||r.test.type===U.AST_NODE_TYPES.ConditionalExpression)return;let p;if(t.maxNonSimpleConditionLength){let c=Yt(r.test);if(!c&&r.test.type===U.AST_NODE_TYPES.UnaryExpression&&r.test.operator==="!"){let g=r.test.argument;Yt(g)&&(c=!0)}if(c&&(p=n.getText(r.test),p.length>t.maxNonSimpleConditionLength))return}p||(p=n.getText(r.test));let i=n.getText(f);if(p.includes(`
|
|
15
|
-
`))return;let o=n.getTokenAfter(r);if(o&&o.type===U.AST_TOKEN_TYPES.Punctuator&&o.value==="}"){let c=n.getTokenAfter(o);if(c&&c.type===U.AST_TOKEN_TYPES.Keyword&&(c.value==="else"||c.value==="catch"))return}let a=vr(n,r),s=`if (${p}) ${i}`;t.maxLineLength&&s.length+a.length>t.maxLineLength||e.report({node:r,messageId:"noSingleLineCurly",fix:c=>c.replaceText(r,s)})}}}});function Yt(e){return e.type===U.AST_NODE_TYPES.CallExpression||e.type===U.AST_NODE_TYPES.BinaryExpression||e.type===U.AST_NODE_TYPES.MemberExpression&&Bt(e)}function Bt(e){return e.object.type===U.AST_NODE_TYPES.MemberExpression?Bt(e.object):e.object.type!==U.AST_NODE_TYPES.Identifier}function vr(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}function qt(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?qt(t):!1}var nt={name:zt,rule:Rr};var z=require("@typescript-eslint/utils");var kr=z.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Kt="react-compiler-migration",Ar=j({disallowHooks:$(H(j({name:F(),replacement:F()}))),disallowMethods:$(H(j({name:F(),replacement:$(F()),requireTrueProp:$(F())})))}),Or=/eslint +react-compiler\/react-compiler: +\["error/;function Pr(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 Nr=kr({name:Kt,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:[Ar]},defaultOptions:[{}],create(e,[t]){let n=!1;for(let r of e.sourceCode.getAllComments())if(Or.test(r.value)){n=!0;break}return n?{CallExpression(r){if(t.disallowHooks?.length){let l=null,f=null;if(r.callee.type===z.AST_NODE_TYPES.Identifier?(l=r.callee.name,f=r.callee):r.callee.type===z.AST_NODE_TYPES.MemberExpression&&r.callee.property.type===z.AST_NODE_TYPES.Identifier&&(l=r.callee.property.name,f=r.callee.property),l){let p=t.disallowHooks.find(i=>i.name===l);p&&f&&e.report({node:r,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:p.name,replacement:p.replacement},suggest:[{messageId:"replace",data:{replacement:p.replacement},fix:i=>i.replaceText(f,p.replacement)}]})}}if(t.disallowMethods?.length&&Pr(r.callee)){for(let l of r.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,i=t.disallowMethods.find(o=>o.name===p);if(i){if(i.requireTrueProp){let o=i.requireTrueProp,a=!1;for(let s of l.properties)if(s.type===z.AST_NODE_TYPES.Property&&s.key.type===z.AST_NODE_TYPES.Identifier&&s.key.name===o&&s.value.type===z.AST_NODE_TYPES.Literal&&s.value.value===!0){a=!0;break}if(!a){e.report({node:f,messageId:"disallowedMethodWithMissingRequireTrueProp",data:{method:i.name,requireTrueProp:o}});continue}}i.replacement&&e.report({node:f,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:i.name,replacement:i.replacement},suggest:[{messageId:"replace",data:{replacement:i.replacement},fix:o=>o.replaceText(f.key,i.replacement)}]})}}}}}}:{}}}),rt={name:Kt,rule:Nr};var we=require("@typescript-eslint/utils"),_r=we.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Xt="require-description",Dr=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,Lr=/^eslint-disable-(next-)?line$/u,$r=_r({name:Xt,meta:{type:"problem",docs:{description:"Require descriptions for eslint directives."},messages:{missingDescription:"Unexpected undescribed directive comment. Include descriptions to explain why the comment is necessary."},schema:[{type:"object",properties:{ignore:{type:"array",items:{type:"string",enum:["eslint","eslint-disable","eslint-disable-line","eslint-disable-next-line","eslint-enable","eslint-env","exported","global","globals"]},additionalItems:!1,uniqueItems:!0}},additionalProperties:!1}]},defaultOptions:[{ignore:[]}],create(e,[t]){let n=e.sourceCode,r=new Set(t.ignore||[]);return{Program(){for(let l of n.getAllComments()){let f=Fr(l);f!=null&&(r.has(f.kind)||f.description||e.report({loc:Mr(l.loc),messageId:"missingDescription"}))}}}}}),Jt={name:Xt,rule:$r};function Fr(e){let{text:t,description:n}=jr(e.value);if(!t)return null;let r=Dr.exec(t);if(!r)return null;let l=r[1];if(!l)return null;let f=Lr.test(l);if(e.type===we.TSESTree.AST_TOKEN_TYPES.Line&&!f||f&&e.loc.start.line!==e.loc.end.line)return null;let p=t.slice(r.index+l.length);return{kind:l,value:p.trim(),description:n}}function jr(e){let t=e.split(/\s-{2,}\s/u);return{text:t[0]?.trim(),description:t.length>1?t[1]?.trim()??null:null}}function Mr(e){return{start:{line:e.start.line,column:-1},end:e.end}}function Qt(e){return/^use[A-Z0-9]/.test(e)}function Re(e){return e.type==="Identifier"?Qt(e.name):e.type==="MemberExpression"&&!e.computed&&Re(e.property)?e.object.type==="Identifier":!1}function en(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function tn(e,t){return e.name===t||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===t}function nn(e){return!!(e.parent&&e.parent.callee&&tn(e.parent.callee,"forwardRef"))}function rn(e){return!!(e.parent&&e.parent.callee&&tn(e.parent.callee,"memo"))}function it(e){for(;e;){let t=on(e);if(t&&(en(t)||Re(t))||nn(e)||rn(e))return!0;e=e.parent}return!1}function Gt(e){return!1}function st(e){return!1}var Ur=/eslint +react-compiler\/react-compiler: +\["error/,sn={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 o of e.sourceCode.getAllComments())if(Ur.test(o.value))return{CallExpression(a){let s=null;a.callee.name==="useMemo"?s="useMemo":a.callee.name==="useCallback"&&(s="useCallback"),s&&e.report({node:a,message:`"${s}" is not necessary when using React Compiler.`})}}}let t=typeof e.getSource=="function"?o=>t(o):o=>e.sourceCode.getText(o),n=typeof e.getScope=="function"?()=>n():o=>e.sourceCode.getScope(o),r=null,l=[],f=[],p=new WeakSet;function i(o){for(let a of o.references){let s=a.identifier.parent;if(s.type==="VariableDeclarator"&&s.init&&s.init.type==="CallExpression"&&s.init.callee&&Gt(s.init.callee))for(let c of a.resolved.references)c!==a&&p.add(c.identifier)}}return{onCodePathSegmentStart:o=>f.push(o),onCodePathSegmentEnd:()=>f.pop(),onCodePathStart:()=>l.push(new Map),onCodePathEnd(o,a){let s=l.pop();if(s.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(o.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(o.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(o.initialSegment),b=on(a),y=it(a),N=b?en(b)||Re(b):nn(a)||rn(a),v=1/0;for(let h of o.finalSegments){if(!h.reachable)continue;let w=S(h);w<v&&(v=w)}for(let[h,w]of s){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&&!st(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(a.async&&e.report({node:A,message:`React Hook "${t(A)}" cannot be called in an async function.`}),!D&&k!==d&&!st(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(a.parent&&(a.parent.type==="MethodDefinition"||a.parent.type==="ClassProperty")&&a.parent.value===a){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(a.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&&!st(A)){if(a.parent.type==="CallExpression"&&a.parent.callee.type==="Identifier"&&a.parent.callee.name==="useCallback"){let X=a.parent;if(X.parent.type==="VariableDeclarator"&&Qt(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(o){if(Re(o.callee)){let a=Zt(l),s=Zt(f),c=a.get(s);c||(c=[],a.set(s,c)),c.push(o.callee)}o.callee.type==="Identifier"&&(o.callee.name==="useEffect"||Gt(o.callee))&&o.arguments.length>0&&(r=o)},Identifier(o){r==null&&p.has(o)&&o.parent.type!=="CallExpression"&&e.report({node:o,message:`\`${t(o)}\` 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"(o){o===r&&(r=null)},FunctionDeclaration(o){it(o)&&i(n(o))},ArrowFunctionExpression(o){it(o)&&i(n(o))}}}};function on(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 an={[et.name]:et.rule,[Ye.name]:Ye.rule,[He.name]:He.rule,"rules-of-hooks":sn,"exhaustive-deps":xt,"require-description":Jt.rule,[ze.name]:ze.rule,[qe.name]:qe.rule,[tt.name]:tt.rule,[Le.name]:Le.rule,[Ve.name]:Ve.rule,[Je.name]:Je.rule,[nt.name]:nt.rule,[Xe.name]:Xe.rule,[Be.name]:Be.rule,[Fe.name]:Fe.rule,[rt.name]:rt.rule,[De.name]:De.rule,[We.name]:We.rule,[Ze.name]:Ze.rule};var Wr={rules:an};0&&(module.exports={extendedLintPlugin});
|
|
14
|
+
Learn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching`});let R=a.acquire(h),O=new Set,$=null;{let f=R.upper;for(;f&&(O.add(f),f.type!=="function");)f=f.upper;if(!f)return;$=f}let k=Array.isArray;function W(f){if(!k(f.defs))return!1;let m=f.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&&(Ve($.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:A}=I;if(A==="useRef"&&C.type==="Identifier")return!0;if(Bn(I)&&C.type==="Identifier"){for(let P of f.references)P!==C&&y.add(P.identifier);return!0}else if(A==="useState"||A==="useReducer"){if(C.type==="ArrayPattern"&&C.elements.length===2&&k(f.identifiers)){if(C.elements[1]===f.identifiers[0]){if(A==="useState"){let P=f.references,K=0;for(let Q=0;Q<P.length;Q++){if(P[Q].isWrite()&&K++,K>1)return!1;l.set(P[Q].identifier,C.elements[0])}}return!0}else if(C.elements[0]===f.identifiers[0]){if(A==="useState"){let P=f.references;for(let K=0;K<P.length;K++)s.add(P[K].identifier)}return!1}}}else if(A==="useTransition"&&C.type==="ArrayPattern"&&C.elements.length===2&&Array.isArray(f.identifiers)&&C.elements[1]===f.identifiers[0])return!0;return!1}function Z(f){if(!k(f.defs))return!1;let m=f.defs[0];if(m==null||m.node==null||m.node.id==null)return!1;let E=m.node,x=$.childScopes,I=null,C;for(C=0;C<x.length;C++){let A=x[C],P=A.block;if(E.type==="FunctionDeclaration"&&P===E||E.type==="VariableDeclarator"&&P.parent===E){I=A;break}}if(I==null)return!1;for(C=0;C<I.through.length;C++){let A=I.through[C];if(A.resolved!=null&&O.has(A.resolved.scope)&&!lt(A.resolved))return!1}return!0}let lt=S(W,p),fn=S(Z,g),ct=new Map;function mn(f){let m=f.from,E=!1;for(;m.block!==h;)m.type==="function"&&(E=m.block.parent!=null&&m.block.parent.type==="ReturnStatement"),m=m.upper;return E}let q=new Map,Oe=new Map;ut(R);function ut(f){for(let m of f.references){if(!m.resolved||!O.has(m.resolved.scope))continue;let E=Ve(h,m.identifier),x=wt(E),I=ee(x,Oe);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"&&mn(m)&&ct.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===h.parent)&&C.type!=="TypeParameter")if(q.has(I))q.get(I).references.push(m);else{let A=m.resolved,P=lt(A)||fn(A);q.set(I,{isStable:P,references:[m]})}}for(let m of f.childScopes)ut(m)}ct.forEach(({reference:f,dependencyNode:m},E)=>{let x=f.resolved.references,I=!1;for(let C=0;C<x.length;C++){let{identifier:A}=x[C],{parent:P}=A;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||i({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 ke=new Set;function dn(f,m){ke.has(m)||(ke.add(m),i({node:f,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 ye=new Set;if(q.forEach(({isStable:f,references:m},E)=>{f&&ye.add(E),m.forEach(x=>{x.writeExpr&&dn(x.writeExpr,E)})}),ke.size>0)return;if(!_){let f=null;if(q.forEach(({isStable:m,references:E},x)=>{f||E.forEach(I=>{if(f)return;let C=I.identifier;if(!l.has(C))return;let P=I.from;for(;P.type!=="function";)P=P.upper;P.block===h&&(f=x)})}),f){let{suggestedDependencies:m}=Me({dependencies:q,declaredDependencies:[],stableDependencies:ye,externalDependencies:new Set,isEffect:!0});i({node:v,message:`React Hook ${T} contains a call to '${f}'. Without a list of dependencies, this can lead to an infinite chain of updates. To fix this, pass [`+m.join(", ")+`] as a second argument to the ${T} Hook.`,suggest:[{desc:`Add dependencies array: [${m.join(", ")}]`,fix(E){return E.insertTextAfter(h,`, [${m.join(", ")}]`)}}]})}return}let fe=[],me=new Set;_.type!=="ArrayExpression"?i({node:_,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.`}):_.elements.forEach(f=>{if(f===null)return;if(f.type==="SpreadElement"){i({node:f,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}y.has(f)&&i({node:f,message:`Functions returned from \`useEffectEvent\` must not be included in the dependency array. Remove \`${n(f)}\` from the list.`,suggest:[{desc:`Remove the dependency \`${n(f)}\``,fix(I){return I.removeRange(f.range)}}]});let m;try{m=ee(f,Oe)}catch(I){if(/Unsupported node type/.test(I.message)){f.type==="Literal"?q.has(f.value)?i({node:f,message:`The ${f.raw} literal is not a valid dependency because it never changes. Did you mean to include ${f.value} in the array instead?`}):i({node:f,message:`The ${f.raw} literal is not a valid dependency because it never changes. You can safely remove it.`}):i({node:f,message:`React Hook ${n(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=f;for(;E.type==="MemberExpression"||E.type==="OptionalMemberExpression"||E.type==="ChainExpression";)E=E.object||E.expression.object;let x=!$.through.some(I=>I.identifier===E);fe.push({key:m,node:f}),x||me.add(m)});let{suggestedDependencies:yn,unnecessaryDependencies:ge,missingDependencies:re,duplicateDependencies:pt}=Me({dependencies:q,declaredDependencies:fe,stableDependencies:ye,externalDependencies:me,isEffect:w}),Se=yn;if(pt.size+re.size+ge.size===0){if(t)return;Wn({declaredDependencies:fe,declaredDependenciesNode:_,componentScope:$,scope:R}).forEach(({construction:m,isUsedOutsideOfHook:E,depType:x})=>{let I=x==="function"?"useCallback":"useMemo",C=x==="function"?"definition":"initialization",A=`wrap the ${C} of '${m.name.name}' in its own ${I}() Hook.`,P=E?`To fix this, ${A}`:`Move it inside the ${T} callback. Alternatively, ${A}`,K=x==="conditional"||x==="logical expression"?"could make":"makes",Q=`The '${m.name.name}' ${x} ${K} the dependencies of ${T} Hook (at line ${_.loc.start.line}) change on every render. ${P}`,ft;E&&m.type==="Variable"&&x==="function"&&(ft=[{desc:`Wrap the ${C} of '${m.name.name}' in its own ${I}() Hook.`,fix(mt){let[Sn,hn]=I==="useMemo"?["useMemo(() => { return ","; })"]:["useCallback(",")"];return[mt.insertTextBefore(m.node.init,Sn),mt.insertTextAfter(m.node.init,hn)]}}]),i({node:m.node,message:Q,suggest:ft})});return}!w&&re.size>0&&(Se=Me({dependencies:q,declaredDependencies:[],stableDependencies:ye,externalDependencies:me,isEffect:w}).suggestedDependencies);function gn(){if(fe.length===0)return!0;let f=fe.map(E=>E.key),m=f.slice().sort();return f.join(",")===m.join(",")}gn()&&Se.sort();function Ae(f){let m=f.split("."),E="";for(let x=0;x<m.length;x++){if(x!==0){let I=m.slice(0,x+1).join("."),C=Oe.get(I)===!0;E+=C?"?.":"."}E+=m[x]}return E}function Pe(f,m,E,x){return f.size===0?null:(f.size>1?"":m+" ")+E+" "+(f.size>1?"dependencies":"dependency")+": "+Yn(Array.from(f).sort().map(I=>"'"+Ae(I)+"'"))+`. Either ${x} ${f.size>1?"them":"it"} or remove the dependency array.`}let J="";if(ge.size>0){let f=null;if(Array.from(ge.keys()).forEach(m=>{f===null&&m.endsWith(".current")&&(f=m)}),f!==null)J=` Mutable values like '${f}' aren't valid dependencies because mutating them doesn't re-render the component.`;else if(me.size>0){let m=Array.from(me)[0];R.set.has(m)||(J=` Outer scope values like '${m}' aren't valid dependencies because mutating them doesn't re-render the component.`)}}if(!J&&re.has("props")){let f=q.get("props");if(f==null)return;let m=f.references;if(!Array.isArray(m))return;let E=!0;for(let x=0;x<m.length;x++){let I=m[x],C=Ve($.block,I.identifier);if(!C){E=!1;break}let A=C.parent;if(A==null){E=!1;break}if(A.type!=="MemberExpression"&&A.type!=="OptionalMemberExpression"){E=!1;break}}E&&(J=` However, 'props' will change when *any* prop changes, so the preferred fix is to destructure the 'props' object outside of the ${T} call and refer to those specific props inside ${n(v)}.`)}if(!J&&re.size>0){let f=null;re.forEach(m=>{if(f)return;let E=$.set.get(m),x=q.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,A;for(let P=0;P<x.references.length;P++)if(A=x.references[P].identifier,A!=null&&A.parent!=null&&(A.parent.type==="CallExpression"||A.parent.type==="OptionalCallExpression")&&A.parent.callee===A){C=!0;break}C&&(f=m)}),f!==null&&(J=` If '${f}' changes too often, find the parent component that defines it and wrap that definition in useCallback.`)}if(!J&&re.size>0){let f=null;if(re.forEach(m=>{if(f!==null)return;let x=q.get(m).references,I,C;for(let A=0;A<x.length;A++){for(I=x[A].identifier,C=I.parent;C!=null&&C!==$.block;){if(C.type==="CallExpression"){let P=l.get(C.callee);if(P!=null){if(P.name===m)f={missingDep:m,setter:C.callee.name,form:"updater"};else if(s.has(I))f={missingDep:m,setter:C.callee.name,form:"reducer"};else{let K=x[A].resolved;if(K!=null){let Q=K.defs[0];Q!=null&&Q.type==="Parameter"&&(f={missingDep:m,setter:C.callee.name,form:"inlineReducer"})}}break}}C=C.parent}if(f!==null)break}}),f!==null)switch(f.form){case"reducer":J=` You can also replace multiple useState variables with useReducer if '${f.setter}' needs the current value of '${f.missingDep}'.`;break;case"inlineReducer":J=` If '${f.setter}' needs the current value of '${f.missingDep}', you can also switch to useReducer instead of useState and read '${f.missingDep}' in the reducer.`;break;case"updater":J=` You can also do a functional update '${f.setter}(${f.missingDep.slice(0,1)} => ...)' if you only need '${f.missingDep}' in the '${f.setter}' call.`;break;default:throw new Error("Unknown case.")}}i({node:_,message:`React Hook ${n(v)} has `+(Pe(re,"a","missing","include")||Pe(ge,"an","unnecessary","exclude")||Pe(pt,"a","duplicate","omit"))+J,suggest:[{desc:`Update the dependencies array to be: [${Se.map(Ae).join(", ")}]`,fix(f){return f.replaceText(_,`[${Se.map(Ae).join(", ")}]`)}}]})}function b(h){let _=Hn(h.callee,c);if(_===-1)return;let v=h.arguments[_],T=h.callee,w=Rt(T).name,R=h.arguments[_+1],O=/Effect($|[^a-z])/g.test(w);if(!v){i({node:T,message:`React Hook ${w} requires an effect callback. Did you forget to pass a callback to the hook?`});return}if(!(t&&!O)){if(!R&&!O){(w==="useMemo"||w==="useCallback")&&i({node:T,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,T,w,O);return;case"Identifier":if(!R||R.elements&&R.elements.some(W=>W&&W.type==="Identifier"&&W.name===v.name))return;let $=r(h).set.get(v.name);if($==null||$.defs==null)return;let k=$.defs[0];if(!k||!k.node||k.type!=="Variable"&&k.type!=="FunctionName")break;switch(k.node.type){case"FunctionDeclaration":d(k.node,R,T,w,O);return;case"VariableDeclarator":let W=k.node.init;if(!W)break;switch(W.type){case"ArrowFunctionExpression":case"FunctionExpression":d(W,R,T,w,O);return}break}break;default:i({node:T,message:`React Hook ${w} received a function whose dependencies are unknown. Pass an inline function instead.`});return}i({node:T,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 h of e.sourceCode.getAllComments())if(Vn.test(h.value))return t=!0,{CallExpression:_=>b(_,!0)}}return{CallExpression:h=>b(h)}}};function Me({dependencies:e,declaredDependencies:t,stableDependencies:n,externalDependencies:r,isEffect:o}){let u=c();function c(){return{isUsed:!1,isSatisfiedRecursively:!1,isSubtreeUsed:!1,children:new Map}}e.forEach((d,b)=>{let h=i(u,b);h.isUsed=!0,a(u,b,_=>{_.isSubtreeUsed=!0})}),t.forEach(({key:d})=>{let b=i(u,d);b.isSatisfiedRecursively=!0}),n.forEach(d=>{let b=i(u,d);b.isSatisfiedRecursively=!0});function i(d,b){let h=b.split("."),_=d;for(let v of h){let T=_.children.get(v);T||(T=c(),_.children.set(v,T)),_=T}return _}function a(d,b,h){let _=b.split("."),v=d;for(let T of _){let w=v.children.get(T);if(!w)return;h(w),v=w}}let l=new Set,s=new Set;p(u,l,s,d=>d);function p(d,b,h,_){d.children.forEach((v,T)=>{let w=_(T);if(v.isSatisfiedRecursively){v.isSubtreeUsed&&h.add(w);return}if(v.isUsed){b.add(w);return}p(v,b,h,R=>w+"."+R)})}let g=[],y=new Set,S=new Set;return t.forEach(({key:d})=>{s.has(d)?g.indexOf(d)===-1?g.push(d):S.add(d):y.add(d)}),l.forEach(d=>{g.push(d)}),{suggestedDependencies:g,unnecessaryDependencies:y,duplicateDependencies:S,missingDependencies:l}}function ie(e){switch(e.type){case"ObjectExpression":return"object";case"ArrayExpression":return"array";case"ArrowFunctionExpression":case"FunctionExpression":return"function";case"ClassExpression":return"class";case"ConditionalExpression":return ie(e.consequent)!=null||ie(e.alternate)!=null?"conditional":null;case"LogicalExpression":return ie(e.left)!=null||ie(e.right)!=null?"logical expression":null;case"JSXFragment":return"JSX fragment";case"JSXElement":return"JSX element";case"AssignmentExpression":return ie(e.right)!=null?"assignment expression":null;case"NewExpression":return"object construction";case"Literal":return e.value instanceof RegExp?"regular expression":null;case"TypeCastExpression":return ie(e.expression);case"TSAsExpression":return ie(e.expression)}return null}function Wn({declaredDependencies:e,declaredDependenciesNode:t,componentScope:n,scope:r}){let o=e.map(({key:c})=>{let i=n.variables.find(l=>l.name===c);if(i==null)return null;let a=i.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 l=ie(a.node.init);if(l!=null)return[i,l]}return a.type==="FunctionName"&&a.node.type==="FunctionDeclaration"?[i,"function"]:a.type==="ClassName"&&a.node.type==="ClassDeclaration"?[i,"class"]:null}).filter(Boolean);function u(c){let i=!1;for(let a=0;a<c.references.length;a++){let l=c.references[a];if(l.writeExpr){if(i)return!0;i=!0;continue}let s=l.from;for(;s!==r&&s!=null;)s=s.upper;if(s!==r&&!vt(t,l.identifier))return!0}return!1}return o.map(([c,i])=>({construction:c.defs[0],depType:i,isUsedOutsideOfHook:u(c)}))}function wt(e){return(e.parent.type==="MemberExpression"||e.parent.type==="OptionalMemberExpression")&&e.parent.object===e&&e.parent.property.name!=="current"&&!e.parent.computed&&!(e.parent.parent!=null&&(e.parent.parent.type==="CallExpression"||e.parent.parent.type==="OptionalCallExpression")&&e.parent.parent.callee===e.parent)?wt(e.parent):e.type==="MemberExpression"&&e.parent&&e.parent.type==="AssignmentExpression"&&e.parent.left===e?e.object:e}function Ue(e,t,n){t&&(e.optional?t.has(n)||t.set(n,!0):t.has(n)||t.set(n,!1))}function ee(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=ee(e.object,t),r=ee(e.property,null),o=`${n}.${r}`;return Ue(e,t,o),o}else if(e.type==="OptionalMemberExpression"&&!e.computed){let n=ee(e.object,t),r=ee(e.property,null),o=`${n}.${r}`;return Ue(e,t,o),o}else if(e.type==="ChainExpression"&&!e.computed){let n=e.expression;if(n.type==="CallExpression")throw new Error(`Unsupported node type: ${n.type}`);let r=ee(n.object,t),o=ee(n.property,null),u=`${r}.${o}`;return Ue(n,t,u),u}else throw new Error(`Unsupported node type: ${e.type}`)}function Rt(e,t){return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.object.name==="React"&&e.property.type==="Identifier"&&!e.computed?e.property:e}function Hn(e,t){let n=Rt(e);if(n.type!=="Identifier")return-1;switch(n.name){case"useEffect":case"useLayoutEffect":case"useCallback":case"useMemo":return 0;case"useImperativeHandle":return 1;default:if(n===e&&t&&t.additionalHooks){let r;try{r=ee(n,null)}catch(o){if(/Unsupported node type/.test(o.message))return 0;throw o}return t.additionalHooks.test(r)?0:-1}else return-1}}function Ve(e,t){let n=[e],r=null;for(;n.length;){if(r=n.shift(),zn(r,t))return r;if(vt(r,t))for(let[o,u]of Object.entries(r))o!=="parent"&&(Ct(u)?(u.parent=r,n.push(u)):Array.isArray(u)&&u.forEach(c=>{Ct(c)&&(c.parent=r,n.push(c))}))}return null}function Yn(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 Ct(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function zn(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 vt(e,t){return e.range[0]<=t.range[0]&&e.range[1]>=t.range[1]}function Bn(e){return!1}var se=require("@typescript-eslint/utils");var z=Ne(require("typescript")),qn=se.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ot="improved-no-unnecessary-condition",Kn=L({}),Xn=["string","number","bigint","boolean","symbol","undefined","object","function","never"],Jn=new Set(Xn),We={name:Ot,rule:qn({name:Ot,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:[Kn]},defaultOptions:[{}],create(e){let t=se.ESLintUtils.getParserServices(e,!0),n=t.program?.getTypeChecker();if(!n||!t.program)throw new Error("TypeScript services or program not available");function r(i){return i.type===se.AST_NODE_TYPES.UnaryExpression&&i.operator==="typeof"}function o(i){return i.flags&z.default.TypeFlags.Any||i.flags&z.default.TypeFlags.Unknown?null:i.flags&z.default.TypeFlags.StringLike?["string"]:i.flags&z.default.TypeFlags.NumberLike?["number"]:i.flags&z.default.TypeFlags.BigIntLike?["bigint"]:i.flags&z.default.TypeFlags.BooleanLike?["boolean"]:i.flags&z.default.TypeFlags.ESSymbolLike?["symbol"]:i.flags&z.default.TypeFlags.Undefined||i.flags&z.default.TypeFlags.Void?["undefined"]:i.flags&z.default.TypeFlags.Null?["object"]:i.getCallSignatures().length>0?["function"]:i.flags&z.default.TypeFlags.Object?i.getProperties().length===0?["string","number","bigint","boolean","symbol","object","function"]:["object"]:i.flags&z.default.TypeFlags.NonPrimitive?["object"]:i.flags&z.default.TypeFlags.Never?["never"]:null}function u(i){if(!n)return null;let a=t.esTreeNodeToTSNodeMap.get(i),l=n.getTypeAtLocation(a.expression);if(l.flags&z.default.TypeFlags.Any||l.flags&z.default.TypeFlags.Unknown)return null;let s=[];if(l.isUnion()){for(let g of l.types){let y=o(g);if(y)s.push(...y);else return null}return s}let p=o(l);return p?(s.push(...p),s):null}function c(i){if(!(i.operator==="==="||i.operator==="!=="))return;let l=null,s=null;if(r(i.left)?(l=i.left,s=i.right.type===se.AST_NODE_TYPES.Literal&&typeof i.right.value=="string"?i.right.value:null):r(i.right)&&(l=i.right,s=i.left.type===se.AST_NODE_TYPES.Literal&&typeof i.left.value=="string"?i.left.value:null),!l||!s||!Gn(s,Jn))return;let p=u(l);if(!p)return;let g=i.operator==="!==",y=p.includes(s);p.length===1?y&&!g?e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:ce(l,e),type:s}}):!y&&g?e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:ce(l,e),type:Array.from(p)[0]}}):!y&&!g?e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:ce(l,e),actualType:Ee(p),conditionType:s}}):y&&g&&e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:ce(l,e),actualType:Ee(p),conditionType:s}}):!y&&!g?e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:ce(l,e),actualType:Ee(p),conditionType:s}}):!y&&g&&e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:ce(l,e),type:Ee(p)}})}return{BinaryExpression:c}}})};function Ee(e){return Array.from(new Set(e)).join(" | ")||"never"}function ce(e,t){let n=e.argument;return n.type===se.AST_NODE_TYPES.Identifier?n.name:t.sourceCode.getText(n)}function Gn(e,t){return t.has(e)}var be=require("@typescript-eslint/utils");var Zn=be.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),kt="no-call-with-explicit-generics",Qn=L({functions:H(F())}),er=Zn({name:kt,meta:{type:"problem",docs:{description:"Enforce calling configured functions with inferred generics only"},messages:{noExplicitGenerics:"Function '{{ functionName }}' should be called with inferred generics (remove the explicit type parameters)"},schema:[Qn]},defaultOptions:[{functions:[]}],create(e,[t]){let n=new Set(t.functions);return{CallExpression(r){let{callee:o}=r;o.type===be.AST_NODE_TYPES.Identifier&&n.has(o.name)&&r.typeArguments&&e.report({node:r,messageId:"noExplicitGenerics",data:{functionName:o.name}})}}}}),He={name:kt,rule:er};var oe=require("@typescript-eslint/utils"),tr=oe.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),At="no-call-with-inferred-generics",nr=tr({name:At,meta:{type:"problem",docs:{description:"Disable calling configured functions with infered generics"},messages:{missingGenericDeclaration:"Function '{{ functionName }}' should be called with at least {{ minGenerics }} generic(s) (ex: `fn<Generic>()`) defined",anyUsedInGenerics:"Function '{{ functionName }}' should not be called with 'any' in generics"},schema:[{type:"object",properties:{functions:{type:"array",items:{type:"object",properties:{name:{type:"string"},minGenerics:{type:"number"},allowAny:{type:"boolean"},disallowTypes:{type:"array",items:{type:"string"}}},required:["name"]}},anyAliases:{type:"array",items:{type:"string"}}},required:["functions"]}]},defaultOptions:[{functions:[]}],create(e,[t]){let n=new Map(t.functions.map(r=>[r.name,r]));return{CallExpression(r){let{callee:o}=r;if(o.type!==oe.AST_NODE_TYPES.Identifier)return;let u=n.get(o.name);if(!u)return;let{minGenerics:c=1,allowAny:i,disallowTypes:a=t.disallowTypes}=u;(r.typeArguments?.params.length||0)<(c||0)&&e.report({node:r,messageId:"missingGenericDeclaration",data:{functionName:o.name,minGenerics:c||0}}),!(i&&!a)&&r.typeArguments?.params?.some(s=>!i&&s.type===oe.AST_NODE_TYPES.TSAnyKeyword||a&&s.type===oe.AST_NODE_TYPES.TSTypeReference&&s.typeName.type===oe.AST_NODE_TYPES.Identifier&&a.includes(s.typeName.name))&&e.report({node:r,messageId:"anyUsedInGenerics",data:{functionName:o.name}})}}}}),Ye={name:At,rule:nr};var de=require("@typescript-eslint/utils"),rr=de.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Pt="no-commented-out-code",ir=["function ","class ","interface ","type ","enum ","namespace ","import ","export ","const ","let ","var ","return "],sr=[") {","return;","if (","else {","for (","switch (","/>","</","},",": {"," } = ","={",/\w=("|')/,");"],or=rr({name:Pt,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 r=n.trimStart();if(n.startsWith("*")||r.startsWith("INFO:")||r.startsWith("TODO:")||r.startsWith("DOCS:")||r.startsWith("FIX:")||r.startsWith("eslint-disable")||n.includes("@deprecated")||n.includes("@example"))return!1;for(let o of ir)if(r.startsWith(o))return{wrongPattern:o};for(let o of sr)if(typeof o=="string"){if(n.includes(o))return{wrongPattern:o}}else if(o.test(n))return{wrongPattern:`regex(${o.toString()})`};return!1}return{Program(){let r=e.sourceCode.getAllComments();for(let o of r)if(o.type===de.TSESTree.AST_TOKEN_TYPES.Line||o.type===de.TSESTree.AST_TOKEN_TYPES.Block){let u=t(o.value);u&&e.report({node:o,messageId:"commentedOutCode",data:{wrongPattern:u.wrongPattern}})}}}}}),ze={name:Pt,rule:or};var xe=require("@typescript-eslint/utils"),ar=xe.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Nt="no-default-export",lr=ar({name:Nt,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===xe.TSESTree.AST_NODE_TYPES.Identifier&&n.exported.name==="default"&&e.report({node:t,messageId:"noDefaultExport"})}}}}),Be={name:Nt,rule:lr};var _t=require("@typescript-eslint/utils"),cr=_t.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ft="no-leaked-text-in-jsx",ur=[",",";","[","]","(",")"],pr=cr({name:Ft,meta:{type:"problem",docs:{description:"Prevents leaking of text in JSX that should be wrapped in an expression container"},messages:{leakedTextInJSX:'Text "{{ text }}" should be wrapped in a JSX expression container.'},schema:[],fixable:"code"},defaultOptions:[],create(e){return{JSXText(t){let n=t.value.trim();if(!n)return;let r="";ur.includes(n)?r=n:n.includes("&&")?r="&&":n.includes("||")?r="||":n.endsWith("? (")&&(r="? ("),r&&e.report({node:t,messageId:"leakedTextInJSX",data:{text:r}})}}}}),qe={name:Ft,rule:pr};var te=require("@typescript-eslint/utils"),fr=te.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Lt="no-non-camel-case-functions",mr=/^[a-z][a-zA-Z0-9]*$/;function Dt(e){return e.typeName.type===te.AST_NODE_TYPES.TSQualifiedName&&e.typeName.left.type===te.AST_NODE_TYPES.Identifier&&e.typeName.left.name==="JSX"&&e.typeName.right.type===te.AST_NODE_TYPES.Identifier&&e.typeName.right.name==="Element"}var dr=fr({name:Lt,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&&!mr.test(t.id.name)){let n=t.returnType?.typeAnnotation;if(n&&(n.type===te.AST_NODE_TYPES.TSTypeReference?Dt(n):n.type===te.AST_NODE_TYPES.TSUnionType&&n.types.some(o=>o.type===te.AST_NODE_TYPES.TSTypeReference&&Dt(o))))return;e.report({node:t.id,messageId:"nonCamelCaseFunction",data:{functionName:t.id.name}})}}}}}),Ke={name:Lt,rule:dr};var M=require("@typescript-eslint/utils");function ue(e,t,n=1/0){if(n!==0&&e.parent)return e.type===t?e:ue(e.parent,t,n===1/0?n:n-1)}function*Xe(e){yield e,e.parent&&(yield*Xe(e.parent))}var yr=M.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),$t="no-optional-root-props",gr=yr({name:$t,meta:{type:"problem",docs:{description:"Prevents usage of optional properties at the root of a type if that type is a local type alias or interface referenced only once"},messages:{optionalNotAllowed:'Optional property "{{ propertyName }}" is not allowed on a local type used only once. Use `prop: undefined | ...` instead.',suggestion:"Use `prop: undefined | ...` instead."},hasSuggestions:!0,schema:[]},defaultOptions:[],create(e){function t(r){let u=e.sourceCode.getDeclaredVariables(r)[0];if(!u||u.references.length!==1)return!1;let c=u.references[0];if(!c)return!1;for(let i of Xe(c.identifier)){if("returnType"in i||i.type===M.TSESTree.AST_NODE_TYPES.ExportNamedDeclaration)return!1;let a=i.parent;if(!a)return!1;if(a.type===M.TSESTree.AST_NODE_TYPES.TSTypeParameterInstantiation&&a.parent.type===M.TSESTree.AST_NODE_TYPES.TSTypeReference&&a.parent.typeName.type===M.TSESTree.AST_NODE_TYPES.Identifier&&a.parent.typeName.name==="FC"){let s=ue(a.parent.parent,M.TSESTree.AST_NODE_TYPES.VariableDeclaration,4);if(!s)return!1;let p=Ce(s,e.sourceCode);return p?!(p.parent.type===M.TSESTree.AST_NODE_TYPES.CallExpression&&p.parent.callee.type===M.TSESTree.AST_NODE_TYPES.Identifier&&p.parent.callee.name==="memo"):!1}if(i.type===M.TSESTree.AST_NODE_TYPES.AssignmentPattern)return!1;if(a.type===M.TSESTree.AST_NODE_TYPES.ArrowFunctionExpression){let l=ue(a,M.TSESTree.AST_NODE_TYPES.VariableDeclaration);return l?!!Ce(l,e.sourceCode):!1}if(a.type===M.TSESTree.AST_NODE_TYPES.FunctionDeclaration)return!!Ce(a,e.sourceCode)}return!1}function n(r){r.key.type!==M.TSESTree.AST_NODE_TYPES.Identifier||!r.optional||e.report({node:r.key,messageId:"optionalNotAllowed",data:{propertyName:r.key.name},suggest:[{messageId:"suggestion",fix:o=>{let u=ue(r,M.TSESTree.AST_NODE_TYPES.TSPropertySignature);if(!u)return null;let c=e.sourceCode.getText(u);return o.replaceText(u,c.replace("?:",": undefined |"))}}]})}return{TSTypeAliasDeclaration(r){if(r.typeAnnotation.type===M.TSESTree.AST_NODE_TYPES.TSTypeLiteral&&!(Ie(r)||!t(r)))for(let o of r.typeAnnotation.members)o.type===M.TSESTree.AST_NODE_TYPES.TSPropertySignature&&n(o)},TSInterfaceDeclaration(r){if(!(Ie(r)||!t(r)))for(let o of r.body.body)o.type===M.TSESTree.AST_NODE_TYPES.TSPropertySignature&&n(o)},TSTypeReference(r){if(r.typeName.type!==M.TSESTree.AST_NODE_TYPES.Identifier||r.typeName.name!=="FC"||!r.typeArguments?.params[0])return;let o=r.typeArguments.params[0];if(o.type!==M.TSESTree.AST_NODE_TYPES.TSTypeLiteral)return;let u=ue(r.parent,M.TSESTree.AST_NODE_TYPES.VariableDeclaration,4);if(!u)return;let c=Ce(u,e.sourceCode);if(!(!c||c.parent.type===M.TSESTree.AST_NODE_TYPES.CallExpression&&c.parent.callee.type===M.TSESTree.AST_NODE_TYPES.Identifier&&c.parent.callee.name==="memo"))for(let a of o.members)a.type===M.TSESTree.AST_NODE_TYPES.TSPropertySignature&&n(a)}}}});function Ie(e){return e?e.parent?.type===M.TSESTree.AST_NODE_TYPES.ExportNamedDeclaration||e.parent?.type===M.TSESTree.AST_NODE_TYPES.ExportDefaultDeclaration:!1}function Ce(e,t){if(Ie(e))return;let n;if(e.type===M.TSESTree.AST_NODE_TYPES.VariableDeclaration){if(e.declarations.length!==1)return;e.declarations[0].id.type===M.TSESTree.AST_NODE_TYPES.Identifier&&(n=e.declarations[0].id)}else{if(!e.id)return;n=e.id}if(!n)return;let r=t.getScope(e);e.type===M.TSESTree.AST_NODE_TYPES.FunctionDeclaration&&r.upper&&(r=r.upper);let o=r.variables.find(c=>c.identifiers.includes(n));if(!o)return;let u=o.references.filter(c=>c.identifier!==n);if(!(u.length!==1||!u[0])&&!Ie(u[0].identifier.parent.parent))return u[0].identifier}var Je={name:$t,rule:gr};var jt=require("@typescript-eslint/utils"),we=Ne(require("path"));var Sr=jt.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Mt="no-relative-imports",hr=L({find:F(),replacement:F()}),Tr=L({aliases:H(hr),rootDir:N(F()),allowNotFoundAliases:N(ae()),_dev_simulateFileName:N(F())}),Er=Sr({name:Mt,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:[Tr]},defaultOptions:[{aliases:[],rootDir:void 0}],create(e,[t]){let n=t._dev_simulateFileName??e.filename;function r(c){return c.startsWith(".")||c.startsWith("..")}function o(c,i){let a=we.default.dirname(i);return we.default.resolve(a,c)}function u(c){let i=t.rootDir??process.cwd(),a=we.default.relative(i,c);if(a.startsWith("."))return null;a.startsWith("/")||(a=`/${a}`);for(let{find:l,replacement:s}of t.aliases)if(a.startsWith(s)){let p=a.replace(s,l);return{alias:l,newPath:p}}return null}return{ImportDeclaration(c){let i=c.source.value;if(!r(i))return;let a=o(i,n),l=u(a);!l&&t.allowNotFoundAliases||e.report({node:c,messageId:l?"noRelativeImportsWithAlias":"noRelativeImports",data:{alias:l?.alias},fix:l?s=>s.replaceText(c.source,`'${l.newPath}'`):void 0})}}}}),Ge={name:Mt,rule:Er};var ne=require("@typescript-eslint/utils");var Ze=Ne(require("typescript")),br=ne.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ut="no-unnecessary-casting",xr=L({additionalCastFunctions:N(H(L({name:F(),expectedType:Te(["string","number"])})))}),Qe={name:Ut,rule:br({name:Ut,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:[xr],fixable:"code"},defaultOptions:[{}],create(e){let n=e.options[0].additionalCastFunctions||[],r=[{name:"Number",expectedType:"number"},{name:"String",expectedType:"string"},...n],o=ne.ESLintUtils.getParserServices(e,!0),u=o.program?.getTypeChecker();if(!u||!o.program)throw new Error("TypeScript services or program not available");function c(s,p){switch(s.type){case ne.AST_NODE_TYPES.Literal:return p==="number"?typeof s.value=="number":typeof s.value=="string";case ne.AST_NODE_TYPES.TemplateLiteral:return p==="string";case ne.AST_NODE_TYPES.UnaryExpression:return p==="number"?s.operator==="+"||s.operator==="-"||s.operator==="~":!1;default:return!1}}function i(s,p){return p==="number"?!!(s.flags&Ze.TypeFlags.NumberLike):!!(s.flags&Ze.TypeFlags.StringLike)}function a(s,p){return g=>g.replaceText(s,e.sourceCode.getText(p))}function l(s){if(!u||s.arguments.length!==1)return;let p=s.arguments[0];if(!p||p.type===ne.AST_NODE_TYPES.SpreadElement)return;let{callee:g}=s;if(g.type!==ne.AST_NODE_TYPES.Identifier)return;let y=g.name,S=r.find(b=>b.name===y);if(!S)return;if(c(p,S.expectedType)||i(u.getTypeAtLocation(o.esTreeNodeToTSNodeMap.get(p)),S.expectedType)){let b,h;y==="Number"?b="unnecessaryNumberCasting":y==="String"?b="unnecessaryStringCasting":(b="unnecessaryCustomCasting",h={name:S.name,type:S.expectedType}),e.report({node:s,messageId:b,...h?{data:h}:{},fix:a(s,p)})}}return{CallExpression:l}}})};var U=require("@typescript-eslint/utils");var Cr=L({selectors:H(L({name:F(),selectorProp:N(F()),selectorArgPos:N(X()),returnProp:N(F())}))}),Ir=U.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Vt="no-unused-selected-values",et={name:Vt,rule:Ir({name:Vt,meta:{type:"suggestion",docs:{description:"Disallow unused values in selector objects"},messages:{unusedSelectedValue:'The selected value "{{name}}" is not being used'},schema:[Cr]},defaultOptions:[{selectors:[]}],create(e,[t]){let{selectors:n=[]}=t,r=new Map(n.map(o=>[o.name,o]));return{VariableDeclarator(o){let u=null;if(o.init?.type===U.AST_NODE_TYPES.CallExpression&&(u=o.init),!u)return;let c=Rr(u);if(!c)return;let i=r.get(c);if(!i)return;let a=wr(u,i.selectorArgPos??0,i.selectorProp);if(!a)return;let l=vr(a);if(!l)return;let s=Wt(l.properties,void 0);if(!s)return;if(o.id.type===U.AST_NODE_TYPES.ObjectPattern){let y=Wt(o.id.properties,i.returnProp);if(!y)return;for(let[S,d]of s)y.has(S)||e.report({node:d,messageId:"unusedSelectedValue",data:{name:S}});return}if(o.id.type!==U.AST_NODE_TYPES.Identifier||i.returnProp)return;let p=Or(o,e.sourceCode);if(p.length===0)return;let g=new Set;for(let y of p){if(y.identifier.parent.type!==U.AST_NODE_TYPES.MemberExpression)return;let S=y.identifier.parent.property;if(S.type!==U.AST_NODE_TYPES.Identifier)return;g.add(S.name)}for(let[y,S]of s)g.has(y)||e.report({node:S,messageId:"unusedSelectedValue",data:{name:y}})}}}})};function wr(e,t,n){let r=e.arguments[t];if(!r)return null;if(r.type===U.AST_NODE_TYPES.ArrowFunctionExpression||r.type===U.AST_NODE_TYPES.FunctionExpression)return r;if(n&&r.type===U.AST_NODE_TYPES.ObjectExpression){let o=r.properties.find(c=>c.type===U.AST_NODE_TYPES.Property&&c.key.type===U.AST_NODE_TYPES.Identifier&&c.key.name===n);if(o?.type!==U.AST_NODE_TYPES.Property)return null;let u=o.value;if(u.type===U.AST_NODE_TYPES.ArrowFunctionExpression||u.type===U.AST_NODE_TYPES.FunctionExpression)return u}return null}function Rr(e){return e.callee.type===U.AST_NODE_TYPES.Identifier?e.callee.name:e.callee.type===U.AST_NODE_TYPES.MemberExpression&&e.callee.property.type===U.AST_NODE_TYPES.Identifier?e.callee.property.name:null}function vr(e){if(e.body.type===U.AST_NODE_TYPES.ObjectExpression)return e.body;if(e.body.type===U.AST_NODE_TYPES.BlockStatement){let t=e.body.body.filter(n=>n.type===U.AST_NODE_TYPES.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==U.AST_NODE_TYPES.ObjectExpression?null:t[0].argument}return null}function Wt(e,t){let n=e;if(t){let o=e.find(u=>u.type===U.AST_NODE_TYPES.Property&&u.key.type===U.AST_NODE_TYPES.Identifier&&u.key.name===t);if(o?.type!==U.AST_NODE_TYPES.Property||o.value.type!==U.AST_NODE_TYPES.ObjectPattern)return null;n=o.value.properties}let r=new Map;for(let o of n){if(o.type!==U.AST_NODE_TYPES.Property||o.key.type!==U.AST_NODE_TYPES.Identifier)return null;r.set(o.key.name,o)}return r.size>0?r:null}function Or(e,t){let n=t.getDeclaredVariables(e);if(n.length!==1)return[];let r=n[0];return r?r.references.filter(o=>o.identifier!==e.id):[]}var j=require("@typescript-eslint/utils");var kr=j.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function Ht(e){let t=[];for(let n of e.members)n.type===j.AST_NODE_TYPES.TSPropertySignature&&n.key.type===j.AST_NODE_TYPES.Identifier&&t.push([n.key.name,n]);return t}function Yt(e,...t){for(let n of t)e.set(...n);return e}var Ar=L({forceCheckOnFCPropTypesWithName:N(H(F()))}),zt="no-unused-type-props-in-args",tt=null,Pr=kr({name:zt,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:[Ar],fixable:"code"},defaultOptions:[{}],create(e,[t]){let{forceCheckOnFCPropTypesWithName:n}=t;n&&!tt&&(tt=n.map(i=>new RegExp(i)));function r(i,a,l,s,p=!0){let g=l.name,y=e.sourceCode.getScope(a).references.find(b=>b.identifier.name===g)?.resolved,S=i&&tt?.some(b=>b.test(g));if(!y||!S&&y.references.filter(b=>b.isTypeReference).length>1)return;let d=y?.defs[0]?.node;if(!(p&&d?.parent?.type===j.AST_NODE_TYPES.ExportNamedDeclaration)){if(d?.type===j.AST_NODE_TYPES.TSTypeAliasDeclaration){o(i,a,s,d.typeAnnotation,!0);return}if(d?.type===j.AST_NODE_TYPES.TSInterfaceDeclaration){o(i,a,s,d.body,!0);return}}}function o(i,a,l,s,p){if(s.type===j.AST_NODE_TYPES.TSInterfaceBody){for(let g of s.body)g.type===j.AST_NODE_TYPES.TSPropertySignature&&g.key.type===j.AST_NODE_TYPES.Identifier&&l.set(g.key.name,g);return}if(s.type===j.AST_NODE_TYPES.TSTypeLiteral){Yt(l,...Ht(s));return}if(s.type===j.AST_NODE_TYPES.TSIntersectionType){for(let g of s.types)o(i,a,l,g,!0);return}p||s.type===j.AST_NODE_TYPES.TSTypeReference&&s.typeName.type===j.AST_NODE_TYPES.Identifier&&r(i,a,s.typeName,l)}function u(i,a,l){for(let s of l)if(s.type==="ObjectPattern"&&s.typeAnnotation){let p=new Map;if(o(i,a,p,s.typeAnnotation.typeAnnotation,!1),p.size===0)continue;c(s,p)}else s.type===j.AST_NODE_TYPES.AssignmentPattern&&s.left.type===j.AST_NODE_TYPES.ObjectPattern&&u(i,a,[s.left])}function c(i,a){let l=[];if(i.properties.at(-1)?.type===j.AST_NODE_TYPES.RestElement)return;for(let y of i.properties)y.type===j.AST_NODE_TYPES.Property&&y.key.type===j.AST_NODE_TYPES.Identifier&&l.push(y.key.name);let p=[],g=[];for(let[y,S]of a)l.includes(y)||(g.push(y),p.push({node:S,messageId:"unusedObjectTypeProperty",data:{propertyName:y}}));for(let[y,S]of p.entries())e.report({...S,fix:y===p.length-1?d=>{let b=i.properties.at(-1),h=g.join(", ");return b?b?.type===j.AST_NODE_TYPES.RestElement?null:d.insertTextAfter(b,`, ${h}`):d.insertTextBeforeRange([i.range[0]+1,i.range[1]],`${h}`)}:void 0})}return{VariableDeclaration(i){let a=i.declarations[0];if(!a)return;let l=new Map,s=a.id.type===j.AST_NODE_TYPES.Identifier&&a.id.typeAnnotation?.typeAnnotation.type===j.AST_NODE_TYPES.TSTypeReference&&a.id.typeAnnotation.typeAnnotation.typeName.type===j.AST_NODE_TYPES.Identifier&&a.id.typeAnnotation.typeAnnotation.typeName.name==="FC"&&a.id.typeAnnotation.typeAnnotation.typeArguments?.params[0];if(s){if(s.type===j.AST_NODE_TYPES.TSTypeReference&&s.typeName.type===j.AST_NODE_TYPES.Identifier)r(!0,i,s.typeName,l,!1);else if(s.type===j.AST_NODE_TYPES.TSTypeLiteral)Yt(l,...Ht(s));else if(s.type===j.AST_NODE_TYPES.TSIntersectionType)for(let p of s.types)p.type===j.AST_NODE_TYPES.TSTypeReference&&p.typeName.type===j.AST_NODE_TYPES.Identifier?r(!0,i,p.typeName,l,!1):o(!0,i,l,p,!0);if(l.size!==0&&a.init?.type===j.AST_NODE_TYPES.ArrowFunctionExpression){let p=a.init.params[0];if(!p){e.report({node:a.init,messageId:"missingComponentParam"});return}p.type===j.AST_NODE_TYPES.ObjectPattern&&c(p,l)}}},FunctionDeclaration:function(i){u(!1,i,i.params)},ArrowFunctionExpression(i){u(!1,i,i.params)}}}}),nt={name:zt,rule:Pr};var pe=require("@typescript-eslint/utils"),Nr=pe.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),qt="prefer-named-functions",Bt=new Map,_r=Nr({name:qt,meta:{hasSuggestions:!0,type:"suggestion",docs:{description:"Prevent using arrow functions when a named function can be used instead"},schema:[{type:"object",properties:{ignoreRegex:{type:"string"},disallowArrowFnWithImplicitReturns:{type:"boolean"}}}],messages:{suggestion:"Convert to named function",default:'Function {{functionName}} should be defined as a named function "function {{functionName}} () {}" instead of an arrow function',withIgnoreRegex:'Function {{functionName}} should be defined as a named function "function {{functionName}} () {}", if not possible to use `function` you can also use a name that matches the rule ignore regex'}},defaultOptions:[{}],create(e,[t]){let n=null;if(t.ignoreRegex){let r=Bt.get(t.ignoreRegex);r?n=r:(n=new RegExp(t.ignoreRegex),Bt.set(t.ignoreRegex,n))}return{VariableDeclarator(r){if(r.init&&r.init.type===pe.AST_NODE_TYPES.ArrowFunctionExpression&&r.id.type===pe.AST_NODE_TYPES.Identifier){let o=r.id.name;if(r.id.typeAnnotation||n&&n.test(o)||!t.disallowArrowFnWithImplicitReturns&&r.init.body.type!==pe.AST_NODE_TYPES.BlockStatement)return;let u=r.parent,c=r.init.params,i=r.init.body,a=r.init;e.report({node:r.id,messageId:n?"withIgnoreRegex":"default",data:{functionName:o,ignoreRegex:t.ignoreRegex},suggest:[{messageId:"suggestion",fix:l=>l.replaceText(u,`${a.async?"async ":""}function ${o}(${c.map(s=>e.sourceCode.getText(s)).join(", ")||""}) ${e.sourceCode.getText(i)}`)}]})}}}}}),rt={name:qt,rule:_r};var V=require("@typescript-eslint/utils");var Fr=V.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Xt="prefer-single-line-if",Dr=L({maxLineLength:N(X()),maxNonSimpleConditionLength:N(X())}),Lr=Fr({name:Xt,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:[Dr]},defaultOptions:[{}],create(e,[t]){let n=e.sourceCode;return{IfStatement(r){if(r.consequent.type!==V.AST_NODE_TYPES.BlockStatement||r.loc.start.line===r.loc.end.line||n.getCommentsInside(r.consequent).length>0||r.alternate||r.consequent.body.length!==1)return;let u=r.consequent.body[0];if(u.type===V.AST_NODE_TYPES.ReturnStatement){if(!Gt(u))return}else if(!(u.type===V.AST_NODE_TYPES.ContinueStatement||u.type===V.AST_NODE_TYPES.BreakStatement))return;if(r.test.type===V.AST_NODE_TYPES.LogicalExpression||r.test.type===V.AST_NODE_TYPES.ConditionalExpression)return;let c;if(t.maxNonSimpleConditionLength){let p=Kt(r.test);if(!p&&r.test.type===V.AST_NODE_TYPES.UnaryExpression&&r.test.operator==="!"){let g=r.test.argument;Kt(g)&&(p=!0)}if(p&&(c=n.getText(r.test),c.length>t.maxNonSimpleConditionLength))return}c||(c=n.getText(r.test));let i=n.getText(u);if(c.includes(`
|
|
15
|
+
`))return;let a=n.getTokenAfter(r);if(a&&a.type===V.AST_TOKEN_TYPES.Punctuator&&a.value==="}"){let p=n.getTokenAfter(a);if(p&&p.type===V.AST_TOKEN_TYPES.Keyword&&(p.value==="else"||p.value==="catch"))return}let l=$r(n,r),s=`if (${c}) ${i}`;t.maxLineLength&&s.length+l.length>t.maxLineLength||e.report({node:r,messageId:"noSingleLineCurly",fix:p=>p.replaceText(r,s)})}}}});function Kt(e){return e.type===V.AST_NODE_TYPES.CallExpression||e.type===V.AST_NODE_TYPES.BinaryExpression||e.type===V.AST_NODE_TYPES.MemberExpression&&Jt(e)}function Jt(e){return e.object.type===V.AST_NODE_TYPES.MemberExpression?Jt(e.object):e.object.type!==V.AST_NODE_TYPES.Identifier}function $r(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}function Gt(e){if(!e.argument)return!0;let t=e.argument;return t.type===V.AST_NODE_TYPES.ArrayExpression&&t.elements.length===0||t.type===V.AST_NODE_TYPES.ObjectExpression&&t.properties.length===0||t.type===V.AST_NODE_TYPES.Literal||t.type===V.AST_NODE_TYPES.Identifier||t.type===V.AST_NODE_TYPES.TemplateLiteral||t.type===V.AST_NODE_TYPES.TaggedTemplateExpression?!0:t.type===V.AST_NODE_TYPES.CallExpression?t.arguments.length===0:t.type===V.AST_NODE_TYPES.UnaryExpression?Gt(t):!1}var it={name:Xt,rule:Lr};var B=require("@typescript-eslint/utils");var jr=B.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Zt="react-compiler-migration",Mr=L({disallowHooks:N(H(L({name:F(),replacement:F()}))),disallowMethods:N(H(L({name:F(),replacement:N(F()),requireTrueProp:N(F())})))}),Ur=/eslint +react-compiler\/react-compiler: +\["error/;function Vr(e){return e.type===B.AST_NODE_TYPES.Identifier?e.name.startsWith("use"):e.type===B.AST_NODE_TYPES.MemberExpression&&e.property.type===B.AST_NODE_TYPES.Identifier?e.property.name.startsWith("use"):!1}var Wr=jr({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:[Mr]},defaultOptions:[{}],create(e,[t]){let n=!1;for(let r of e.sourceCode.getAllComments())if(Ur.test(r.value)){n=!0;break}return n?{CallExpression(r){if(t.disallowHooks?.length){let o=null,u=null;if(r.callee.type===B.AST_NODE_TYPES.Identifier?(o=r.callee.name,u=r.callee):r.callee.type===B.AST_NODE_TYPES.MemberExpression&&r.callee.property.type===B.AST_NODE_TYPES.Identifier&&(o=r.callee.property.name,u=r.callee.property),o){let c=t.disallowHooks.find(i=>i.name===o);c&&u&&e.report({node:r,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:c.name,replacement:c.replacement},suggest:[{messageId:"replace",data:{replacement:c.replacement},fix:i=>i.replaceText(u,c.replacement)}]})}}if(t.disallowMethods?.length&&Vr(r.callee)){for(let o of r.arguments)if(o.type===B.AST_NODE_TYPES.ObjectExpression){for(let u of o.properties)if(u.type===B.AST_NODE_TYPES.Property&&u.key.type===B.AST_NODE_TYPES.Identifier){let c=u.key.name,i=t.disallowMethods.find(a=>a.name===c);if(i){if(i.requireTrueProp){let a=i.requireTrueProp,l=!1;for(let s of o.properties)if(s.type===B.AST_NODE_TYPES.Property&&s.key.type===B.AST_NODE_TYPES.Identifier&&s.key.name===a&&s.value.type===B.AST_NODE_TYPES.Literal&&s.value.value===!0){l=!0;break}if(!l){e.report({node:u,messageId:"disallowedMethodWithMissingRequireTrueProp",data:{method:i.name,requireTrueProp:a}});continue}}i.replacement&&e.report({node:u,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:i.name,replacement:i.replacement},suggest:[{messageId:"replace",data:{replacement:i.replacement},fix:a=>a.replaceText(u.key,i.replacement)}]})}}}}}}:{}}}),st={name:Zt,rule:Wr};var Re=require("@typescript-eslint/utils"),Hr=Re.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Qt="require-description",Yr=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,zr=/^eslint-disable-(next-)?line$/u,Br=Hr({name:Qt,meta:{type:"problem",docs:{description:"Require descriptions for eslint directives."},messages:{missingDescription:"Unexpected undescribed directive comment. Include descriptions to explain why the comment is necessary."},schema:[{type:"object",properties:{ignore:{type:"array",items:{type:"string",enum:["eslint","eslint-disable","eslint-disable-line","eslint-disable-next-line","eslint-enable","eslint-env","exported","global","globals"]},additionalItems:!1,uniqueItems:!0}},additionalProperties:!1}]},defaultOptions:[{ignore:[]}],create(e,[t]){let n=e.sourceCode,r=new Set(t.ignore||[]);return{Program(){for(let o of n.getAllComments()){let u=qr(o);u!=null&&(r.has(u.kind)||u.description||e.report({loc:Xr(o.loc),messageId:"missingDescription"}))}}}}}),en={name:Qt,rule:Br};function qr(e){let{text:t,description:n}=Kr(e.value);if(!t)return null;let r=Yr.exec(t);if(!r)return null;let o=r[1];if(!o)return null;let u=zr.test(o);if(e.type===Re.TSESTree.AST_TOKEN_TYPES.Line&&!u||u&&e.loc.start.line!==e.loc.end.line)return null;let c=t.slice(r.index+o.length);return{kind:o,value:c.trim(),description:n}}function Kr(e){let t=e.split(/\s-{2,}\s/u);return{text:t[0]?.trim(),description:t.length>1?t[1]?.trim()??null:null}}function Xr(e){return{start:{line:e.start.line,column:-1},end:e.end}}function rn(e){return/^use[A-Z0-9]/.test(e)}function ve(e){return e.type==="Identifier"?rn(e.name):e.type==="MemberExpression"&&!e.computed&&ve(e.property)?e.object.type==="Identifier":!1}function sn(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function on(e,t){return e.name===t||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===t}function an(e){return!!(e.parent&&e.parent.callee&&on(e.parent.callee,"forwardRef"))}function ln(e){return!!(e.parent&&e.parent.callee&&on(e.parent.callee,"memo"))}function ot(e){for(;e;){let t=un(e);if(t&&(sn(t)||ve(t))||an(e)||ln(e))return!0;e=e.parent}return!1}function tn(e){return!1}function at(e){return!1}var Jr=/eslint +react-compiler\/react-compiler: +\["error/,cn={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(Jr.test(a.value))return{CallExpression(l){let s=null;l.callee.name==="useMemo"?s="useMemo":l.callee.name==="useCallback"&&(s="useCallback"),s&&e.report({node:l,message:`"${s}" is not necessary when using React Compiler.`})}}}let t=typeof e.getSource=="function"?a=>t(a):a=>e.sourceCode.getText(a),n=typeof e.getScope=="function"?()=>n():a=>e.sourceCode.getScope(a),r=null,o=[],u=[],c=new WeakSet;function i(a){for(let l of a.references){let s=l.identifier.parent;if(s.type==="VariableDeclarator"&&s.init&&s.init.type==="CallExpression"&&s.init.callee&&tn(s.init.callee))for(let p of l.resolved.references)p!==l&&c.add(p.identifier)}}return{onCodePathSegmentStart:a=>u.push(a),onCodePathSegmentEnd:()=>u.pop(),onCodePathStart:()=>o.push(new Map),onCodePathEnd(a,l){let s=o.pop();if(s.size===0)return;let p=new Set;function g(T,w){let{cache:R}=g,O=R.get(T.id),$=new Set(w);if($.has(T.id)){let k=[...$],W=k.slice(k.indexOf(T.id)+1);for(let Z of W)p.add(Z);return BigInt("0")}if($.add(T.id),O!==void 0)return O;if(a.thrownSegments.includes(T))O=BigInt("0");else if(T.prevSegments.length===0)O=BigInt("1");else{O=BigInt("0");for(let k of T.prevSegments)O+=g(k,$)}return T.reachable&&O===BigInt("0")?R.delete(T.id):R.set(T.id,O),O}function y(T,w){let{cache:R}=y,O=R.get(T.id),$=new Set(w);if($.has(T.id)){let k=Array.from($),W=k.slice(k.indexOf(T.id)+1);for(let Z of W)p.add(Z);return BigInt("0")}if($.add(T.id),O!==void 0)return O;if(a.thrownSegments.includes(T))O=BigInt("0");else if(T.nextSegments.length===0)O=BigInt("1");else{O=BigInt("0");for(let k of T.nextSegments)O+=y(k,$)}return R.set(T.id,O),O}function S(T){let{cache:w}=S,R=w.get(T.id);if(R===null)return 1/0;if(R!==void 0)return R;if(w.set(T.id,null),T.prevSegments.length===0)R=1;else{R=1/0;for(let O of T.prevSegments){let $=S(O);$<R&&(R=$)}R+=1}return w.set(T.id,R),R}g.cache=new Map,y.cache=new Map,S.cache=new Map;let d=y(a.initialSegment),b=un(l),h=ot(l),_=b?sn(b)||ve(b):an(l)||ln(l),v=1/0;for(let T of a.finalSegments){if(!T.reachable)continue;let w=S(T);w<v&&(v=w)}for(let[T,w]of s){if(!T.reachable)continue;let R=T.nextSegments.length===0?v<=S(T):v<S(T),O=g(T)*y(T),$=p.has(T.id);for(let k of w)if($&&!at(k)&&e.report({node:k,message:`React Hook "${t(k)}" 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.`}),_){if(l.async&&e.report({node:k,message:`React Hook "${t(k)}" cannot be called in an async function.`}),!$&&O!==d&&!at(k)){let Z=`React Hook "${t(k)}" 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:k,message:Z})}}else if(l.parent&&(l.parent.type==="MethodDefinition"||l.parent.type==="ClassProperty")&&l.parent.value===l){let W=`React Hook "${t(k)}" 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:k,message:W})}else if(b){let W=`React Hook "${t(k)}" 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:k,message:W})}else if(l.type==="Program"){let W=`React Hook "${t(k)}" 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:k,message:W})}else if(h&&!at(k)){if(l.parent.type==="CallExpression"&&l.parent.callee.type==="Identifier"&&l.parent.callee.name==="useCallback"){let Z=l.parent;if(Z.parent.type==="VariableDeclarator"&&rn(Z.parent.id.name))return}let W=`React Hook "${t(k)}" 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:k,message:W})}}},CallExpression(a){if(ve(a.callee)){let l=nn(o),s=nn(u),p=l.get(s);p||(p=[],l.set(s,p)),p.push(a.callee)}a.callee.type==="Identifier"&&(a.callee.name==="useEffect"||tn(a.callee))&&a.arguments.length>0&&(r=a)},Identifier(a){r==null&&c.has(a)&&a.parent.type!=="CallExpression"&&e.report({node:a,message:`\`${t(a)}\` is a function created with React Hook "useEffectEvent", and can only be called from the same component. They cannot be assigned to variables or passed down.`})},"CallExpression:exit"(a){a===r&&(r=null)},FunctionDeclaration(a){ot(a)&&i(n(a))},ArrowFunctionExpression(a){ot(a)&&i(n(a))}}}};function un(e){return e.type==="FunctionDeclaration"||e.type==="FunctionExpression"&&e.id?e.id:e.type==="FunctionExpression"||e.type==="ArrowFunctionExpression"?e.parent.type==="VariableDeclarator"&&e.parent.init===e?e.parent.id:e.parent.type==="AssignmentExpression"&&e.parent.right===e&&e.parent.operator==="="?e.parent.left:e.parent.type==="Property"&&e.parent.value===e&&!e.parent.computed?e.parent.key:e.parent.type==="AssignmentPattern"&&e.parent.right===e&&!e.parent.computed?e.parent.left:void 0:void 0}function nn(e){return e[e.length-1]}var pn={[nt.name]:nt.rule,[ze.name]:ze.rule,[Ye.name]:Ye.rule,"rules-of-hooks":cn,"exhaustive-deps":It,"require-description":en.rule,[Be.name]:Be.rule,[Ke.name]:Ke.rule,[rt.name]:rt.rule,[Le.name]:Le.rule,[He.name]:He.rule,[Ge.name]:Ge.rule,[it.name]:it.rule,[Je.name]:Je.rule,[qe.name]:qe.rule,[je.name]:je.rule,[st.name]:st.rule,[De.name]:De.rule,[We.name]:We.rule,[Qe.name]:Qe.rule,[et.name]:et.rule};var Gr={rules:pn};0&&(module.exports={extendedLintPlugin});
|
package/dist/extended-lint.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{AST_NODE_TYPES as
|
|
2
|
-
`)||n.getCommentsInside(
|
|
3
|
-
`,n.range[1]);return(r!==-1?r:t.text.length)-n.range[1]}function
|
|
1
|
+
import{AST_NODE_TYPES as Y,ESLintUtils as dn}from"@typescript-eslint/utils";var Ie=Symbol.for("optional");function N(e){return{...e,[Ie]:!0}}function me(e,t){return{enum:e,...t}}function re(e){return{...e,type:"boolean"}}function F(e){return{...e,type:"string"}}function K(e){return{...e,type:"number"}}function lt(e){return{...e,type:"integer"}}function W(e,t){return{...t,type:"array",items:e}}function D(e,t){let n={...t,type:"object",properties:e};if(e&&(n.additionalProperties||=!1,!n.required)){let r,a=[];for(r in e)e[r][Ie]?e[r][Ie]=void 0:a.push(r);a.length>0&&(n.required=a)}return n}function we(...e){return{anyOf:e}}var yn=dn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),ut="react-compiler-extra",gn=D({runOnlyWithEnableCompilerDirective:N(re())}),Sn=/eslint +react-compiler\/react-compiler: +\["error/;function hn(e){return e.type===Y.Identifier?e.name.startsWith("use"):e.type===Y.MemberExpression&&e.property.type===Y.Identifier?e.property.name.startsWith("use"):!1}var Tn=/\bthis[.[]/;function ct(e){return Tn.test(e)}var En=yn({name:ut,meta:{type:"suggestion",fixable:"code",docs:{description:"Extra rules to enforce best practices when using the React compiler"},messages:{objectMethodIsNotSupported:"Object methods such as `{ method() {} }` have limited support to optimizations in the React compiler, use a function expression `{ method: () => {} }` instead.",replaceWithFunctionExpression:"Replace with function expression",thisKeywordInMethod:"Object method uses `this` keyword which would have different behavior if converted to an arrow function. Fix this manually."},hasSuggestions:!0,schema:[gn]},defaultOptions:[{}],create(e,[t]){let n=!1;if(t.runOnlyWithEnableCompilerDirective){for(let u of e.sourceCode.getAllComments())if(Sn.test(u.value)){n=!0;break}if(!n)return{}}function r(u){for(let c of u.properties)if(c.type===Y.Property&&c.method&&c.value.type===Y.FunctionExpression){let i=e.sourceCode,o=i.getText(c.key),l=c.value,s=i.getText(l.body);if(ct(s))e.report({node:c,messageId:"thisKeywordInMethod"});else{let p=l.params.map(y=>i.getText(y)).join(", "),g="";l.generator?g=`${o}: function* (${p}) ${s}`:g=`${o}: (${p}) => ${s}`,e.report({node:c,messageId:"objectMethodIsNotSupported",fix:y=>y.replaceText(c,g)})}}}function a(u){for(let c of u.properties)if(c.type===Y.Property&&c.value.type===Y.ObjectExpression){for(let i of c.value.properties)if(i.type===Y.Property&&i.method&&i.value.type===Y.FunctionExpression){let l=e.sourceCode.getText(i.value.body);ct(l)&&e.report({node:i,messageId:"thisKeywordInMethod"})}}}return{CallExpression(u){if(hn(u.callee))for(let c of u.arguments){if(c.type===Y.ObjectExpression&&(r(c),a(c)),c.type===Y.ArrowFunctionExpression&&(c.body.type===Y.ObjectExpression&&(r(c.body),a(c.body)),c.body.type===Y.BlockStatement))for(let i of c.body.body)i.type===Y.ReturnStatement&&i.argument?.type===Y.ObjectExpression&&(r(i.argument),a(i.argument));if(c.type===Y.FunctionExpression)for(let i of c.body.body)i.type===Y.ReturnStatement&&i.argument?.type===Y.ObjectExpression&&(r(i.argument),a(i.argument))}}}}}),Re={name:ut,rule:En};import{AST_NODE_TYPES as ve,ESLintUtils as bn}from"@typescript-eslint/utils";var xn=bn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Cn=D({disallow:N(W(D({selector:F(),message:F(),replace:N(we(F(),D({regex:F(),with:F()}))),replaceType:N(me(["suggestion","autofix"]))}))),__dev_simulateFileName:N(F()),mustMatchSyntax:N(W(D({includeRegex:F(),mustCallFn:W(D({anyCall:W(D({fn:F(),withArgs:W(D({atIndex:lt(),literal:we(F(),K(),re())}))})),message:N(F())}))})))}),mt="advanced-no-restricted-syntax",In=xn({name:mt,meta:{type:"suggestion",docs:{description:"Disallow specific syntax patterns"},schema:[Cn],messages:{default:"{{message}}"},fixable:"code",hasSuggestions:!0},defaultOptions:[{disallow:[]}],create(e,[t]){let n={},{mustMatchSyntax:r,__dev_simulateFileName:a,disallow:u}=t,c=a??e.filename,i=[],o=new Set;for(let{includeRegex:s,mustCallFn:p}of r??[]){let g=wn(c,new RegExp(s));if(!g)continue;let y=S=>{let d=S;for(let{name:b,value:h}of g)d=d.replaceAll(b,h);return d};for(let{anyCall:S,message:d}of p){let b=`Expected file to call the function: ${S.map(({fn:h})=>h).join(" or ")}`;o.add(b),i.push(h=>{let{callee:_}=h;if(_.type===ve.Identifier){for(let{fn:v,withArgs:T}of S)if(_.name===v){o.delete(b);for(let w of T){let R=h.arguments[w.atIndex],O=typeof w.literal=="string"?y(w.literal):w.literal;if(!R){e.report({node:h,messageId:"default",data:{message:`Missing argument with value "${O}" at index ${w.atIndex}${d?`: ${y(d)}`:""}`}});continue}if(R.type!==ve.Literal){e.report({node:R,messageId:"default",data:{message:`Argument at position ${w.atIndex} should the literal "${O}"${d?`: ${y(d)}`:""}`}});continue}R.value!==O&&e.report({node:R,messageId:"default",data:{message:`Argument should have the value "${O}"${d?`: ${y(d)}`:""}`},fix:L=>L.replaceText(R,typeof O=="string"?`'${O}'`:String(O))})}break}}})}}for(let{selector:s,message:p,replace:g,replaceType:y="suggestion"}of u??[]){if(s==="CallExpression"){i.push(S=>{l(g,S,p,y)});continue}n[s]=S=>{l(g,S,p,y)}}return i.length>0&&(n.CallExpression=s=>{if(s.type===ve.CallExpression)for(let p of i)p(s)}),n["Program:exit"]=s=>{for(let p of o)e.report({node:s,messageId:"default",data:{message:`${p}`}})},n;function l(s,p,g,y){let S=d=>{if(!s)return null;if(typeof s=="string")return d.replaceText(p,s);{let b=new RegExp(s.regex),h=e.sourceCode.getText(p);return d.replaceText(p,h.replace(b,s.with))}};e.report({node:p,messageId:"default",data:{message:g},fix:s&&y==="autofix"?S:void 0,suggest:s&&y==="suggestion"?[{messageId:"default",data:{message:`Replace with "${typeof s=="string"?s:s.with}"`},fix:S}]:void 0})}}});function wn(e,t){let n=[],r=t.exec(e);if(!r)return null;let[a,...u]=r;n.push({name:"$0_lowercase",value:a.toLowerCase()}),n.push({name:"$0_capitalize",value:pt(a)}),n.push({name:"$0_uncapitalize",value:ft(a)}),n.push({name:"$0",value:a});for(let c=0;c<u.length;c++){let i=`$${c+1}`,o=u[c];n.push({name:`${i}_lowercase`,value:o.toLowerCase()}),n.push({name:`${i}_capitalize`,value:pt(o)}),n.push({name:`${i}_uncapitalize`,value:ft(o)}),n.push({name:i,value:o})}return n}function pt(e){return e.charAt(0).toUpperCase()+e.slice(1)}function ft(e){return e.charAt(0).toLowerCase()+e.slice(1)}var Oe={name:mt,rule:In};import{AST_NODE_TYPES as $,AST_TOKEN_TYPES as Rn,ESLintUtils as vn}from"@typescript-eslint/utils";var On=vn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),yt="collapse-simple-objs-in-one-line",kn=D({maxLineLength:N(K()),maxProperties:N(K()),nestedObjMaxLineLength:N(K()),nestedObjMaxProperties:N(K()),ignoreTypesWithSuffix:N(W(F()))}),An=On({name:yt,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:[kn]},defaultOptions:[{}],create(e,[t]){let n=e.sourceCode,r=t.ignoreTypesWithSuffix??[],a=t.maxProperties??2,u=t.nestedObjMaxLineLength??t.maxLineLength,c=t.nestedObjMaxProperties??3;function i(l){if(l.type===$.ObjectExpression){let s=l.parent.type===$.Property,p=s?c:a,g=l.properties.length;if(g>p)return!1;if(g===1){let S=l.properties[0];return S.type===$.Property&&S.value.type===$.ObjectExpression||S.type===$.Property&&S.value.type===$.ArrayExpression&&!S.value.elements.every(b=>b&&ke(b))?!1:{text:n.getText(S),isNested:s,propsSize:g}}let y=[];for(let S of l.properties){if(S.type===$.Property&&!ke(S.value))return!1;y.push(n.getText(S))}return{text:y.join(", "),isNested:s,propsSize:g}}else{let s=l.parent.parent?.type===$.TSPropertySignature,p=s?c:a,g=l.members.length;if(g>p)return!1;if(r.length>0&&l.parent.type===$.TSTypeAliasDeclaration){let S=l.parent.id.name;if(r.some(d=>S.endsWith(d)))return!1}if(g===1){let S=l.members[0];return S.type===$.TSPropertySignature&&S.typeAnnotation?.typeAnnotation.type===$.TSTypeLiteral?!1:{text:n.getText(S),isNested:s,propsSize:1}}if(l.parent.type===$.TSIntersectionType||l.parent.type===$.TSUnionType)return!1;let y=[];for(let S of l.members){if(S.type!==$.TSPropertySignature)return!1;let d=S.typeAnnotation?.typeAnnotation;if(!d||d.type===$.TSTypeLiteral||!dt(d))return!1;if(d.type===$.TSTypeReference&&d.typeArguments){if(d.typeArguments.params.length>1)return!1;let h=d.typeArguments.params[0];if(!dt(h))return!1}let b=n.getText(S).trim();(b.endsWith(";")||b.endsWith(","))&&(b=b.slice(0,-1)),y.push(b)}return{text:y.join("; "),isNested:s,propsSize:g}}}function o(l){if(l.loc.start.line===l.loc.end.line)return;if(l.parent.type!==$.JSXExpressionContainer){let d=0,b=n.getTokenAfter(l,{filter:h=>h.type!==Rn.Punctuator?!0:h.value===","||h.value===";"||h.value===")"||h.value==="}"?(d++,!1):!0});if(d>4||b?.loc.start.line===l.loc.end.line)return}let s=i(l);if(!s)return;let p=s.text;if(p.includes(`
|
|
2
|
+
`)||n.getCommentsInside(l).length>0)return;p.endsWith(";")&&(p=p.slice(0,-1));let g=`{ ${p} }`,y=Nn(n,l),S=s.isNested&&s.propsSize>2?u:t.maxLineLength;S&&g.length+y.length+Pn(l,n)>S||e.report({node:l,messageId:"singleLineProp",fix:d=>d.replaceText(l,g)})}return{TSTypeLiteral:o,ObjectExpression:o}}});function dt(e){return e.type===$.TSLiteralType||e.type===$.TSTypeReference||e.type===$.TSNumberKeyword||e.type===$.TSStringKeyword||e.type===$.TSBooleanKeyword||e.type===$.TSNullKeyword||e.type===$.TSUndefinedKeyword}function ke(e,t){return!!(e.type===$.Literal||e.type===$.Identifier||e.type===$.TemplateLiteral||e.type===$.TaggedTemplateExpression||!t&&e.type===$.ArrayExpression&&e.elements.every(n=>n&&ke(n,!0)))}function Pn(e,t){let n=t.getLastToken(e);if(!n)return 0;let r=t.text.indexOf(`
|
|
3
|
+
`,n.range[1]);return(r!==-1?r:t.text.length)-n.range[1]}function Nn(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}var Ae={name:yt,rule:An};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"?h=>n(h):h=>e.sourceCode.getText(h),r=typeof e.getScope=="function"?()=>r():h=>e.sourceCode.getScope(h),a=e.options&&e.options[0]&&e.options[0].additionalHooks?new RegExp(e.options[0].additionalHooks):void 0,u=e.options&&e.options[0]&&e.options[0].enableDangerousAutofixThisMayCauseInfiniteLoops||!1,c={additionalHooks:a,enableDangerousAutofixThisMayCauseInfiniteLoops:u};function i(h){u&&Array.isArray(h.suggest)&&h.suggest.length>0&&(h.fix=h.suggest[0].fix),e.report(h)}let o=e.getSourceCode().scopeManager,l=new WeakMap,s=new WeakSet,p=new WeakMap,g=new WeakMap,y=new WeakSet;function S(h,_){return function(v){if(_.has(v))return _.get(v);let T=h(v);return _.set(v,T),T}}function d(h,_,v,T,w){w&&h.async&&i({node:h,message:`Effect callbacks are synchronous to prevent race conditions. Put the async function inside:
|
|
4
4
|
|
|
5
5
|
useEffect(() => {
|
|
6
6
|
async function fetchData() {
|
|
@@ -11,5 +11,5 @@ useEffect(() => {
|
|
|
11
11
|
fetchData();
|
|
12
12
|
}, [someId]); // Or [] if effect doesn't need props or state
|
|
13
13
|
|
|
14
|
-
Learn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching`});let R=o.acquire(y),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 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&&(Ne(_.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(Dn(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;a.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++)s.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=_.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)&&!et(O.resolved))return!1}return!0}let et=S(U,c),nn=S(X,g),tt=new Map;function rn(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,Se=new Map;nt(R);function nt(u){for(let m of u.references){if(!m.resolved||!k.has(m.resolved.scope))continue;let E=Ne(y,m.identifier),x=gt(E),I=Q(x,Se);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"&&rn(m)&&tt.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=et(O)||nn(O);z.set(I,{isStable:P,references:[m]})}}for(let m of u.childScopes)nt(m)}tt.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||i({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 Ee=new Set;function sn(u,m){Ee.has(m)||(Ee.add(m),i({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},E)=>{u&&ce.add(E),m.forEach(x=>{x.writeExpr&&sn(x.writeExpr,E)})}),Ee.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(!a.has(C))return;let P=I.from;for(;P.type!=="function";)P=P.upper;P.block===y&&(u=x)})}),u){let{suggestedDependencies:m}=Oe({dependencies:z,declaredDependencies:[],stableDependencies:ce,externalDependencies:new Set,isEffect:!0});i({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"?i({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"){i({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)&&i({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,Se)}catch(I){if(/Unsupported node type/.test(I.message)){u.type==="Literal"?z.has(u.value)?i({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?`}):i({node:u,message:`The ${u.raw} literal is not a valid dependency because it never changes. You can safely remove it.`}):i({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=!_.through.some(I=>I.identifier===E);oe.push({key:m,node:u}),x||ae.add(m)});let{suggestedDependencies:on,unnecessaryDependencies:pe,missingDependencies:ee,duplicateDependencies:rt}=Oe({dependencies:z,declaredDependencies:oe,stableDependencies:ce,externalDependencies:ae,isEffect:w}),ue=on;if(rt.size+ee.size+pe.size===0){if(t)return;On({declaredDependencies:oe,declaredDependenciesNode:N,componentScope:_,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}`,it;E&&m.type==="Variable"&&x==="function"&&(it=[{desc:`Wrap the ${C} of '${m.name.name}' in its own ${I}() Hook.`,fix(st){let[ln,cn]=I==="useMemo"?["useMemo(() => { return ","; })"]:["useCallback(",")"];return[st.insertTextBefore(m.node.init,ln),st.insertTextAfter(m.node.init,cn)]}}]),i({node:m.node,message:Z,suggest:it})});return}!w&&ee.size>0&&(ue=Oe({dependencies:z,declaredDependencies:[],stableDependencies:ce,externalDependencies:ae,isEffect:w}).suggestedDependencies);function an(){if(oe.length===0)return!0;let u=oe.map(E=>E.key),m=u.slice().sort();return u.join(",")===m.join(",")}an()&&ue.sort();function be(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=Se.get(I)===!0;E+=C?"?.":"."}E+=m[x]}return E}function xe(u,m,E,x){return u.size===0?null:(u.size>1?"":m+" ")+E+" "+(u.size>1?"dependencies":"dependency")+": "+Nn(Array.from(u).sort().map(I=>"'"+be(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=Ne(_.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&&ee.size>0){let u=null;ee.forEach(m=>{if(u)return;let E=_.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!==_.block;){if(C.type==="CallExpression"){let P=a.get(C.callee);if(P!=null){if(P.name===m)u={missingDep:m,setter:C.callee.name,form:"updater"};else if(s.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.")}}i({node:N,message:`React Hook ${n(v)} has `+(xe(ee,"a","missing","include")||xe(pe,"an","unnecessary","exclude")||xe(rt,"a","duplicate","omit"))+K,suggest:[{desc:`Update the dependencies array to be: [${ue.map(be).join(", ")}]`,fix(u){return u.replaceText(N,`[${ue.map(be).join(", ")}]`)}}]})}function b(y){let N=Pn(y.callee,p);if(N===-1)return;let v=y.arguments[N],h=y.callee,w=ht(h).name,R=y.arguments[N+1],k=/Effect($|[^a-z])/g.test(w);if(!v){i({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")&&i({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 _=r(y).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,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:i({node:h,message:`React Hook ${w} received a function whose dependencies are unknown. Pass an inline function instead.`});return}i({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(_){return _.replaceText(R,`[${v.name}]`)}}]})}}if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let y of e.sourceCode.getAllComments())if(An.test(y.value))return t=!0,{CallExpression:N=>b(N,!0)}}return{CallExpression:y=>b(y)}}};function Oe({dependencies:e,declaredDependencies:t,stableDependencies:n,externalDependencies:r,isEffect:l}){let f=p();function p(){return{isUsed:!1,isSatisfiedRecursively:!1,isSubtreeUsed:!1,children:new Map}}e.forEach((d,b)=>{let y=i(f,b);y.isUsed=!0,o(f,b,N=>{N.isSubtreeUsed=!0})}),t.forEach(({key:d})=>{let b=i(f,d);b.isSatisfiedRecursively=!0}),n.forEach(d=>{let b=i(f,d);b.isSatisfiedRecursively=!0});function i(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 o(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 a=new Set,s=new Set;c(f,a,s,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})=>{s.has(d)?g.indexOf(d)===-1?g.push(d):S.add(d):T.add(d)}),a.forEach(d=>{g.push(d)}),{suggestedDependencies:g,unnecessaryDependencies:T,duplicateDependencies:S,missingDependencies:a}}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 On({declaredDependencies:e,declaredDependenciesNode:t,componentScope:n,scope:r}){let l=e.map(({key:p})=>{let i=n.variables.find(a=>a.name===p);if(i==null)return null;let o=i.defs[0];if(o==null)return null;if(o.type==="Variable"&&o.node.type==="VariableDeclarator"&&o.node.id.type==="Identifier"&&o.node.init!=null){let a=te(o.node.init);if(a!=null)return[i,a]}return o.type==="FunctionName"&&o.node.type==="FunctionDeclaration"?[i,"function"]:o.type==="ClassName"&&o.node.type==="ClassDeclaration"?[i,"class"]:null}).filter(Boolean);function f(p){let i=!1;for(let o=0;o<p.references.length;o++){let a=p.references[o];if(a.writeExpr){if(i)return!0;i=!0;continue}let s=a.from;for(;s!==r&&s!=null;)s=s.upper;if(s!==r&&!Tt(t,a.identifier))return!0}return!1}return l.map(([p,i])=>({construction:p.defs[0],depType:i,isUsedOutsideOfHook:f(p)}))}function gt(e){return(e.parent.type==="MemberExpression"||e.parent.type==="OptionalMemberExpression")&&e.parent.object===e&&e.parent.property.name!=="current"&&!e.parent.computed&&!(e.parent.parent!=null&&(e.parent.parent.type==="CallExpression"||e.parent.parent.type==="OptionalCallExpression")&&e.parent.parent.callee===e.parent)?gt(e.parent):e.type==="MemberExpression"&&e.parent&&e.parent.type==="AssignmentExpression"&&e.parent.left===e?e.object:e}function Pe(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),r=Q(e.property,null),l=`${n}.${r}`;return Pe(e,t,l),l}else if(e.type==="OptionalMemberExpression"&&!e.computed){let n=Q(e.object,t),r=Q(e.property,null),l=`${n}.${r}`;return Pe(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 r=Q(n.object,t),l=Q(n.property,null),f=`${r}.${l}`;return Pe(n,t,f),f}else throw new Error(`Unsupported node type: ${e.type}`)}function ht(e,t){return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.object.name==="React"&&e.property.type==="Identifier"&&!e.computed?e.property:e}function Pn(e,t){let n=ht(e);if(n.type!=="Identifier")return-1;switch(n.name){case"useEffect":case"useLayoutEffect":case"useCallback":case"useMemo":return 0;case"useImperativeHandle":return 1;default:if(n===e&&t&&t.additionalHooks){let r;try{r=Q(n,null)}catch(l){if(/Unsupported node type/.test(l.message))return 0;throw l}return t.additionalHooks.test(r)?0:-1}else return-1}}function Ne(e,t){let n=[e],r=null;for(;n.length;){if(r=n.shift(),_n(r,t))return r;if(Tt(r,t))for(let[l,f]of Object.entries(r))l!=="parent"&&(dt(f)?(f.parent=r,n.push(f)):Array.isArray(f)&&f.forEach(p=>{dt(p)&&(p.parent=r,n.push(p))}))}return null}function Nn(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 dt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function _n(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 Tt(e,t){return e.range[0]<=t.range[0]&&e.range[1]>=t.range[1]}function Dn(e){return!1}import{AST_NODE_TYPES as de,ESLintUtils as Et}from"@typescript-eslint/utils";import Y from"typescript";var Ln=Et.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),St="improved-no-unnecessary-condition",$n=$({}),Fn=["string","number","bigint","boolean","symbol","undefined","object","function","never"],jn=new Set(Fn),_e={name:St,rule:Ln({name:St,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:[$n]},defaultOptions:[{}],create(e){let t=Et.getParserServices(e,!0),n=t.program?.getTypeChecker();if(!n||!t.program)throw new Error("TypeScript services or program not available");function r(i){return i.type===de.UnaryExpression&&i.operator==="typeof"}function l(i){return i.flags&Y.TypeFlags.Any||i.flags&Y.TypeFlags.Unknown?null:i.flags&Y.TypeFlags.StringLike?["string"]:i.flags&Y.TypeFlags.NumberLike?["number"]:i.flags&Y.TypeFlags.BigIntLike?["bigint"]:i.flags&Y.TypeFlags.BooleanLike?["boolean"]:i.flags&Y.TypeFlags.ESSymbolLike?["symbol"]:i.flags&Y.TypeFlags.Undefined||i.flags&Y.TypeFlags.Void?["undefined"]:i.flags&Y.TypeFlags.Null?["object"]:i.getCallSignatures().length>0?["function"]:i.flags&Y.TypeFlags.Object?i.getProperties().length===0?["string","number","bigint","boolean","symbol","object","function"]:["object"]:i.flags&Y.TypeFlags.NonPrimitive?["object"]:i.flags&Y.TypeFlags.Never?["never"]:null}function f(i){if(!n)return null;let o=t.esTreeNodeToTSNodeMap.get(i),a=n.getTypeAtLocation(o.expression);if(a.flags&Y.TypeFlags.Any||a.flags&Y.TypeFlags.Unknown)return null;let s=[];if(a.isUnion()){for(let g of a.types){let T=l(g);if(T)s.push(...T);else return null}return s}let c=l(a);return c?(s.push(...c),s):null}function p(i){if(!(i.operator==="==="||i.operator==="!=="))return;let a=null,s=null;if(r(i.left)?(a=i.left,s=i.right.type===de.Literal&&typeof i.right.value=="string"?i.right.value:null):r(i.right)&&(a=i.right,s=i.left.type===de.Literal&&typeof i.left.value=="string"?i.left.value:null),!a||!s||!Mn(s,jn))return;let c=f(a);if(!c)return;let g=i.operator==="!==",T=c.includes(s);c.length===1?T&&!g?e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:re(a,e),type:s}}):!T&&g?e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:re(a,e),type:Array.from(c)[0]}}):!T&&!g?e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:re(a,e),actualType:me(c),conditionType:s}}):T&&g&&e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:re(a,e),actualType:me(c),conditionType:s}}):!T&&!g?e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:re(a,e),actualType:me(c),conditionType:s}}):!T&&g&&e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:re(a,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 Mn(e,t){return t.has(e)}import{AST_NODE_TYPES as Un,ESLintUtils as Wn}from"@typescript-eslint/utils";var Vn=Wn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),bt="no-call-with-explicit-generics",Hn=$({functions:V(L())}),Yn=Vn({name:bt,meta:{type:"problem",docs:{description:"Enforce calling configured functions with inferred generics only"},messages:{noExplicitGenerics:"Function '{{ functionName }}' should be called with inferred generics (remove the explicit type parameters)"},schema:[Hn]},defaultOptions:[{functions:[]}],create(e,[t]){let n=new Set(t.functions);return{CallExpression(r){let{callee:l}=r;l.type===Un.Identifier&&n.has(l.name)&&r.typeArguments&&e.report({node:r,messageId:"noExplicitGenerics",data:{functionName:l.name}})}}}}),De={name:bt,rule:Yn};import{AST_NODE_TYPES as ye,ESLintUtils as zn}from"@typescript-eslint/utils";var Bn=zn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),xt="no-call-with-inferred-generics",qn=Bn({name:xt,meta:{type:"problem",docs:{description:"Disable calling configured functions with infered generics"},messages:{missingGenericDeclaration:"Function '{{ functionName }}' should be called with at least {{ minGenerics }} generic(s) (ex: `fn<Generic>()`) defined",anyUsedInGenerics:"Function '{{ functionName }}' should not be called with 'any' in generics"},schema:[{type:"object",properties:{functions:{type:"array",items:{type:"object",properties:{name:{type:"string"},minGenerics:{type:"number"},allowAny:{type:"boolean"},disallowTypes:{type:"array",items:{type:"string"}}},required:["name"]}},anyAliases:{type:"array",items:{type:"string"}}},required:["functions"]}]},defaultOptions:[{functions:[]}],create(e,[t]){let n=new Map(t.functions.map(r=>[r.name,r]));return{CallExpression(r){let{callee:l}=r;if(l.type!==ye.Identifier)return;let f=n.get(l.name);if(!f)return;let{minGenerics:p=1,allowAny:i,disallowTypes:o=t.disallowTypes}=f;(r.typeArguments?.params.length||0)<(p||0)&&e.report({node:r,messageId:"missingGenericDeclaration",data:{functionName:l.name,minGenerics:p||0}}),!(i&&!o)&&r.typeArguments?.params?.some(s=>!i&&s.type===ye.TSAnyKeyword||o&&s.type===ye.TSTypeReference&&s.typeName.type===ye.Identifier&&o.includes(s.typeName.name))&&e.report({node:r,messageId:"anyUsedInGenerics",data:{functionName:l.name}})}}}}),Le={name:xt,rule:qn};import{ESLintUtils as Kn,TSESTree as Ct}from"@typescript-eslint/utils";var Xn=Kn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),It="no-commented-out-code",Jn=["function ","class ","interface ","type ","enum ","namespace ","import ","export ","const ","let ","var ","return "],Gn=[") {","return;","if (","else {","for (","switch (","/>","</","},",": {"," } = ","={",/\w=("|')/,");"],Zn=Xn({name:It,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 r=n.trimStart();if(n.startsWith("*")||r.startsWith("INFO:")||r.startsWith("TODO:")||r.startsWith("DOCS:")||r.startsWith("FIX:")||r.startsWith("eslint-disable")||n.includes("@deprecated")||n.includes("@example"))return!1;for(let l of Jn)if(r.startsWith(l))return{wrongPattern:l};for(let l of Gn)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 r=e.sourceCode.getAllComments();for(let l of r)if(l.type===Ct.AST_TOKEN_TYPES.Line||l.type===Ct.AST_TOKEN_TYPES.Block){let f=t(l.value);f&&e.report({node:l,messageId:"commentedOutCode",data:{wrongPattern:f.wrongPattern}})}}}}}),$e={name:It,rule:Zn};import{ESLintUtils as Qn,TSESTree as er}from"@typescript-eslint/utils";var tr=Qn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),wt="no-default-export",nr=tr({name:wt,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===er.AST_NODE_TYPES.Identifier&&n.exported.name==="default"&&e.report({node:t,messageId:"noDefaultExport"})}}}}),Fe={name:wt,rule:nr};import{ESLintUtils as rr}from"@typescript-eslint/utils";var ir=rr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Rt="no-leaked-text-in-jsx",sr=[",",";","[","]","(",")"],or=ir({name:Rt,meta:{type:"problem",docs:{description:"Prevents leaking of text in JSX that should be wrapped in an expression container"},messages:{leakedTextInJSX:'Text "{{ text }}" should be wrapped in a JSX expression container.'},schema:[],fixable:"code"},defaultOptions:[],create(e){return{JSXText(t){let n=t.value.trim();if(!n)return;let r="";sr.includes(n)?r=n:n.includes("&&")?r="&&":n.includes("||")?r="||":n.endsWith("? (")&&(r="? ("),r&&e.report({node:t,messageId:"leakedTextInJSX",data:{text:r}})}}}}),je={name:Rt,rule:or};import{AST_NODE_TYPES as ie,ESLintUtils as ar}from"@typescript-eslint/utils";var lr=ar.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),kt="no-non-camel-case-functions",cr=/^[a-z][a-zA-Z0-9]*$/;function vt(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 pr=lr({name:kt,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&&!cr.test(t.id.name)){let n=t.returnType?.typeAnnotation;if(n&&(n.type===ie.TSTypeReference?vt(n):n.type===ie.TSUnionType&&n.types.some(l=>l.type===ie.TSTypeReference&&vt(l))))return;e.report({node:t.id,messageId:"nonCamelCaseFunction",data:{functionName:t.id.name}})}}}}}),Me={name:kt,rule:pr};import{ESLintUtils as ur,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*Ue(e){yield e,e.parent&&(yield*Ue(e.parent))}var fr=ur.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),At="no-optional-root-props",mr=fr({name:At,meta:{type:"problem",docs:{description:"Prevents usage of optional properties at the root of a type if that type is a local type alias or interface referenced only once"},messages:{optionalNotAllowed:'Optional property "{{ propertyName }}" is not allowed on a local type used only once. Use `prop: undefined | ...` instead.',suggestion:"Use `prop: undefined | ...` instead."},hasSuggestions:!0,schema:[]},defaultOptions:[],create(e){function t(r){let f=e.sourceCode.getDeclaredVariables(r)[0];if(!f||f.references.length!==1)return!1;let p=f.references[0];if(!p)return!1;for(let i of Ue(p.identifier)){if("returnType"in i||i.type===M.AST_NODE_TYPES.ExportNamedDeclaration)return!1;let o=i.parent;if(!o)return!1;if(o.type===M.AST_NODE_TYPES.TSTypeParameterInstantiation&&o.parent.type===M.AST_NODE_TYPES.TSTypeReference&&o.parent.typeName.type===M.AST_NODE_TYPES.Identifier&&o.parent.typeName.name==="FC"){let s=se(o.parent.parent,M.AST_NODE_TYPES.VariableDeclaration,4);if(!s)return!1;let c=ge(s,e.sourceCode);return c?!(c.parent.type===M.AST_NODE_TYPES.CallExpression&&c.parent.callee.type===M.AST_NODE_TYPES.Identifier&&c.parent.callee.name==="memo"):!1}if(i.type===M.AST_NODE_TYPES.AssignmentPattern)return!1;if(o.type===M.AST_NODE_TYPES.ArrowFunctionExpression){let a=se(o,M.AST_NODE_TYPES.VariableDeclaration);return a?!!ge(a,e.sourceCode):!1}if(o.type===M.AST_NODE_TYPES.FunctionDeclaration)return!!ge(o,e.sourceCode)}return!1}function n(r){r.key.type!==M.AST_NODE_TYPES.Identifier||!r.optional||e.report({node:r.key,messageId:"optionalNotAllowed",data:{propertyName:r.key.name},suggest:[{messageId:"suggestion",fix:l=>{let f=se(r,M.AST_NODE_TYPES.TSPropertySignature);if(!f)return null;let p=e.sourceCode.getText(f);return l.replaceText(f,p.replace("?:",": undefined |"))}}]})}return{TSTypeAliasDeclaration(r){if(r.typeAnnotation.type===M.AST_NODE_TYPES.TSTypeLiteral&&!(he(r)||!t(r)))for(let l of r.typeAnnotation.members)l.type===M.AST_NODE_TYPES.TSPropertySignature&&n(l)},TSInterfaceDeclaration(r){if(!(he(r)||!t(r)))for(let l of r.body.body)l.type===M.AST_NODE_TYPES.TSPropertySignature&&n(l)},TSTypeReference(r){if(r.typeName.type!==M.AST_NODE_TYPES.Identifier||r.typeName.name!=="FC"||!r.typeArguments?.params[0])return;let l=r.typeArguments.params[0];if(l.type!==M.AST_NODE_TYPES.TSTypeLiteral)return;let f=se(r.parent,M.AST_NODE_TYPES.VariableDeclaration,4);if(!f)return;let p=ge(f,e.sourceCode);if(!(!p||p.parent.type===M.AST_NODE_TYPES.CallExpression&&p.parent.callee.type===M.AST_NODE_TYPES.Identifier&&p.parent.callee.name==="memo"))for(let o of l.members)o.type===M.AST_NODE_TYPES.TSPropertySignature&&n(o)}}}});function he(e){return e?e.parent?.type===M.AST_NODE_TYPES.ExportNamedDeclaration||e.parent?.type===M.AST_NODE_TYPES.ExportDefaultDeclaration:!1}function ge(e,t){if(he(e))return;let n;if(e.type===M.AST_NODE_TYPES.VariableDeclaration){if(e.declarations.length!==1)return;e.declarations[0].id.type===M.AST_NODE_TYPES.Identifier&&(n=e.declarations[0].id)}else{if(!e.id)return;n=e.id}if(!n)return;let r=t.getScope(e);e.type===M.AST_NODE_TYPES.FunctionDeclaration&&r.upper&&(r=r.upper);let l=r.variables.find(p=>p.identifiers.includes(n));if(!l)return;let f=l.references.filter(p=>p.identifier!==n);if(!(f.length!==1||!f[0])&&!he(f[0].identifier.parent.parent))return f[0].identifier}var We={name:At,rule:mr};import{ESLintUtils as dr}from"@typescript-eslint/utils";import Ve from"node:path";var yr=dr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ot="no-relative-imports",gr=$({find:L(),replacement:L()}),hr=$({aliases:V(gr),rootDir:D(L()),allowNotFoundAliases:D(ne()),_dev_simulateFileName:D(L())}),Tr=yr({name:Ot,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:[hr]},defaultOptions:[{aliases:[],rootDir:void 0}],create(e,[t]){let n=t._dev_simulateFileName??e.filename;function r(p){return p.startsWith(".")||p.startsWith("..")}function l(p,i){let o=Ve.dirname(i);return Ve.resolve(o,p)}function f(p){let i=t.rootDir??process.cwd(),o=Ve.relative(i,p);if(o.startsWith("."))return null;o.startsWith("/")||(o=`/${o}`);for(let{find:a,replacement:s}of t.aliases)if(o.startsWith(s)){let c=o.replace(s,a);return{alias:a,newPath:c}}return null}return{ImportDeclaration(p){let i=p.source.value;if(!r(i))return;let o=l(i,n),a=f(o);!a&&t.allowNotFoundAliases||e.report({node:p,messageId:a?"noRelativeImportsWithAlias":"noRelativeImports",data:{alias:a?.alias},fix:a?s=>s.replaceText(p.source,`'${a.newPath}'`):void 0})}}}}),He={name:Ot,rule:Tr};import{AST_NODE_TYPES as le,ESLintUtils as Nt}from"@typescript-eslint/utils";import*as Ye from"typescript";var Sr=Nt.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Pt="no-unnecessary-casting",Er=$({additionalCastFunctions:D(V($({name:L(),expectedType:fe(["string","number"])})))}),ze={name:Pt,rule:Sr({name:Pt,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:[Er],fixable:"code"},defaultOptions:[{}],create(e){let n=e.options[0].additionalCastFunctions||[],r=[{name:"Number",expectedType:"number"},{name:"String",expectedType:"string"},...n],l=Nt.getParserServices(e,!0),f=l.program?.getTypeChecker();if(!f||!l.program)throw new Error("TypeScript services or program not available");function p(s,c){switch(s.type){case le.Literal:return c==="number"?typeof s.value=="number":typeof s.value=="string";case le.TemplateLiteral:return c==="string";case le.UnaryExpression:return c==="number"?s.operator==="+"||s.operator==="-"||s.operator==="~":!1;default:return!1}}function i(s,c){return c==="number"?!!(s.flags&Ye.TypeFlags.NumberLike):!!(s.flags&Ye.TypeFlags.StringLike)}function o(s,c){return g=>g.replaceText(s,e.sourceCode.getText(c))}function a(s){if(!f||s.arguments.length!==1)return;let c=s.arguments[0];if(!c||c.type===le.SpreadElement)return;let{callee:g}=s;if(g.type!==le.Identifier)return;let T=g.name,S=r.find(b=>b.name===T);if(!S)return;if(p(c,S.expectedType)||i(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:s,messageId:b,...y?{data:y}:{},fix:o(s,c)})}}return{CallExpression:a}}})};import{AST_NODE_TYPES as j,ESLintUtils as br}from"@typescript-eslint/utils";var xr=br.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function _t(e){let t=[];for(let n of e.members)n.type===j.TSPropertySignature&&n.key.type===j.Identifier&&t.push([n.key.name,n]);return t}function Dt(e,...t){for(let n of t)e.set(...n);return e}var Cr=$({forceCheckOnFCPropTypesWithName:D(V(L()))}),Lt="no-unused-type-props-in-args",Be=null,Ir=xr({name:Lt,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:[Cr],fixable:"code"},defaultOptions:[{}],create(e,[t]){let{forceCheckOnFCPropTypesWithName:n}=t;n&&!Be&&(Be=n.map(i=>new RegExp(i)));function r(i,o,a,s,c=!0){let g=a.name,T=e.sourceCode.getScope(o).references.find(b=>b.identifier.name===g)?.resolved,S=i&&Be?.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===j.ExportNamedDeclaration)){if(d?.type===j.TSTypeAliasDeclaration){l(i,o,s,d.typeAnnotation,!0);return}if(d?.type===j.TSInterfaceDeclaration){l(i,o,s,d.body,!0);return}}}function l(i,o,a,s,c){if(s.type===j.TSInterfaceBody){for(let g of s.body)g.type===j.TSPropertySignature&&g.key.type===j.Identifier&&a.set(g.key.name,g);return}if(s.type===j.TSTypeLiteral){Dt(a,..._t(s));return}if(s.type===j.TSIntersectionType){for(let g of s.types)l(i,o,a,g,!0);return}c||s.type===j.TSTypeReference&&s.typeName.type===j.Identifier&&r(i,o,s.typeName,a)}function f(i,o,a){for(let s of a)if(s.type==="ObjectPattern"&&s.typeAnnotation){let c=new Map;if(l(i,o,c,s.typeAnnotation.typeAnnotation,!1),c.size===0)continue;p(s,c)}else s.type===j.AssignmentPattern&&s.left.type===j.ObjectPattern&&f(i,o,[s.left])}function p(i,o){let a=[];if(i.properties.at(-1)?.type===j.RestElement)return;for(let T of i.properties)T.type===j.Property&&T.key.type===j.Identifier&&a.push(T.key.name);let c=[],g=[];for(let[T,S]of o)a.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=i.properties.at(-1),y=g.join(", ");return b?b?.type===j.RestElement?null:d.insertTextAfter(b,`, ${y}`):d.insertTextBeforeRange([i.range[0]+1,i.range[1]],`${y}`)}:void 0})}return{VariableDeclaration(i){let o=i.declarations[0];if(!o)return;let a=new Map,s=o.id.type===j.Identifier&&o.id.typeAnnotation?.typeAnnotation.type===j.TSTypeReference&&o.id.typeAnnotation.typeAnnotation.typeName.type===j.Identifier&&o.id.typeAnnotation.typeAnnotation.typeName.name==="FC"&&o.id.typeAnnotation.typeAnnotation.typeArguments?.params[0];if(s){if(s.type===j.TSTypeReference&&s.typeName.type===j.Identifier)r(!0,i,s.typeName,a,!1);else if(s.type===j.TSTypeLiteral)Dt(a,..._t(s));else if(s.type===j.TSIntersectionType)for(let c of s.types)c.type===j.TSTypeReference&&c.typeName.type===j.Identifier?r(!0,i,c.typeName,a,!1):l(!0,i,a,c,!0);if(a.size!==0&&o.init?.type===j.ArrowFunctionExpression){let c=o.init.params[0];if(!c){e.report({node:o.init,messageId:"missingComponentParam"});return}c.type===j.ObjectPattern&&p(c,a)}}},FunctionDeclaration:function(i){f(!1,i,i.params)},ArrowFunctionExpression(i){f(!1,i,i.params)}}}}),qe={name:Lt,rule:Ir};import{AST_NODE_TYPES as Ke,ESLintUtils as wr}from"@typescript-eslint/utils";var Rr=wr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ft="prefer-named-functions",$t=new Map,vr=Rr({name:Ft,meta:{hasSuggestions:!0,type:"suggestion",docs:{description:"Prevent using arrow functions when a named function can be used instead"},schema:[{type:"object",properties:{ignoreRegex:{type:"string"},disallowArrowFnWithImplicitReturns:{type:"boolean"}}}],messages:{suggestion:"Convert to named function",default:'Function {{functionName}} should be defined as a named function "function {{functionName}} () {}" instead of an arrow function',withIgnoreRegex:'Function {{functionName}} should be defined as a named function "function {{functionName}} () {}", if not possible to use `function` you can also use a name that matches the rule ignore regex'}},defaultOptions:[{}],create(e,[t]){let n=null;if(t.ignoreRegex){let r=$t.get(t.ignoreRegex);r?n=r:(n=new RegExp(t.ignoreRegex),$t.set(t.ignoreRegex,n))}return{VariableDeclarator(r){if(r.init&&r.init.type===Ke.ArrowFunctionExpression&&r.id.type===Ke.Identifier){let l=r.id.name;if(r.id.typeAnnotation||n&&n.test(l)||!t.disallowArrowFnWithImplicitReturns&&r.init.body.type!==Ke.BlockStatement)return;let f=r.parent,p=r.init.params,i=r.init.body,o=r.init;e.report({node:r.id,messageId:n?"withIgnoreRegex":"default",data:{functionName:l,ignoreRegex:t.ignoreRegex},suggest:[{messageId:"suggestion",fix:a=>a.replaceText(f,`${o.async?"async ":""}function ${l}(${p.map(s=>e.sourceCode.getText(s)).join(", ")||""}) ${e.sourceCode.getText(i)}`)}]})}}}}}),Xe={name:Ft,rule:vr};import{AST_NODE_TYPES as W,AST_TOKEN_TYPES as jt,ESLintUtils as kr}from"@typescript-eslint/utils";var Ar=kr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ut="prefer-single-line-if",Or=$({maxLineLength:D(J()),maxNonSimpleConditionLength:D(J())}),Pr=Ar({name:Ut,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:[Or]},defaultOptions:[{}],create(e,[t]){let n=e.sourceCode;return{IfStatement(r){if(r.consequent.type!==W.BlockStatement||r.loc.start.line===r.loc.end.line||n.getCommentsInside(r.consequent).length>0||r.alternate||r.consequent.body.length!==1)return;let f=r.consequent.body[0];if(f.type===W.ReturnStatement){if(!Vt(f))return}else if(!(f.type===W.ContinueStatement||f.type===W.BreakStatement))return;if(r.test.type===W.LogicalExpression||r.test.type===W.ConditionalExpression)return;let p;if(t.maxNonSimpleConditionLength){let c=Mt(r.test);if(!c&&r.test.type===W.UnaryExpression&&r.test.operator==="!"){let g=r.test.argument;Mt(g)&&(c=!0)}if(c&&(p=n.getText(r.test),p.length>t.maxNonSimpleConditionLength))return}p||(p=n.getText(r.test));let i=n.getText(f);if(p.includes(`
|
|
15
|
-
`))return;let o=n.getTokenAfter(r);if(o&&o.type===jt.Punctuator&&o.value==="}"){let c=n.getTokenAfter(o);if(c&&c.type===jt.Keyword&&(c.value==="else"||c.value==="catch"))return}let a=Nr(n,r),s=`if (${p}) ${i}`;t.maxLineLength&&s.length+a.length>t.maxLineLength||e.report({node:r,messageId:"noSingleLineCurly",fix:c=>c.replaceText(r,s)})}}}});function Mt(e){return e.type===W.CallExpression||e.type===W.BinaryExpression||e.type===W.MemberExpression&&Wt(e)}function Wt(e){return e.object.type===W.MemberExpression?Wt(e.object):e.object.type!==W.Identifier}function Nr(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}function Vt(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?Vt(t):!1}var Je={name:Ut,rule:Pr};import{AST_NODE_TYPES as q,ESLintUtils as _r}from"@typescript-eslint/utils";var Dr=_r.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ht="react-compiler-migration",Lr=$({disallowHooks:D(V($({name:L(),replacement:L()}))),disallowMethods:D(V($({name:L(),replacement:D(L()),requireTrueProp:D(L())})))}),$r=/eslint +react-compiler\/react-compiler: +\["error/;function Fr(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 jr=Dr({name:Ht,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:[Lr]},defaultOptions:[{}],create(e,[t]){let n=!1;for(let r of e.sourceCode.getAllComments())if($r.test(r.value)){n=!0;break}return n?{CallExpression(r){if(t.disallowHooks?.length){let l=null,f=null;if(r.callee.type===q.Identifier?(l=r.callee.name,f=r.callee):r.callee.type===q.MemberExpression&&r.callee.property.type===q.Identifier&&(l=r.callee.property.name,f=r.callee.property),l){let p=t.disallowHooks.find(i=>i.name===l);p&&f&&e.report({node:r,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:p.name,replacement:p.replacement},suggest:[{messageId:"replace",data:{replacement:p.replacement},fix:i=>i.replaceText(f,p.replacement)}]})}}if(t.disallowMethods?.length&&Fr(r.callee)){for(let l of r.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,i=t.disallowMethods.find(o=>o.name===p);if(i){if(i.requireTrueProp){let o=i.requireTrueProp,a=!1;for(let s of l.properties)if(s.type===q.Property&&s.key.type===q.Identifier&&s.key.name===o&&s.value.type===q.Literal&&s.value.value===!0){a=!0;break}if(!a){e.report({node:f,messageId:"disallowedMethodWithMissingRequireTrueProp",data:{method:i.name,requireTrueProp:o}});continue}}i.replacement&&e.report({node:f,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:i.name,replacement:i.replacement},suggest:[{messageId:"replace",data:{replacement:i.replacement},fix:o=>o.replaceText(f.key,i.replacement)}]})}}}}}}:{}}}),Ge={name:Ht,rule:jr};import{ESLintUtils as Mr,TSESTree as Ur}from"@typescript-eslint/utils";var Wr=Mr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Yt="require-description",Vr=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,Hr=/^eslint-disable-(next-)?line$/u,Yr=Wr({name:Yt,meta:{type:"problem",docs:{description:"Require descriptions for eslint directives."},messages:{missingDescription:"Unexpected undescribed directive comment. Include descriptions to explain why the comment is necessary."},schema:[{type:"object",properties:{ignore:{type:"array",items:{type:"string",enum:["eslint","eslint-disable","eslint-disable-line","eslint-disable-next-line","eslint-enable","eslint-env","exported","global","globals"]},additionalItems:!1,uniqueItems:!0}},additionalProperties:!1}]},defaultOptions:[{ignore:[]}],create(e,[t]){let n=e.sourceCode,r=new Set(t.ignore||[]);return{Program(){for(let l of n.getAllComments()){let f=zr(l);f!=null&&(r.has(f.kind)||f.description||e.report({loc:qr(l.loc),messageId:"missingDescription"}))}}}}}),zt={name:Yt,rule:Yr};function zr(e){let{text:t,description:n}=Br(e.value);if(!t)return null;let r=Vr.exec(t);if(!r)return null;let l=r[1];if(!l)return null;let f=Hr.test(l);if(e.type===Ur.AST_TOKEN_TYPES.Line&&!f||f&&e.loc.start.line!==e.loc.end.line)return null;let p=t.slice(r.index+l.length);return{kind:l,value:p.trim(),description:n}}function Br(e){let t=e.split(/\s-{2,}\s/u);return{text:t[0]?.trim(),description:t.length>1?t[1]?.trim()??null:null}}function qr(e){return{start:{line:e.start.line,column:-1},end:e.end}}function Kt(e){return/^use[A-Z0-9]/.test(e)}function Te(e){return e.type==="Identifier"?Kt(e.name):e.type==="MemberExpression"&&!e.computed&&Te(e.property)?e.object.type==="Identifier":!1}function Xt(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function Jt(e,t){return e.name===t||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===t}function Gt(e){return!!(e.parent&&e.parent.callee&&Jt(e.parent.callee,"forwardRef"))}function Zt(e){return!!(e.parent&&e.parent.callee&&Jt(e.parent.callee,"memo"))}function Ze(e){for(;e;){let t=en(e);if(t&&(Xt(t)||Te(t))||Gt(e)||Zt(e))return!0;e=e.parent}return!1}function Bt(e){return!1}function Qe(e){return!1}var Kr=/eslint +react-compiler\/react-compiler: +\["error/,Qt={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 o of e.sourceCode.getAllComments())if(Kr.test(o.value))return{CallExpression(a){let s=null;a.callee.name==="useMemo"?s="useMemo":a.callee.name==="useCallback"&&(s="useCallback"),s&&e.report({node:a,message:`"${s}" is not necessary when using React Compiler.`})}}}let t=typeof e.getSource=="function"?o=>t(o):o=>e.sourceCode.getText(o),n=typeof e.getScope=="function"?()=>n():o=>e.sourceCode.getScope(o),r=null,l=[],f=[],p=new WeakSet;function i(o){for(let a of o.references){let s=a.identifier.parent;if(s.type==="VariableDeclarator"&&s.init&&s.init.type==="CallExpression"&&s.init.callee&&Bt(s.init.callee))for(let c of a.resolved.references)c!==a&&p.add(c.identifier)}}return{onCodePathSegmentStart:o=>f.push(o),onCodePathSegmentEnd:()=>f.pop(),onCodePathStart:()=>l.push(new Map),onCodePathEnd(o,a){let s=l.pop();if(s.size===0)return;let c=new Set;function g(h,w){let{cache:R}=g,k=R.get(h.id),_=new Set(w);if(_.has(h.id)){let A=[..._],U=A.slice(A.indexOf(h.id)+1);for(let X of U)c.add(X);return BigInt("0")}if(_.add(h.id),k!==void 0)return k;if(o.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,_)}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),_=new Set(w);if(_.has(h.id)){let A=Array.from(_),U=A.slice(A.indexOf(h.id)+1);for(let X of U)c.add(X);return BigInt("0")}if(_.add(h.id),k!==void 0)return k;if(o.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,_)}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 _=S(k);_<R&&(R=_)}R+=1}return w.set(h.id,R),R}g.cache=new Map,T.cache=new Map,S.cache=new Map;let d=T(o.initialSegment),b=en(a),y=Ze(a),N=b?Xt(b)||Te(b):Gt(a)||Zt(a),v=1/0;for(let h of o.finalSegments){if(!h.reachable)continue;let w=S(h);w<v&&(v=w)}for(let[h,w]of s){if(!h.reachable)continue;let R=h.nextSegments.length===0?v<=S(h):v<S(h),k=g(h)*T(h),_=c.has(h.id);for(let A of w)if(_&&!Qe(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(a.async&&e.report({node:A,message:`React Hook "${t(A)}" cannot be called in an async function.`}),!_&&k!==d&&!Qe(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(a.parent&&(a.parent.type==="MethodDefinition"||a.parent.type==="ClassProperty")&&a.parent.value===a){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(a.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&&!Qe(A)){if(a.parent.type==="CallExpression"&&a.parent.callee.type==="Identifier"&&a.parent.callee.name==="useCallback"){let X=a.parent;if(X.parent.type==="VariableDeclarator"&&Kt(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(o){if(Te(o.callee)){let a=qt(l),s=qt(f),c=a.get(s);c||(c=[],a.set(s,c)),c.push(o.callee)}o.callee.type==="Identifier"&&(o.callee.name==="useEffect"||Bt(o.callee))&&o.arguments.length>0&&(r=o)},Identifier(o){r==null&&p.has(o)&&o.parent.type!=="CallExpression"&&e.report({node:o,message:`\`${t(o)}\` 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"(o){o===r&&(r=null)},FunctionDeclaration(o){Ze(o)&&i(n(o))},ArrowFunctionExpression(o){Ze(o)&&i(n(o))}}}};function en(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 qt(e){return e[e.length-1]}var tn={[qe.name]:qe.rule,[$e.name]:$e.rule,[Le.name]:Le.rule,"rules-of-hooks":Qt,"exhaustive-deps":yt,"require-description":zt.rule,[Fe.name]:Fe.rule,[Me.name]:Me.rule,[Xe.name]:Xe.rule,[ve.name]:ve.rule,[De.name]:De.rule,[He.name]:He.rule,[Je.name]:Je.rule,[We.name]:We.rule,[je.name]:je.rule,[Ae.name]:Ae.rule,[Ge.name]:Ge.rule,[we.name]:we.rule,[_e.name]:_e.rule,[ze.name]:ze.rule};var xs={rules:tn};export{xs as extendedLintPlugin};
|
|
14
|
+
Learn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching`});let R=o.acquire(h),O=new Set,L=null;{let f=R.upper;for(;f&&(O.add(f),f.type!=="function");)f=f.upper;if(!f)return;L=f}let k=Array.isArray;function V(f){if(!k(f.defs))return!1;let m=f.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&&(_e(L.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:A}=I;if(A==="useRef"&&C.type==="Identifier")return!0;if(jn(I)&&C.type==="Identifier"){for(let P of f.references)P!==C&&y.add(P.identifier);return!0}else if(A==="useState"||A==="useReducer"){if(C.type==="ArrayPattern"&&C.elements.length===2&&k(f.identifiers)){if(C.elements[1]===f.identifiers[0]){if(A==="useState"){let P=f.references,q=0;for(let Q=0;Q<P.length;Q++){if(P[Q].isWrite()&&q++,q>1)return!1;l.set(P[Q].identifier,C.elements[0])}}return!0}else if(C.elements[0]===f.identifiers[0]){if(A==="useState"){let P=f.references;for(let q=0;q<P.length;q++)s.add(P[q].identifier)}return!1}}}else if(A==="useTransition"&&C.type==="ArrayPattern"&&C.elements.length===2&&Array.isArray(f.identifiers)&&C.elements[1]===f.identifiers[0])return!0;return!1}function Z(f){if(!k(f.defs))return!1;let m=f.defs[0];if(m==null||m.node==null||m.node.id==null)return!1;let E=m.node,x=L.childScopes,I=null,C;for(C=0;C<x.length;C++){let A=x[C],P=A.block;if(E.type==="FunctionDeclaration"&&P===E||E.type==="VariableDeclarator"&&P.parent===E){I=A;break}}if(I==null)return!1;for(C=0;C<I.through.length;C++){let A=I.through[C];if(A.resolved!=null&&O.has(A.resolved.scope)&&!nt(A.resolved))return!1}return!0}let nt=S(V,p),an=S(Z,g),rt=new Map;function ln(f){let m=f.from,E=!1;for(;m.block!==h;)m.type==="function"&&(E=m.block.parent!=null&&m.block.parent.type==="ReturnStatement"),m=m.upper;return E}let B=new Map,Ee=new Map;it(R);function it(f){for(let m of f.references){if(!m.resolved||!O.has(m.resolved.scope))continue;let E=_e(h,m.identifier),x=ht(E),I=ee(x,Ee);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"&&ln(m)&&rt.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===h.parent)&&C.type!=="TypeParameter")if(B.has(I))B.get(I).references.push(m);else{let A=m.resolved,P=nt(A)||an(A);B.set(I,{isStable:P,references:[m]})}}for(let m of f.childScopes)it(m)}rt.forEach(({reference:f,dependencyNode:m},E)=>{let x=f.resolved.references,I=!1;for(let C=0;C<x.length;C++){let{identifier:A}=x[C],{parent:P}=A;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||i({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 be=new Set;function cn(f,m){be.has(m)||(be.add(m),i({node:f,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 ue=new Set;if(B.forEach(({isStable:f,references:m},E)=>{f&&ue.add(E),m.forEach(x=>{x.writeExpr&&cn(x.writeExpr,E)})}),be.size>0)return;if(!_){let f=null;if(B.forEach(({isStable:m,references:E},x)=>{f||E.forEach(I=>{if(f)return;let C=I.identifier;if(!l.has(C))return;let P=I.from;for(;P.type!=="function";)P=P.upper;P.block===h&&(f=x)})}),f){let{suggestedDependencies:m}=Pe({dependencies:B,declaredDependencies:[],stableDependencies:ue,externalDependencies:new Set,isEffect:!0});i({node:v,message:`React Hook ${T} contains a call to '${f}'. Without a list of dependencies, this can lead to an infinite chain of updates. To fix this, pass [`+m.join(", ")+`] as a second argument to the ${T} Hook.`,suggest:[{desc:`Add dependencies array: [${m.join(", ")}]`,fix(E){return E.insertTextAfter(h,`, [${m.join(", ")}]`)}}]})}return}let ae=[],le=new Set;_.type!=="ArrayExpression"?i({node:_,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.`}):_.elements.forEach(f=>{if(f===null)return;if(f.type==="SpreadElement"){i({node:f,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}y.has(f)&&i({node:f,message:`Functions returned from \`useEffectEvent\` must not be included in the dependency array. Remove \`${n(f)}\` from the list.`,suggest:[{desc:`Remove the dependency \`${n(f)}\``,fix(I){return I.removeRange(f.range)}}]});let m;try{m=ee(f,Ee)}catch(I){if(/Unsupported node type/.test(I.message)){f.type==="Literal"?B.has(f.value)?i({node:f,message:`The ${f.raw} literal is not a valid dependency because it never changes. Did you mean to include ${f.value} in the array instead?`}):i({node:f,message:`The ${f.raw} literal is not a valid dependency because it never changes. You can safely remove it.`}):i({node:f,message:`React Hook ${n(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=f;for(;E.type==="MemberExpression"||E.type==="OptionalMemberExpression"||E.type==="ChainExpression";)E=E.object||E.expression.object;let x=!L.through.some(I=>I.identifier===E);ae.push({key:m,node:f}),x||le.add(m)});let{suggestedDependencies:un,unnecessaryDependencies:pe,missingDependencies:te,duplicateDependencies:st}=Pe({dependencies:B,declaredDependencies:ae,stableDependencies:ue,externalDependencies:le,isEffect:w}),fe=un;if(st.size+te.size+pe.size===0){if(t)return;Fn({declaredDependencies:ae,declaredDependenciesNode:_,componentScope:L,scope:R}).forEach(({construction:m,isUsedOutsideOfHook:E,depType:x})=>{let I=x==="function"?"useCallback":"useMemo",C=x==="function"?"definition":"initialization",A=`wrap the ${C} of '${m.name.name}' in its own ${I}() Hook.`,P=E?`To fix this, ${A}`:`Move it inside the ${T} callback. Alternatively, ${A}`,q=x==="conditional"||x==="logical expression"?"could make":"makes",Q=`The '${m.name.name}' ${x} ${q} the dependencies of ${T} Hook (at line ${_.loc.start.line}) change on every render. ${P}`,ot;E&&m.type==="Variable"&&x==="function"&&(ot=[{desc:`Wrap the ${C} of '${m.name.name}' in its own ${I}() Hook.`,fix(at){let[fn,mn]=I==="useMemo"?["useMemo(() => { return ","; })"]:["useCallback(",")"];return[at.insertTextBefore(m.node.init,fn),at.insertTextAfter(m.node.init,mn)]}}]),i({node:m.node,message:Q,suggest:ot})});return}!w&&te.size>0&&(fe=Pe({dependencies:B,declaredDependencies:[],stableDependencies:ue,externalDependencies:le,isEffect:w}).suggestedDependencies);function pn(){if(ae.length===0)return!0;let f=ae.map(E=>E.key),m=f.slice().sort();return f.join(",")===m.join(",")}pn()&&fe.sort();function xe(f){let m=f.split("."),E="";for(let x=0;x<m.length;x++){if(x!==0){let I=m.slice(0,x+1).join("."),C=Ee.get(I)===!0;E+=C?"?.":"."}E+=m[x]}return E}function Ce(f,m,E,x){return f.size===0?null:(f.size>1?"":m+" ")+E+" "+(f.size>1?"dependencies":"dependency")+": "+Ln(Array.from(f).sort().map(I=>"'"+xe(I)+"'"))+`. Either ${x} ${f.size>1?"them":"it"} or remove the dependency array.`}let J="";if(pe.size>0){let f=null;if(Array.from(pe.keys()).forEach(m=>{f===null&&m.endsWith(".current")&&(f=m)}),f!==null)J=` Mutable values like '${f}' aren't valid dependencies because mutating them doesn't re-render the component.`;else if(le.size>0){let m=Array.from(le)[0];R.set.has(m)||(J=` Outer scope values like '${m}' aren't valid dependencies because mutating them doesn't re-render the component.`)}}if(!J&&te.has("props")){let f=B.get("props");if(f==null)return;let m=f.references;if(!Array.isArray(m))return;let E=!0;for(let x=0;x<m.length;x++){let I=m[x],C=_e(L.block,I.identifier);if(!C){E=!1;break}let A=C.parent;if(A==null){E=!1;break}if(A.type!=="MemberExpression"&&A.type!=="OptionalMemberExpression"){E=!1;break}}E&&(J=` However, 'props' will change when *any* prop changes, so the preferred fix is to destructure the 'props' object outside of the ${T} call and refer to those specific props inside ${n(v)}.`)}if(!J&&te.size>0){let f=null;te.forEach(m=>{if(f)return;let E=L.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,A;for(let P=0;P<x.references.length;P++)if(A=x.references[P].identifier,A!=null&&A.parent!=null&&(A.parent.type==="CallExpression"||A.parent.type==="OptionalCallExpression")&&A.parent.callee===A){C=!0;break}C&&(f=m)}),f!==null&&(J=` If '${f}' changes too often, find the parent component that defines it and wrap that definition in useCallback.`)}if(!J&&te.size>0){let f=null;if(te.forEach(m=>{if(f!==null)return;let x=B.get(m).references,I,C;for(let A=0;A<x.length;A++){for(I=x[A].identifier,C=I.parent;C!=null&&C!==L.block;){if(C.type==="CallExpression"){let P=l.get(C.callee);if(P!=null){if(P.name===m)f={missingDep:m,setter:C.callee.name,form:"updater"};else if(s.has(I))f={missingDep:m,setter:C.callee.name,form:"reducer"};else{let q=x[A].resolved;if(q!=null){let Q=q.defs[0];Q!=null&&Q.type==="Parameter"&&(f={missingDep:m,setter:C.callee.name,form:"inlineReducer"})}}break}}C=C.parent}if(f!==null)break}}),f!==null)switch(f.form){case"reducer":J=` You can also replace multiple useState variables with useReducer if '${f.setter}' needs the current value of '${f.missingDep}'.`;break;case"inlineReducer":J=` If '${f.setter}' needs the current value of '${f.missingDep}', you can also switch to useReducer instead of useState and read '${f.missingDep}' in the reducer.`;break;case"updater":J=` You can also do a functional update '${f.setter}(${f.missingDep.slice(0,1)} => ...)' if you only need '${f.missingDep}' in the '${f.setter}' call.`;break;default:throw new Error("Unknown case.")}}i({node:_,message:`React Hook ${n(v)} has `+(Ce(te,"a","missing","include")||Ce(pe,"an","unnecessary","exclude")||Ce(st,"a","duplicate","omit"))+J,suggest:[{desc:`Update the dependencies array to be: [${fe.map(xe).join(", ")}]`,fix(f){return f.replaceText(_,`[${fe.map(xe).join(", ")}]`)}}]})}function b(h){let _=Dn(h.callee,c);if(_===-1)return;let v=h.arguments[_],T=h.callee,w=Tt(T).name,R=h.arguments[_+1],O=/Effect($|[^a-z])/g.test(w);if(!v){i({node:T,message:`React Hook ${w} requires an effect callback. Did you forget to pass a callback to the hook?`});return}if(!(t&&!O)){if(!R&&!O){(w==="useMemo"||w==="useCallback")&&i({node:T,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,T,w,O);return;case"Identifier":if(!R||R.elements&&R.elements.some(V=>V&&V.type==="Identifier"&&V.name===v.name))return;let L=r(h).set.get(v.name);if(L==null||L.defs==null)return;let k=L.defs[0];if(!k||!k.node||k.type!=="Variable"&&k.type!=="FunctionName")break;switch(k.node.type){case"FunctionDeclaration":d(k.node,R,T,w,O);return;case"VariableDeclarator":let V=k.node.init;if(!V)break;switch(V.type){case"ArrowFunctionExpression":case"FunctionExpression":d(V,R,T,w,O);return}break}break;default:i({node:T,message:`React Hook ${w} received a function whose dependencies are unknown. Pass an inline function instead.`});return}i({node:T,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(L){return L.replaceText(R,`[${v.name}]`)}}]})}}if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let h of e.sourceCode.getAllComments())if(_n.test(h.value))return t=!0,{CallExpression:_=>b(_,!0)}}return{CallExpression:h=>b(h)}}};function Pe({dependencies:e,declaredDependencies:t,stableDependencies:n,externalDependencies:r,isEffect:a}){let u=c();function c(){return{isUsed:!1,isSatisfiedRecursively:!1,isSubtreeUsed:!1,children:new Map}}e.forEach((d,b)=>{let h=i(u,b);h.isUsed=!0,o(u,b,_=>{_.isSubtreeUsed=!0})}),t.forEach(({key:d})=>{let b=i(u,d);b.isSatisfiedRecursively=!0}),n.forEach(d=>{let b=i(u,d);b.isSatisfiedRecursively=!0});function i(d,b){let h=b.split("."),_=d;for(let v of h){let T=_.children.get(v);T||(T=c(),_.children.set(v,T)),_=T}return _}function o(d,b,h){let _=b.split("."),v=d;for(let T of _){let w=v.children.get(T);if(!w)return;h(w),v=w}}let l=new Set,s=new Set;p(u,l,s,d=>d);function p(d,b,h,_){d.children.forEach((v,T)=>{let w=_(T);if(v.isSatisfiedRecursively){v.isSubtreeUsed&&h.add(w);return}if(v.isUsed){b.add(w);return}p(v,b,h,R=>w+"."+R)})}let g=[],y=new Set,S=new Set;return t.forEach(({key:d})=>{s.has(d)?g.indexOf(d)===-1?g.push(d):S.add(d):y.add(d)}),l.forEach(d=>{g.push(d)}),{suggestedDependencies:g,unnecessaryDependencies:y,duplicateDependencies:S,missingDependencies:l}}function ne(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 ne(e.consequent)!=null||ne(e.alternate)!=null?"conditional":null;case"LogicalExpression":return ne(e.left)!=null||ne(e.right)!=null?"logical expression":null;case"JSXFragment":return"JSX fragment";case"JSXElement":return"JSX element";case"AssignmentExpression":return ne(e.right)!=null?"assignment expression":null;case"NewExpression":return"object construction";case"Literal":return e.value instanceof RegExp?"regular expression":null;case"TypeCastExpression":return ne(e.expression);case"TSAsExpression":return ne(e.expression)}return null}function Fn({declaredDependencies:e,declaredDependenciesNode:t,componentScope:n,scope:r}){let a=e.map(({key:c})=>{let i=n.variables.find(l=>l.name===c);if(i==null)return null;let o=i.defs[0];if(o==null)return null;if(o.type==="Variable"&&o.node.type==="VariableDeclarator"&&o.node.id.type==="Identifier"&&o.node.init!=null){let l=ne(o.node.init);if(l!=null)return[i,l]}return o.type==="FunctionName"&&o.node.type==="FunctionDeclaration"?[i,"function"]:o.type==="ClassName"&&o.node.type==="ClassDeclaration"?[i,"class"]:null}).filter(Boolean);function u(c){let i=!1;for(let o=0;o<c.references.length;o++){let l=c.references[o];if(l.writeExpr){if(i)return!0;i=!0;continue}let s=l.from;for(;s!==r&&s!=null;)s=s.upper;if(s!==r&&!Et(t,l.identifier))return!0}return!1}return a.map(([c,i])=>({construction:c.defs[0],depType:i,isUsedOutsideOfHook:u(c)}))}function ht(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)?ht(e.parent):e.type==="MemberExpression"&&e.parent&&e.parent.type==="AssignmentExpression"&&e.parent.left===e?e.object:e}function Ne(e,t,n){t&&(e.optional?t.has(n)||t.set(n,!0):t.has(n)||t.set(n,!1))}function ee(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=ee(e.object,t),r=ee(e.property,null),a=`${n}.${r}`;return Ne(e,t,a),a}else if(e.type==="OptionalMemberExpression"&&!e.computed){let n=ee(e.object,t),r=ee(e.property,null),a=`${n}.${r}`;return Ne(e,t,a),a}else if(e.type==="ChainExpression"&&!e.computed){let n=e.expression;if(n.type==="CallExpression")throw new Error(`Unsupported node type: ${n.type}`);let r=ee(n.object,t),a=ee(n.property,null),u=`${r}.${a}`;return Ne(n,t,u),u}else throw new Error(`Unsupported node type: ${e.type}`)}function Tt(e,t){return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.object.name==="React"&&e.property.type==="Identifier"&&!e.computed?e.property:e}function Dn(e,t){let n=Tt(e);if(n.type!=="Identifier")return-1;switch(n.name){case"useEffect":case"useLayoutEffect":case"useCallback":case"useMemo":return 0;case"useImperativeHandle":return 1;default:if(n===e&&t&&t.additionalHooks){let r;try{r=ee(n,null)}catch(a){if(/Unsupported node type/.test(a.message))return 0;throw a}return t.additionalHooks.test(r)?0:-1}else return-1}}function _e(e,t){let n=[e],r=null;for(;n.length;){if(r=n.shift(),$n(r,t))return r;if(Et(r,t))for(let[a,u]of Object.entries(r))a!=="parent"&&(gt(u)?(u.parent=r,n.push(u)):Array.isArray(u)&&u.forEach(c=>{gt(c)&&(c.parent=r,n.push(c))}))}return null}function Ln(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 gt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function $n(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 Et(e,t){return e.range[0]<=t.range[0]&&e.range[1]>=t.range[1]}function jn(e){return!1}import{AST_NODE_TYPES as ye,ESLintUtils as xt}from"@typescript-eslint/utils";import z from"typescript";var Mn=xt.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),bt="improved-no-unnecessary-condition",Un=D({}),Vn=["string","number","bigint","boolean","symbol","undefined","object","function","never"],Wn=new Set(Vn),Fe={name:bt,rule:Mn({name:bt,meta:{type:"suggestion",docs:{description:"Extends checks of `no-unnecessary-condition` rule"},messages:{unnecessaryTypeofCondition:'This condition is unnecessary. The type of "{{name}}" is always "{{type}}".',alwaysFalseTypeofCondition:'This condition will always be false. The type of "{{name}}" is "{{actualType}}" so the condition has no overlap with "{{conditionType}}".'},schema:[Un]},defaultOptions:[{}],create(e){let t=xt.getParserServices(e,!0),n=t.program?.getTypeChecker();if(!n||!t.program)throw new Error("TypeScript services or program not available");function r(i){return i.type===ye.UnaryExpression&&i.operator==="typeof"}function a(i){return i.flags&z.TypeFlags.Any||i.flags&z.TypeFlags.Unknown?null:i.flags&z.TypeFlags.StringLike?["string"]:i.flags&z.TypeFlags.NumberLike?["number"]:i.flags&z.TypeFlags.BigIntLike?["bigint"]:i.flags&z.TypeFlags.BooleanLike?["boolean"]:i.flags&z.TypeFlags.ESSymbolLike?["symbol"]:i.flags&z.TypeFlags.Undefined||i.flags&z.TypeFlags.Void?["undefined"]:i.flags&z.TypeFlags.Null?["object"]:i.getCallSignatures().length>0?["function"]:i.flags&z.TypeFlags.Object?i.getProperties().length===0?["string","number","bigint","boolean","symbol","object","function"]:["object"]:i.flags&z.TypeFlags.NonPrimitive?["object"]:i.flags&z.TypeFlags.Never?["never"]:null}function u(i){if(!n)return null;let o=t.esTreeNodeToTSNodeMap.get(i),l=n.getTypeAtLocation(o.expression);if(l.flags&z.TypeFlags.Any||l.flags&z.TypeFlags.Unknown)return null;let s=[];if(l.isUnion()){for(let g of l.types){let y=a(g);if(y)s.push(...y);else return null}return s}let p=a(l);return p?(s.push(...p),s):null}function c(i){if(!(i.operator==="==="||i.operator==="!=="))return;let l=null,s=null;if(r(i.left)?(l=i.left,s=i.right.type===ye.Literal&&typeof i.right.value=="string"?i.right.value:null):r(i.right)&&(l=i.right,s=i.left.type===ye.Literal&&typeof i.left.value=="string"?i.left.value:null),!l||!s||!Hn(s,Wn))return;let p=u(l);if(!p)return;let g=i.operator==="!==",y=p.includes(s);p.length===1?y&&!g?e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:ie(l,e),type:s}}):!y&&g?e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:ie(l,e),type:Array.from(p)[0]}}):!y&&!g?e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:ie(l,e),actualType:de(p),conditionType:s}}):y&&g&&e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:ie(l,e),actualType:de(p),conditionType:s}}):!y&&!g?e.report({node:i,messageId:"alwaysFalseTypeofCondition",data:{name:ie(l,e),actualType:de(p),conditionType:s}}):!y&&g&&e.report({node:i,messageId:"unnecessaryTypeofCondition",data:{name:ie(l,e),type:de(p)}})}return{BinaryExpression:c}}})};function de(e){return Array.from(new Set(e)).join(" | ")||"never"}function ie(e,t){let n=e.argument;return n.type===ye.Identifier?n.name:t.sourceCode.getText(n)}function Hn(e,t){return t.has(e)}import{AST_NODE_TYPES as Yn,ESLintUtils as zn}from"@typescript-eslint/utils";var Bn=zn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ct="no-call-with-explicit-generics",qn=D({functions:W(F())}),Kn=Bn({name:Ct,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:[qn]},defaultOptions:[{functions:[]}],create(e,[t]){let n=new Set(t.functions);return{CallExpression(r){let{callee:a}=r;a.type===Yn.Identifier&&n.has(a.name)&&r.typeArguments&&e.report({node:r,messageId:"noExplicitGenerics",data:{functionName:a.name}})}}}}),De={name:Ct,rule:Kn};import{AST_NODE_TYPES as ge,ESLintUtils as Xn}from"@typescript-eslint/utils";var Jn=Xn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),It="no-call-with-inferred-generics",Gn=Jn({name:It,meta:{type:"problem",docs:{description:"Disable calling configured functions with infered generics"},messages:{missingGenericDeclaration:"Function '{{ functionName }}' should be called with at least {{ minGenerics }} generic(s) (ex: `fn<Generic>()`) defined",anyUsedInGenerics:"Function '{{ functionName }}' should not be called with 'any' in generics"},schema:[{type:"object",properties:{functions:{type:"array",items:{type:"object",properties:{name:{type:"string"},minGenerics:{type:"number"},allowAny:{type:"boolean"},disallowTypes:{type:"array",items:{type:"string"}}},required:["name"]}},anyAliases:{type:"array",items:{type:"string"}}},required:["functions"]}]},defaultOptions:[{functions:[]}],create(e,[t]){let n=new Map(t.functions.map(r=>[r.name,r]));return{CallExpression(r){let{callee:a}=r;if(a.type!==ge.Identifier)return;let u=n.get(a.name);if(!u)return;let{minGenerics:c=1,allowAny:i,disallowTypes:o=t.disallowTypes}=u;(r.typeArguments?.params.length||0)<(c||0)&&e.report({node:r,messageId:"missingGenericDeclaration",data:{functionName:a.name,minGenerics:c||0}}),!(i&&!o)&&r.typeArguments?.params?.some(s=>!i&&s.type===ge.TSAnyKeyword||o&&s.type===ge.TSTypeReference&&s.typeName.type===ge.Identifier&&o.includes(s.typeName.name))&&e.report({node:r,messageId:"anyUsedInGenerics",data:{functionName:a.name}})}}}}),Le={name:It,rule:Gn};import{ESLintUtils as Zn,TSESTree as wt}from"@typescript-eslint/utils";var Qn=Zn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Rt="no-commented-out-code",er=["function ","class ","interface ","type ","enum ","namespace ","import ","export ","const ","let ","var ","return "],tr=[") {","return;","if (","else {","for (","switch (","/>","</","},",": {"," } = ","={",/\w=("|')/,");"],nr=Qn({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 r=n.trimStart();if(n.startsWith("*")||r.startsWith("INFO:")||r.startsWith("TODO:")||r.startsWith("DOCS:")||r.startsWith("FIX:")||r.startsWith("eslint-disable")||n.includes("@deprecated")||n.includes("@example"))return!1;for(let a of er)if(r.startsWith(a))return{wrongPattern:a};for(let a of tr)if(typeof a=="string"){if(n.includes(a))return{wrongPattern:a}}else if(a.test(n))return{wrongPattern:`regex(${a.toString()})`};return!1}return{Program(){let r=e.sourceCode.getAllComments();for(let a of r)if(a.type===wt.AST_TOKEN_TYPES.Line||a.type===wt.AST_TOKEN_TYPES.Block){let u=t(a.value);u&&e.report({node:a,messageId:"commentedOutCode",data:{wrongPattern:u.wrongPattern}})}}}}}),$e={name:Rt,rule:nr};import{ESLintUtils as rr,TSESTree as ir}from"@typescript-eslint/utils";var sr=rr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),vt="no-default-export",or=sr({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===ir.AST_NODE_TYPES.Identifier&&n.exported.name==="default"&&e.report({node:t,messageId:"noDefaultExport"})}}}}),je={name:vt,rule:or};import{ESLintUtils as ar}from"@typescript-eslint/utils";var lr=ar.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ot="no-leaked-text-in-jsx",cr=[",",";","[","]","(",")"],ur=lr({name:Ot,meta:{type:"problem",docs:{description:"Prevents leaking of text in JSX that should be wrapped in an expression container"},messages:{leakedTextInJSX:'Text "{{ text }}" should be wrapped in a JSX expression container.'},schema:[],fixable:"code"},defaultOptions:[],create(e){return{JSXText(t){let n=t.value.trim();if(!n)return;let r="";cr.includes(n)?r=n:n.includes("&&")?r="&&":n.includes("||")?r="||":n.endsWith("? (")&&(r="? ("),r&&e.report({node:t,messageId:"leakedTextInJSX",data:{text:r}})}}}}),Me={name:Ot,rule:ur};import{AST_NODE_TYPES as se,ESLintUtils as pr}from"@typescript-eslint/utils";var fr=pr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),At="no-non-camel-case-functions",mr=/^[a-z][a-zA-Z0-9]*$/;function kt(e){return e.typeName.type===se.TSQualifiedName&&e.typeName.left.type===se.Identifier&&e.typeName.left.name==="JSX"&&e.typeName.right.type===se.Identifier&&e.typeName.right.name==="Element"}var dr=fr({name:At,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&&!mr.test(t.id.name)){let n=t.returnType?.typeAnnotation;if(n&&(n.type===se.TSTypeReference?kt(n):n.type===se.TSUnionType&&n.types.some(a=>a.type===se.TSTypeReference&&kt(a))))return;e.report({node:t.id,messageId:"nonCamelCaseFunction",data:{functionName:t.id.name}})}}}}}),Ue={name:At,rule:dr};import{ESLintUtils as yr,TSESTree as M}from"@typescript-eslint/utils";function oe(e,t,n=1/0){if(n!==0&&e.parent)return e.type===t?e:oe(e.parent,t,n===1/0?n:n-1)}function*Ve(e){yield e,e.parent&&(yield*Ve(e.parent))}var gr=yr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Pt="no-optional-root-props",Sr=gr({name:Pt,meta:{type:"problem",docs:{description:"Prevents usage of optional properties at the root of a type if that type is a local type alias or interface referenced only once"},messages:{optionalNotAllowed:'Optional property "{{ propertyName }}" is not allowed on a local type used only once. Use `prop: undefined | ...` instead.',suggestion:"Use `prop: undefined | ...` instead."},hasSuggestions:!0,schema:[]},defaultOptions:[],create(e){function t(r){let u=e.sourceCode.getDeclaredVariables(r)[0];if(!u||u.references.length!==1)return!1;let c=u.references[0];if(!c)return!1;for(let i of Ve(c.identifier)){if("returnType"in i||i.type===M.AST_NODE_TYPES.ExportNamedDeclaration)return!1;let o=i.parent;if(!o)return!1;if(o.type===M.AST_NODE_TYPES.TSTypeParameterInstantiation&&o.parent.type===M.AST_NODE_TYPES.TSTypeReference&&o.parent.typeName.type===M.AST_NODE_TYPES.Identifier&&o.parent.typeName.name==="FC"){let s=oe(o.parent.parent,M.AST_NODE_TYPES.VariableDeclaration,4);if(!s)return!1;let p=Se(s,e.sourceCode);return p?!(p.parent.type===M.AST_NODE_TYPES.CallExpression&&p.parent.callee.type===M.AST_NODE_TYPES.Identifier&&p.parent.callee.name==="memo"):!1}if(i.type===M.AST_NODE_TYPES.AssignmentPattern)return!1;if(o.type===M.AST_NODE_TYPES.ArrowFunctionExpression){let l=oe(o,M.AST_NODE_TYPES.VariableDeclaration);return l?!!Se(l,e.sourceCode):!1}if(o.type===M.AST_NODE_TYPES.FunctionDeclaration)return!!Se(o,e.sourceCode)}return!1}function n(r){r.key.type!==M.AST_NODE_TYPES.Identifier||!r.optional||e.report({node:r.key,messageId:"optionalNotAllowed",data:{propertyName:r.key.name},suggest:[{messageId:"suggestion",fix:a=>{let u=oe(r,M.AST_NODE_TYPES.TSPropertySignature);if(!u)return null;let c=e.sourceCode.getText(u);return a.replaceText(u,c.replace("?:",": undefined |"))}}]})}return{TSTypeAliasDeclaration(r){if(r.typeAnnotation.type===M.AST_NODE_TYPES.TSTypeLiteral&&!(he(r)||!t(r)))for(let a of r.typeAnnotation.members)a.type===M.AST_NODE_TYPES.TSPropertySignature&&n(a)},TSInterfaceDeclaration(r){if(!(he(r)||!t(r)))for(let a of r.body.body)a.type===M.AST_NODE_TYPES.TSPropertySignature&&n(a)},TSTypeReference(r){if(r.typeName.type!==M.AST_NODE_TYPES.Identifier||r.typeName.name!=="FC"||!r.typeArguments?.params[0])return;let a=r.typeArguments.params[0];if(a.type!==M.AST_NODE_TYPES.TSTypeLiteral)return;let u=oe(r.parent,M.AST_NODE_TYPES.VariableDeclaration,4);if(!u)return;let c=Se(u,e.sourceCode);if(!(!c||c.parent.type===M.AST_NODE_TYPES.CallExpression&&c.parent.callee.type===M.AST_NODE_TYPES.Identifier&&c.parent.callee.name==="memo"))for(let o of a.members)o.type===M.AST_NODE_TYPES.TSPropertySignature&&n(o)}}}});function he(e){return e?e.parent?.type===M.AST_NODE_TYPES.ExportNamedDeclaration||e.parent?.type===M.AST_NODE_TYPES.ExportDefaultDeclaration:!1}function Se(e,t){if(he(e))return;let n;if(e.type===M.AST_NODE_TYPES.VariableDeclaration){if(e.declarations.length!==1)return;e.declarations[0].id.type===M.AST_NODE_TYPES.Identifier&&(n=e.declarations[0].id)}else{if(!e.id)return;n=e.id}if(!n)return;let r=t.getScope(e);e.type===M.AST_NODE_TYPES.FunctionDeclaration&&r.upper&&(r=r.upper);let a=r.variables.find(c=>c.identifiers.includes(n));if(!a)return;let u=a.references.filter(c=>c.identifier!==n);if(!(u.length!==1||!u[0])&&!he(u[0].identifier.parent.parent))return u[0].identifier}var We={name:Pt,rule:Sr};import{ESLintUtils as hr}from"@typescript-eslint/utils";import He from"node:path";var Tr=hr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Nt="no-relative-imports",Er=D({find:F(),replacement:F()}),br=D({aliases:W(Er),rootDir:N(F()),allowNotFoundAliases:N(re()),_dev_simulateFileName:N(F())}),xr=Tr({name:Nt,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:[br]},defaultOptions:[{aliases:[],rootDir:void 0}],create(e,[t]){let n=t._dev_simulateFileName??e.filename;function r(c){return c.startsWith(".")||c.startsWith("..")}function a(c,i){let o=He.dirname(i);return He.resolve(o,c)}function u(c){let i=t.rootDir??process.cwd(),o=He.relative(i,c);if(o.startsWith("."))return null;o.startsWith("/")||(o=`/${o}`);for(let{find:l,replacement:s}of t.aliases)if(o.startsWith(s)){let p=o.replace(s,l);return{alias:l,newPath:p}}return null}return{ImportDeclaration(c){let i=c.source.value;if(!r(i))return;let o=a(i,n),l=u(o);!l&&t.allowNotFoundAliases||e.report({node:c,messageId:l?"noRelativeImportsWithAlias":"noRelativeImports",data:{alias:l?.alias},fix:l?s=>s.replaceText(c.source,`'${l.newPath}'`):void 0})}}}}),Ye={name:Nt,rule:xr};import{AST_NODE_TYPES as ce,ESLintUtils as Ft}from"@typescript-eslint/utils";import*as ze from"typescript";var Cr=Ft.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),_t="no-unnecessary-casting",Ir=D({additionalCastFunctions:N(W(D({name:F(),expectedType:me(["string","number"])})))}),Be={name:_t,rule:Cr({name:_t,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:[Ir],fixable:"code"},defaultOptions:[{}],create(e){let n=e.options[0].additionalCastFunctions||[],r=[{name:"Number",expectedType:"number"},{name:"String",expectedType:"string"},...n],a=Ft.getParserServices(e,!0),u=a.program?.getTypeChecker();if(!u||!a.program)throw new Error("TypeScript services or program not available");function c(s,p){switch(s.type){case ce.Literal:return p==="number"?typeof s.value=="number":typeof s.value=="string";case ce.TemplateLiteral:return p==="string";case ce.UnaryExpression:return p==="number"?s.operator==="+"||s.operator==="-"||s.operator==="~":!1;default:return!1}}function i(s,p){return p==="number"?!!(s.flags&ze.TypeFlags.NumberLike):!!(s.flags&ze.TypeFlags.StringLike)}function o(s,p){return g=>g.replaceText(s,e.sourceCode.getText(p))}function l(s){if(!u||s.arguments.length!==1)return;let p=s.arguments[0];if(!p||p.type===ce.SpreadElement)return;let{callee:g}=s;if(g.type!==ce.Identifier)return;let y=g.name,S=r.find(b=>b.name===y);if(!S)return;if(c(p,S.expectedType)||i(u.getTypeAtLocation(a.esTreeNodeToTSNodeMap.get(p)),S.expectedType)){let b,h;y==="Number"?b="unnecessaryNumberCasting":y==="String"?b="unnecessaryStringCasting":(b="unnecessaryCustomCasting",h={name:S.name,type:S.expectedType}),e.report({node:s,messageId:b,...h?{data:h}:{},fix:o(s,p)})}}return{CallExpression:l}}})};import{AST_NODE_TYPES as U,ESLintUtils as wr}from"@typescript-eslint/utils";var Rr=D({selectors:W(D({name:F(),selectorProp:N(F()),selectorArgPos:N(K()),returnProp:N(F())}))}),vr=wr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Dt="no-unused-selected-values",qe={name:Dt,rule:vr({name:Dt,meta:{type:"suggestion",docs:{description:"Disallow unused values in selector objects"},messages:{unusedSelectedValue:'The selected value "{{name}}" is not being used'},schema:[Rr]},defaultOptions:[{selectors:[]}],create(e,[t]){let{selectors:n=[]}=t,r=new Map(n.map(a=>[a.name,a]));return{VariableDeclarator(a){let u=null;if(a.init?.type===U.CallExpression&&(u=a.init),!u)return;let c=kr(u);if(!c)return;let i=r.get(c);if(!i)return;let o=Or(u,i.selectorArgPos??0,i.selectorProp);if(!o)return;let l=Ar(o);if(!l)return;let s=Lt(l.properties,void 0);if(!s)return;if(a.id.type===U.ObjectPattern){let y=Lt(a.id.properties,i.returnProp);if(!y)return;for(let[S,d]of s)y.has(S)||e.report({node:d,messageId:"unusedSelectedValue",data:{name:S}});return}if(a.id.type!==U.Identifier||i.returnProp)return;let p=Pr(a,e.sourceCode);if(p.length===0)return;let g=new Set;for(let y of p){if(y.identifier.parent.type!==U.MemberExpression)return;let S=y.identifier.parent.property;if(S.type!==U.Identifier)return;g.add(S.name)}for(let[y,S]of s)g.has(y)||e.report({node:S,messageId:"unusedSelectedValue",data:{name:y}})}}}})};function Or(e,t,n){let r=e.arguments[t];if(!r)return null;if(r.type===U.ArrowFunctionExpression||r.type===U.FunctionExpression)return r;if(n&&r.type===U.ObjectExpression){let a=r.properties.find(c=>c.type===U.Property&&c.key.type===U.Identifier&&c.key.name===n);if(a?.type!==U.Property)return null;let u=a.value;if(u.type===U.ArrowFunctionExpression||u.type===U.FunctionExpression)return u}return null}function kr(e){return e.callee.type===U.Identifier?e.callee.name:e.callee.type===U.MemberExpression&&e.callee.property.type===U.Identifier?e.callee.property.name:null}function Ar(e){if(e.body.type===U.ObjectExpression)return e.body;if(e.body.type===U.BlockStatement){let t=e.body.body.filter(n=>n.type===U.ReturnStatement);return t.length!==1||!t[0]||t[0].argument?.type!==U.ObjectExpression?null:t[0].argument}return null}function Lt(e,t){let n=e;if(t){let a=e.find(u=>u.type===U.Property&&u.key.type===U.Identifier&&u.key.name===t);if(a?.type!==U.Property||a.value.type!==U.ObjectPattern)return null;n=a.value.properties}let r=new Map;for(let a of n){if(a.type!==U.Property||a.key.type!==U.Identifier)return null;r.set(a.key.name,a)}return r.size>0?r:null}function Pr(e,t){let n=t.getDeclaredVariables(e);if(n.length!==1)return[];let r=n[0];return r?r.references.filter(a=>a.identifier!==e.id):[]}import{AST_NODE_TYPES as j,ESLintUtils as Nr}from"@typescript-eslint/utils";var _r=Nr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function $t(e){let t=[];for(let n of e.members)n.type===j.TSPropertySignature&&n.key.type===j.Identifier&&t.push([n.key.name,n]);return t}function jt(e,...t){for(let n of t)e.set(...n);return e}var Fr=D({forceCheckOnFCPropTypesWithName:N(W(F()))}),Mt="no-unused-type-props-in-args",Ke=null,Dr=_r({name:Mt,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:[Fr],fixable:"code"},defaultOptions:[{}],create(e,[t]){let{forceCheckOnFCPropTypesWithName:n}=t;n&&!Ke&&(Ke=n.map(i=>new RegExp(i)));function r(i,o,l,s,p=!0){let g=l.name,y=e.sourceCode.getScope(o).references.find(b=>b.identifier.name===g)?.resolved,S=i&&Ke?.some(b=>b.test(g));if(!y||!S&&y.references.filter(b=>b.isTypeReference).length>1)return;let d=y?.defs[0]?.node;if(!(p&&d?.parent?.type===j.ExportNamedDeclaration)){if(d?.type===j.TSTypeAliasDeclaration){a(i,o,s,d.typeAnnotation,!0);return}if(d?.type===j.TSInterfaceDeclaration){a(i,o,s,d.body,!0);return}}}function a(i,o,l,s,p){if(s.type===j.TSInterfaceBody){for(let g of s.body)g.type===j.TSPropertySignature&&g.key.type===j.Identifier&&l.set(g.key.name,g);return}if(s.type===j.TSTypeLiteral){jt(l,...$t(s));return}if(s.type===j.TSIntersectionType){for(let g of s.types)a(i,o,l,g,!0);return}p||s.type===j.TSTypeReference&&s.typeName.type===j.Identifier&&r(i,o,s.typeName,l)}function u(i,o,l){for(let s of l)if(s.type==="ObjectPattern"&&s.typeAnnotation){let p=new Map;if(a(i,o,p,s.typeAnnotation.typeAnnotation,!1),p.size===0)continue;c(s,p)}else s.type===j.AssignmentPattern&&s.left.type===j.ObjectPattern&&u(i,o,[s.left])}function c(i,o){let l=[];if(i.properties.at(-1)?.type===j.RestElement)return;for(let y of i.properties)y.type===j.Property&&y.key.type===j.Identifier&&l.push(y.key.name);let p=[],g=[];for(let[y,S]of o)l.includes(y)||(g.push(y),p.push({node:S,messageId:"unusedObjectTypeProperty",data:{propertyName:y}}));for(let[y,S]of p.entries())e.report({...S,fix:y===p.length-1?d=>{let b=i.properties.at(-1),h=g.join(", ");return b?b?.type===j.RestElement?null:d.insertTextAfter(b,`, ${h}`):d.insertTextBeforeRange([i.range[0]+1,i.range[1]],`${h}`)}:void 0})}return{VariableDeclaration(i){let o=i.declarations[0];if(!o)return;let l=new Map,s=o.id.type===j.Identifier&&o.id.typeAnnotation?.typeAnnotation.type===j.TSTypeReference&&o.id.typeAnnotation.typeAnnotation.typeName.type===j.Identifier&&o.id.typeAnnotation.typeAnnotation.typeName.name==="FC"&&o.id.typeAnnotation.typeAnnotation.typeArguments?.params[0];if(s){if(s.type===j.TSTypeReference&&s.typeName.type===j.Identifier)r(!0,i,s.typeName,l,!1);else if(s.type===j.TSTypeLiteral)jt(l,...$t(s));else if(s.type===j.TSIntersectionType)for(let p of s.types)p.type===j.TSTypeReference&&p.typeName.type===j.Identifier?r(!0,i,p.typeName,l,!1):a(!0,i,l,p,!0);if(l.size!==0&&o.init?.type===j.ArrowFunctionExpression){let p=o.init.params[0];if(!p){e.report({node:o.init,messageId:"missingComponentParam"});return}p.type===j.ObjectPattern&&c(p,l)}}},FunctionDeclaration:function(i){u(!1,i,i.params)},ArrowFunctionExpression(i){u(!1,i,i.params)}}}}),Xe={name:Mt,rule:Dr};import{AST_NODE_TYPES as Je,ESLintUtils as Lr}from"@typescript-eslint/utils";var $r=Lr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Vt="prefer-named-functions",Ut=new Map,jr=$r({name:Vt,meta:{hasSuggestions:!0,type:"suggestion",docs:{description:"Prevent using arrow functions when a named function can be used instead"},schema:[{type:"object",properties:{ignoreRegex:{type:"string"},disallowArrowFnWithImplicitReturns:{type:"boolean"}}}],messages:{suggestion:"Convert to named function",default:'Function {{functionName}} should be defined as a named function "function {{functionName}} () {}" instead of an arrow function',withIgnoreRegex:'Function {{functionName}} should be defined as a named function "function {{functionName}} () {}", if not possible to use `function` you can also use a name that matches the rule ignore regex'}},defaultOptions:[{}],create(e,[t]){let n=null;if(t.ignoreRegex){let r=Ut.get(t.ignoreRegex);r?n=r:(n=new RegExp(t.ignoreRegex),Ut.set(t.ignoreRegex,n))}return{VariableDeclarator(r){if(r.init&&r.init.type===Je.ArrowFunctionExpression&&r.id.type===Je.Identifier){let a=r.id.name;if(r.id.typeAnnotation||n&&n.test(a)||!t.disallowArrowFnWithImplicitReturns&&r.init.body.type!==Je.BlockStatement)return;let u=r.parent,c=r.init.params,i=r.init.body,o=r.init;e.report({node:r.id,messageId:n?"withIgnoreRegex":"default",data:{functionName:a,ignoreRegex:t.ignoreRegex},suggest:[{messageId:"suggestion",fix:l=>l.replaceText(u,`${o.async?"async ":""}function ${a}(${c.map(s=>e.sourceCode.getText(s)).join(", ")||""}) ${e.sourceCode.getText(i)}`)}]})}}}}}),Ge={name:Vt,rule:jr};import{AST_NODE_TYPES as H,AST_TOKEN_TYPES as Wt,ESLintUtils as Mr}from"@typescript-eslint/utils";var Ur=Mr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Yt="prefer-single-line-if",Vr=D({maxLineLength:N(K()),maxNonSimpleConditionLength:N(K())}),Wr=Ur({name:Yt,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(r){if(r.consequent.type!==H.BlockStatement||r.loc.start.line===r.loc.end.line||n.getCommentsInside(r.consequent).length>0||r.alternate||r.consequent.body.length!==1)return;let u=r.consequent.body[0];if(u.type===H.ReturnStatement){if(!Bt(u))return}else if(!(u.type===H.ContinueStatement||u.type===H.BreakStatement))return;if(r.test.type===H.LogicalExpression||r.test.type===H.ConditionalExpression)return;let c;if(t.maxNonSimpleConditionLength){let p=Ht(r.test);if(!p&&r.test.type===H.UnaryExpression&&r.test.operator==="!"){let g=r.test.argument;Ht(g)&&(p=!0)}if(p&&(c=n.getText(r.test),c.length>t.maxNonSimpleConditionLength))return}c||(c=n.getText(r.test));let i=n.getText(u);if(c.includes(`
|
|
15
|
+
`))return;let o=n.getTokenAfter(r);if(o&&o.type===Wt.Punctuator&&o.value==="}"){let p=n.getTokenAfter(o);if(p&&p.type===Wt.Keyword&&(p.value==="else"||p.value==="catch"))return}let l=Hr(n,r),s=`if (${c}) ${i}`;t.maxLineLength&&s.length+l.length>t.maxLineLength||e.report({node:r,messageId:"noSingleLineCurly",fix:p=>p.replaceText(r,s)})}}}});function Ht(e){return e.type===H.CallExpression||e.type===H.BinaryExpression||e.type===H.MemberExpression&&zt(e)}function zt(e){return e.object.type===H.MemberExpression?zt(e.object):e.object.type!==H.Identifier}function Hr(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}function Bt(e){if(!e.argument)return!0;let t=e.argument;return t.type===H.ArrayExpression&&t.elements.length===0||t.type===H.ObjectExpression&&t.properties.length===0||t.type===H.Literal||t.type===H.Identifier||t.type===H.TemplateLiteral||t.type===H.TaggedTemplateExpression?!0:t.type===H.CallExpression?t.arguments.length===0:t.type===H.UnaryExpression?Bt(t):!1}var Ze={name:Yt,rule:Wr};import{AST_NODE_TYPES as X,ESLintUtils as Yr}from"@typescript-eslint/utils";var zr=Yr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),qt="react-compiler-migration",Br=D({disallowHooks:N(W(D({name:F(),replacement:F()}))),disallowMethods:N(W(D({name:F(),replacement:N(F()),requireTrueProp:N(F())})))}),qr=/eslint +react-compiler\/react-compiler: +\["error/;function Kr(e){return e.type===X.Identifier?e.name.startsWith("use"):e.type===X.MemberExpression&&e.property.type===X.Identifier?e.property.name.startsWith("use"):!1}var Xr=zr({name:qt,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:[Br]},defaultOptions:[{}],create(e,[t]){let n=!1;for(let r of e.sourceCode.getAllComments())if(qr.test(r.value)){n=!0;break}return n?{CallExpression(r){if(t.disallowHooks?.length){let a=null,u=null;if(r.callee.type===X.Identifier?(a=r.callee.name,u=r.callee):r.callee.type===X.MemberExpression&&r.callee.property.type===X.Identifier&&(a=r.callee.property.name,u=r.callee.property),a){let c=t.disallowHooks.find(i=>i.name===a);c&&u&&e.report({node:r,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:c.name,replacement:c.replacement},suggest:[{messageId:"replace",data:{replacement:c.replacement},fix:i=>i.replaceText(u,c.replacement)}]})}}if(t.disallowMethods?.length&&Kr(r.callee)){for(let a of r.arguments)if(a.type===X.ObjectExpression){for(let u of a.properties)if(u.type===X.Property&&u.key.type===X.Identifier){let c=u.key.name,i=t.disallowMethods.find(o=>o.name===c);if(i){if(i.requireTrueProp){let o=i.requireTrueProp,l=!1;for(let s of a.properties)if(s.type===X.Property&&s.key.type===X.Identifier&&s.key.name===o&&s.value.type===X.Literal&&s.value.value===!0){l=!0;break}if(!l){e.report({node:u,messageId:"disallowedMethodWithMissingRequireTrueProp",data:{method:i.name,requireTrueProp:o}});continue}}i.replacement&&e.report({node:u,messageId:"disallowedFunctionOrMethod",data:{functionOrMethod:i.name,replacement:i.replacement},suggest:[{messageId:"replace",data:{replacement:i.replacement},fix:o=>o.replaceText(u.key,i.replacement)}]})}}}}}}:{}}}),Qe={name:qt,rule:Xr};import{ESLintUtils as Jr,TSESTree as Gr}from"@typescript-eslint/utils";var Zr=Jr.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Kt="require-description",Qr=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,ei=/^eslint-disable-(next-)?line$/u,ti=Zr({name:Kt,meta:{type:"problem",docs:{description:"Require descriptions for eslint directives."},messages:{missingDescription:"Unexpected undescribed directive comment. Include descriptions to explain why the comment is necessary."},schema:[{type:"object",properties:{ignore:{type:"array",items:{type:"string",enum:["eslint","eslint-disable","eslint-disable-line","eslint-disable-next-line","eslint-enable","eslint-env","exported","global","globals"]},additionalItems:!1,uniqueItems:!0}},additionalProperties:!1}]},defaultOptions:[{ignore:[]}],create(e,[t]){let n=e.sourceCode,r=new Set(t.ignore||[]);return{Program(){for(let a of n.getAllComments()){let u=ni(a);u!=null&&(r.has(u.kind)||u.description||e.report({loc:ii(a.loc),messageId:"missingDescription"}))}}}}}),Xt={name:Kt,rule:ti};function ni(e){let{text:t,description:n}=ri(e.value);if(!t)return null;let r=Qr.exec(t);if(!r)return null;let a=r[1];if(!a)return null;let u=ei.test(a);if(e.type===Gr.AST_TOKEN_TYPES.Line&&!u||u&&e.loc.start.line!==e.loc.end.line)return null;let c=t.slice(r.index+a.length);return{kind:a,value:c.trim(),description:n}}function ri(e){let t=e.split(/\s-{2,}\s/u);return{text:t[0]?.trim(),description:t.length>1?t[1]?.trim()??null:null}}function ii(e){return{start:{line:e.start.line,column:-1},end:e.end}}function Zt(e){return/^use[A-Z0-9]/.test(e)}function Te(e){return e.type==="Identifier"?Zt(e.name):e.type==="MemberExpression"&&!e.computed&&Te(e.property)?e.object.type==="Identifier":!1}function Qt(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function en(e,t){return e.name===t||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===t}function tn(e){return!!(e.parent&&e.parent.callee&&en(e.parent.callee,"forwardRef"))}function nn(e){return!!(e.parent&&e.parent.callee&&en(e.parent.callee,"memo"))}function et(e){for(;e;){let t=sn(e);if(t&&(Qt(t)||Te(t))||tn(e)||nn(e))return!0;e=e.parent}return!1}function Jt(e){return!1}function tt(e){return!1}var si=/eslint +react-compiler\/react-compiler: +\["error/,rn={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 o of e.sourceCode.getAllComments())if(si.test(o.value))return{CallExpression(l){let s=null;l.callee.name==="useMemo"?s="useMemo":l.callee.name==="useCallback"&&(s="useCallback"),s&&e.report({node:l,message:`"${s}" is not necessary when using React Compiler.`})}}}let t=typeof e.getSource=="function"?o=>t(o):o=>e.sourceCode.getText(o),n=typeof e.getScope=="function"?()=>n():o=>e.sourceCode.getScope(o),r=null,a=[],u=[],c=new WeakSet;function i(o){for(let l of o.references){let s=l.identifier.parent;if(s.type==="VariableDeclarator"&&s.init&&s.init.type==="CallExpression"&&s.init.callee&&Jt(s.init.callee))for(let p of l.resolved.references)p!==l&&c.add(p.identifier)}}return{onCodePathSegmentStart:o=>u.push(o),onCodePathSegmentEnd:()=>u.pop(),onCodePathStart:()=>a.push(new Map),onCodePathEnd(o,l){let s=a.pop();if(s.size===0)return;let p=new Set;function g(T,w){let{cache:R}=g,O=R.get(T.id),L=new Set(w);if(L.has(T.id)){let k=[...L],V=k.slice(k.indexOf(T.id)+1);for(let Z of V)p.add(Z);return BigInt("0")}if(L.add(T.id),O!==void 0)return O;if(o.thrownSegments.includes(T))O=BigInt("0");else if(T.prevSegments.length===0)O=BigInt("1");else{O=BigInt("0");for(let k of T.prevSegments)O+=g(k,L)}return T.reachable&&O===BigInt("0")?R.delete(T.id):R.set(T.id,O),O}function y(T,w){let{cache:R}=y,O=R.get(T.id),L=new Set(w);if(L.has(T.id)){let k=Array.from(L),V=k.slice(k.indexOf(T.id)+1);for(let Z of V)p.add(Z);return BigInt("0")}if(L.add(T.id),O!==void 0)return O;if(o.thrownSegments.includes(T))O=BigInt("0");else if(T.nextSegments.length===0)O=BigInt("1");else{O=BigInt("0");for(let k of T.nextSegments)O+=y(k,L)}return R.set(T.id,O),O}function S(T){let{cache:w}=S,R=w.get(T.id);if(R===null)return 1/0;if(R!==void 0)return R;if(w.set(T.id,null),T.prevSegments.length===0)R=1;else{R=1/0;for(let O of T.prevSegments){let L=S(O);L<R&&(R=L)}R+=1}return w.set(T.id,R),R}g.cache=new Map,y.cache=new Map,S.cache=new Map;let d=y(o.initialSegment),b=sn(l),h=et(l),_=b?Qt(b)||Te(b):tn(l)||nn(l),v=1/0;for(let T of o.finalSegments){if(!T.reachable)continue;let w=S(T);w<v&&(v=w)}for(let[T,w]of s){if(!T.reachable)continue;let R=T.nextSegments.length===0?v<=S(T):v<S(T),O=g(T)*y(T),L=p.has(T.id);for(let k of w)if(L&&!tt(k)&&e.report({node:k,message:`React Hook "${t(k)}" 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.`}),_){if(l.async&&e.report({node:k,message:`React Hook "${t(k)}" cannot be called in an async function.`}),!L&&O!==d&&!tt(k)){let Z=`React Hook "${t(k)}" 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:k,message:Z})}}else if(l.parent&&(l.parent.type==="MethodDefinition"||l.parent.type==="ClassProperty")&&l.parent.value===l){let V=`React Hook "${t(k)}" 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:k,message:V})}else if(b){let V=`React Hook "${t(k)}" 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:k,message:V})}else if(l.type==="Program"){let V=`React Hook "${t(k)}" 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:k,message:V})}else if(h&&!tt(k)){if(l.parent.type==="CallExpression"&&l.parent.callee.type==="Identifier"&&l.parent.callee.name==="useCallback"){let Z=l.parent;if(Z.parent.type==="VariableDeclarator"&&Zt(Z.parent.id.name))return}let V=`React Hook "${t(k)}" 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:k,message:V})}}},CallExpression(o){if(Te(o.callee)){let l=Gt(a),s=Gt(u),p=l.get(s);p||(p=[],l.set(s,p)),p.push(o.callee)}o.callee.type==="Identifier"&&(o.callee.name==="useEffect"||Jt(o.callee))&&o.arguments.length>0&&(r=o)},Identifier(o){r==null&&c.has(o)&&o.parent.type!=="CallExpression"&&e.report({node:o,message:`\`${t(o)}\` 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"(o){o===r&&(r=null)},FunctionDeclaration(o){et(o)&&i(n(o))},ArrowFunctionExpression(o){et(o)&&i(n(o))}}}};function sn(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 Gt(e){return e[e.length-1]}var on={[Xe.name]:Xe.rule,[$e.name]:$e.rule,[Le.name]:Le.rule,"rules-of-hooks":rn,"exhaustive-deps":St,"require-description":Xt.rule,[je.name]:je.rule,[Ue.name]:Ue.rule,[Ge.name]:Ge.rule,[Oe.name]:Oe.rule,[De.name]:De.rule,[Ye.name]:Ye.rule,[Ze.name]:Ze.rule,[We.name]:We.rule,[Me.name]:Me.rule,[Ae.name]:Ae.rule,[Qe.name]:Qe.rule,[Re.name]:Re.rule,[Fe.name]:Fe.rule,[Be.name]:Be.rule,[qe.name]:qe.rule};var js={rules:on};export{js as extendedLintPlugin};
|