@ls-stack/extended-lint 0.10.0 → 0.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- "use strict";var re=Object.defineProperty;var rt=Object.getOwnPropertyDescriptor;var it=Object.getOwnPropertyNames;var st=Object.prototype.hasOwnProperty;var ot=(e,t)=>{for(var r in t)re(e,r,{get:t[r],enumerable:!0})},at=(e,t,r,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of it(t))!st.call(e,o)&&o!==r&&re(e,o,{get:()=>t[o],enumerable:!(a=rt(t,o))||a.enumerable});return e};var ct=e=>at(re({},"__esModule",{value:!0}),e);var _t={};ot(_t,{extendedLintPlugin:()=>Lt});module.exports=ct(_t);var lt=/eslint +react-compiler\/react-compiler: +\["error/,Te={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){if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let g of e.sourceCode.getAllComments())if(lt.test(g.value))return{}}let t=typeof e.getSource=="function"?g=>t(g):g=>e.sourceCode.getText(g),r=typeof e.getScope=="function"?()=>r():g=>e.sourceCode.getScope(g),a=e.options&&e.options[0]&&e.options[0].additionalHooks?new RegExp(e.options[0].additionalHooks):void 0,o=e.options&&e.options[0]&&e.options[0].enableDangerousAutofixThisMayCauseInfiniteLoops||!1,u={additionalHooks:a,enableDangerousAutofixThisMayCauseInfiniteLoops:o};function f(g){o&&Array.isArray(g.suggest)&&g.suggest.length>0&&(g.fix=g.suggest[0].fix),e.report(g)}let m=e.getSourceCode().scopeManager,s=new WeakMap,c=new WeakSet,b=new WeakMap,I=new WeakMap,M=new WeakSet;function O(g,$){return function(w){if($.has(w))return $.get(w);let k=g(w);return $.set(w,k),k}}function F(g,$,w,k,l){l&&g.async&&f({node:g,message:`Effect callbacks are synchronous to prevent race conditions. Put the async function inside:
1
+ "use strict";var re=Object.defineProperty;var ot=Object.getOwnPropertyDescriptor;var at=Object.getOwnPropertyNames;var ct=Object.prototype.hasOwnProperty;var lt=(e,t)=>{for(var r in t)re(e,r,{get:t[r],enumerable:!0})},ut=(e,t,r,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of at(t))!ct.call(e,o)&&o!==r&&re(e,o,{get:()=>t[o],enumerable:!(a=ot(t,o))||a.enumerable});return e};var pt=e=>ut(re({},"__esModule",{value:!0}),e);var zt={};lt(zt,{extendedLintPlugin:()=>Vt});module.exports=pt(zt);var xe=require("@typescript-eslint/utils"),ft=xe.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Te="advanced-no-restricted-syntax",dt=ft({name:Te,meta:{type:"suggestion",docs:{description:"Disallow specific syntax patterns"},schema:[{type:"object",properties:{disallow:{type:"array",items:{type:"object",properties:{selector:{type:"string"},message:{type:"string"},replace:{oneOf:[{type:"string"},{type:"object",properties:{regex:{type:"string"},with:{type:"string"}},required:["regex","with"],additionalProperties:!1}]},replaceType:{type:"string",enum:["suggestion","autofix"]}},required:["selector","message"],additionalProperties:!1}}},additionalProperties:!1}],messages:{default:"{{message}}"},fixable:"code",hasSuggestions:!0},defaultOptions:[{disallow:[]}],create(e){let t={};for(let{selector:r,message:a,replace:o,replaceType:p="suggestion"}of e.options[0].disallow??[])t[r]=l=>{let d=i=>{if(!o)return null;if(typeof o=="string")return i.replaceText(l,o);{let c=new RegExp(o.regex),b=e.sourceCode.getText(l);return i.replaceText(l,b.replace(c,o.with))}};e.report({node:l,messageId:"default",data:{message:a},fix:o&&p==="autofix"?d:void 0,suggest:o&&p==="suggestion"?[{messageId:"default",data:{message:`Replace with "${typeof o=="string"?o:o.with}"`},fix:d}]:void 0})};return t}}),se={name:Te,rule:dt};var mt=/eslint +react-compiler\/react-compiler: +\["error/,Re={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){if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let g of e.sourceCode.getAllComments())if(mt.test(g.value))return{}}let t=typeof e.getSource=="function"?g=>t(g):g=>e.sourceCode.getText(g),r=typeof e.getScope=="function"?()=>r():g=>e.sourceCode.getScope(g),a=e.options&&e.options[0]&&e.options[0].additionalHooks?new RegExp(e.options[0].additionalHooks):void 0,o=e.options&&e.options[0]&&e.options[0].enableDangerousAutofixThisMayCauseInfiniteLoops||!1,p={additionalHooks:a,enableDangerousAutofixThisMayCauseInfiniteLoops:o};function l(g){o&&Array.isArray(g.suggest)&&g.suggest.length>0&&(g.fix=g.suggest[0].fix),e.report(g)}let d=e.getSourceCode().scopeManager,i=new WeakMap,c=new WeakSet,b=new WeakMap,I=new WeakMap,F=new WeakSet;function O(g,$){return function(w){if($.has(w))return $.get(w);let k=g(w);return $.set(w,k),k}}function M(g,$,w,k,u){u&&g.async&&l({node:g,message:`Effect callbacks are synchronous to prevent race conditions. Put the async function inside:
2
2
 
3
3
  useEffect(() => {
4
4
  async function fetchData() {
@@ -9,4 +9,4 @@ useEffect(() => {
9
9
  fetchData();
10
10
  }, [someId]); // Or [] if effect doesn't need props or state
11
11
 
12
- Learn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching`});let R=m.acquire(g),A=new Set,S=null;{let n=R.upper;for(;n&&(A.add(n),n.type!=="function");)n=n.upper;if(!n)return;S=n}let D=Array.isArray;function T(n){if(!D(n.defs))return!1;let i=n.defs[0];if(i==null||i.node.type!=="VariableDeclarator")return!1;let p=i.node.init;if(p==null)return!1;for(;p.type==="TSAsExpression";)p=p.expression;let d=i.node.parent;if(d==null&&(oe(S.block,i.node.id),d=i.node.parent,d==null))return!1;if(d.kind==="const"&&p.type==="Literal"&&(typeof p.value=="string"||typeof p.value=="number"||p.value===null))return!0;if(p.type!=="CallExpression")return!1;let h=p.callee;if(h.type==="MemberExpression"&&h.object.name==="React"&&h.property!=null&&!h.computed&&(h=h.property),h.type!=="Identifier")return!1;let y=i.node.id,{name:E}=h;if(E==="useRef"&&y.type==="Identifier")return!0;if(mt(h)&&y.type==="Identifier"){for(let x of n.references)x!==y&&M.add(x.identifier);return!0}else if(E==="useState"||E==="useReducer"){if(y.type==="ArrayPattern"&&y.elements.length===2&&D(n.identifiers)){if(y.elements[1]===n.identifiers[0]){if(E==="useState"){let x=n.references,j=0;for(let W=0;W<x.length;W++){if(x[W].isWrite()&&j++,j>1)return!1;s.set(x[W].identifier,y.elements[0])}}return!0}else if(y.elements[0]===n.identifiers[0]){if(E==="useState"){let x=n.references;for(let j=0;j<x.length;j++)c.add(x[j].identifier)}return!1}}}else if(E==="useTransition"&&y.type==="ArrayPattern"&&y.elements.length===2&&Array.isArray(n.identifiers)&&y.elements[1]===n.identifiers[0])return!0;return!1}function P(n){if(!D(n.defs))return!1;let i=n.defs[0];if(i==null||i.node==null||i.node.id==null)return!1;let p=i.node,d=S.childScopes,h=null,y;for(y=0;y<d.length;y++){let E=d[y],x=E.block;if(p.type==="FunctionDeclaration"&&x===p||p.type==="VariableDeclarator"&&x.parent===p){h=E;break}}if(h==null)return!1;for(y=0;y<h.through.length;y++){let E=h.through[y];if(E.resolved!=null&&A.has(E.resolved.scope)&&!L(E.resolved))return!1}return!0}let L=O(T,b),Je=O(P,I),ye=new Map;function Ye(n){let i=n.from,p=!1;for(;i.block!==g;)i.type==="function"&&(p=i.block.parent!=null&&i.block.parent.type==="ReturnStatement"),i=i.upper;return p}let H=new Map,Q=new Map;ge(R);function ge(n){for(let i of n.references){if(!i.resolved||!A.has(i.resolved.scope))continue;let p=oe(g,i.identifier),d=xe(p),h=U(d,Q);if(l&&d.type==="Identifier"&&(d.parent.type==="MemberExpression"||d.parent.type==="OptionalMemberExpression")&&!d.parent.computed&&d.parent.property.type==="Identifier"&&d.parent.property.name==="current"&&Ye(i)&&ye.set(h,{reference:i,dependencyNode:d}),d.parent.type==="TSTypeQuery"||d.parent.type==="TSTypeReference")continue;let y=i.resolved.defs[0];if(y!=null&&!(y.node!=null&&y.node.init===g.parent)&&y.type!=="TypeParameter")if(H.has(h))H.get(h).references.push(i);else{let E=i.resolved,x=L(E)||Je(E);H.set(h,{isStable:x,references:[i]})}}for(let i of n.childScopes)ge(i)}ye.forEach(({reference:n,dependencyNode:i},p)=>{let d=n.resolved.references,h=!1;for(let y=0;y<d.length;y++){let{identifier:E}=d[y],{parent:x}=E;if(x!=null&&x.type==="MemberExpression"&&!x.computed&&x.property.type==="Identifier"&&x.property.name==="current"&&x.parent.type==="AssignmentExpression"&&x.parent.left===x){h=!0;break}}h||f({node:i.parent.property,message:`The ref value '${p}.current' will likely have changed by the time this effect cleanup function runs. If this ref points to a node rendered by React, copy '${p}.current' to a variable inside the effect, and use that variable in the cleanup function.`})});let ee=new Set;function Ze(n,i){ee.has(i)||(ee.add(i),f({node:n,message:`Assignments to the '${i}' variable from inside React Hook ${t(w)} 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 ${t(w)}.`}))}let K=new Set;if(H.forEach(({isStable:n,references:i},p)=>{n&&K.add(p),i.forEach(d=>{d.writeExpr&&Ze(d.writeExpr,p)})}),ee.size>0)return;if(!$){let n=null;if(H.forEach(({isStable:i,references:p},d)=>{n||p.forEach(h=>{if(n)return;let y=h.identifier;if(!s.has(y))return;let x=h.from;for(;x.type!=="function";)x=x.upper;x.block===g&&(n=d)})}),n){let{suggestedDependencies:i}=ie({dependencies:H,declaredDependencies:[],stableDependencies:K,externalDependencies:new Set,isEffect:!0});f({node:w,message:`React Hook ${k} contains a call to '${n}'. Without a list of dependencies, this can lead to an infinite chain of updates. To fix this, pass [`+i.join(", ")+`] as a second argument to the ${k} Hook.`,suggest:[{desc:`Add dependencies array: [${i.join(", ")}]`,fix(p){return p.insertTextAfter(g,`, [${i.join(", ")}]`)}}]})}return}let G=[],X=new Set;$.type!=="ArrayExpression"?f({node:$,message:`React Hook ${t(w)} 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(n=>{if(n===null)return;if(n.type==="SpreadElement"){f({node:n,message:`React Hook ${t(w)} has a spread element in its dependency array. This means we can't statically verify whether you've passed the correct dependencies.`});return}M.has(n)&&f({node:n,message:`Functions returned from \`useEffectEvent\` must not be included in the dependency array. Remove \`${t(n)}\` from the list.`,suggest:[{desc:`Remove the dependency \`${t(n)}\``,fix(h){return h.removeRange(n.range)}}]});let i;try{i=U(n,Q)}catch(h){if(/Unsupported node type/.test(h.message)){n.type==="Literal"?H.has(n.value)?f({node:n,message:`The ${n.raw} literal is not a valid dependency because it never changes. Did you mean to include ${n.value} in the array instead?`}):f({node:n,message:`The ${n.raw} literal is not a valid dependency because it never changes. You can safely remove it.`}):f({node:n,message:`React Hook ${t(w)} has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked.`});return}else throw h}let p=n;for(;p.type==="MemberExpression"||p.type==="OptionalMemberExpression"||p.type==="ChainExpression";)p=p.object||p.expression.object;let d=!S.through.some(h=>h.identifier===p);G.push({key:i,node:n}),d||X.add(i)});let{suggestedDependencies:Qe,unnecessaryDependencies:J,missingDependencies:V,duplicateDependencies:he}=ie({dependencies:H,declaredDependencies:G,stableDependencies:K,externalDependencies:X,isEffect:l}),Y=Qe;if(he.size+V.size+J.size===0){ut({declaredDependencies:G,declaredDependenciesNode:$,componentScope:S,scope:R}).forEach(({construction:i,isUsedOutsideOfHook:p,depType:d})=>{let h=d==="function"?"useCallback":"useMemo",y=d==="function"?"definition":"initialization",E=`wrap the ${y} of '${i.name.name}' in its own ${h}() Hook.`,x=p?`To fix this, ${E}`:`Move it inside the ${k} callback. Alternatively, ${E}`,j=d==="conditional"||d==="logical expression"?"could make":"makes",W=`The '${i.name.name}' ${d} ${j} the dependencies of ${k} Hook (at line ${$.loc.start.line}) change on every render. ${x}`,be;p&&i.type==="Variable"&&d==="function"&&(be=[{desc:`Wrap the ${y} of '${i.name.name}' in its own ${h}() Hook.`,fix(Ee){let[tt,nt]=h==="useMemo"?["useMemo(() => { return ","; })"]:["useCallback(",")"];return[Ee.insertTextBefore(i.node.init,tt),Ee.insertTextAfter(i.node.init,nt)]}}]),f({node:i.node,message:W,suggest:be})});return}!l&&V.size>0&&(Y=ie({dependencies:H,declaredDependencies:[],stableDependencies:K,externalDependencies:X,isEffect:l}).suggestedDependencies);function et(){if(G.length===0)return!0;let n=G.map(p=>p.key),i=n.slice().sort();return n.join(",")===i.join(",")}et()&&Y.sort();function te(n){let i=n.split("."),p="";for(let d=0;d<i.length;d++){if(d!==0){let h=i.slice(0,d+1).join("."),y=Q.get(h)===!0;p+=y?"?.":"."}p+=i[d]}return p}function ne(n,i,p,d){return n.size===0?null:(n.size>1?"":i+" ")+p+" "+(n.size>1?"dependencies":"dependency")+": "+pt(Array.from(n).sort().map(h=>"'"+te(h)+"'"))+`. Either ${d} ${n.size>1?"them":"it"} or remove the dependency array.`}let _="";if(J.size>0){let n=null;if(Array.from(J.keys()).forEach(i=>{n===null&&i.endsWith(".current")&&(n=i)}),n!==null)_=` Mutable values like '${n}' aren't valid dependencies because mutating them doesn't re-render the component.`;else if(X.size>0){let i=Array.from(X)[0];R.set.has(i)||(_=` Outer scope values like '${i}' aren't valid dependencies because mutating them doesn't re-render the component.`)}}if(!_&&V.has("props")){let n=H.get("props");if(n==null)return;let i=n.references;if(!Array.isArray(i))return;let p=!0;for(let d=0;d<i.length;d++){let h=i[d],y=oe(S.block,h.identifier);if(!y){p=!1;break}let E=y.parent;if(E==null){p=!1;break}if(E.type!=="MemberExpression"&&E.type!=="OptionalMemberExpression"){p=!1;break}}p&&(_=` However, 'props' will change when *any* prop changes, so the preferred fix is to destructure the 'props' object outside of the ${k} call and refer to those specific props inside ${t(w)}.`)}if(!_&&V.size>0){let n=null;V.forEach(i=>{if(n)return;let p=S.set.get(i),d=H.get(i);if(d.references[0].resolved!==p)return;let h=p.defs[0];if(h==null||h.name==null||h.type!=="Parameter")return;let y=!1,E;for(let x=0;x<d.references.length;x++)if(E=d.references[x].identifier,E!=null&&E.parent!=null&&(E.parent.type==="CallExpression"||E.parent.type==="OptionalCallExpression")&&E.parent.callee===E){y=!0;break}y&&(n=i)}),n!==null&&(_=` If '${n}' changes too often, find the parent component that defines it and wrap that definition in useCallback.`)}if(!_&&V.size>0){let n=null;if(V.forEach(i=>{if(n!==null)return;let d=H.get(i).references,h,y;for(let E=0;E<d.length;E++){for(h=d[E].identifier,y=h.parent;y!=null&&y!==S.block;){if(y.type==="CallExpression"){let x=s.get(y.callee);if(x!=null){if(x.name===i)n={missingDep:i,setter:y.callee.name,form:"updater"};else if(c.has(h))n={missingDep:i,setter:y.callee.name,form:"reducer"};else{let j=d[E].resolved;if(j!=null){let W=j.defs[0];W!=null&&W.type==="Parameter"&&(n={missingDep:i,setter:y.callee.name,form:"inlineReducer"})}}break}}y=y.parent}if(n!==null)break}}),n!==null)switch(n.form){case"reducer":_=` You can also replace multiple useState variables with useReducer if '${n.setter}' needs the current value of '${n.missingDep}'.`;break;case"inlineReducer":_=` If '${n.setter}' needs the current value of '${n.missingDep}', you can also switch to useReducer instead of useState and read '${n.missingDep}' in the reducer.`;break;case"updater":_=` You can also do a functional update '${n.setter}(${n.missingDep.slice(0,1)} => ...)' if you only need '${n.missingDep}' in the '${n.setter}' call.`;break;default:throw new Error("Unknown case.")}}f({node:$,message:`React Hook ${t(w)} has `+(ne(V,"a","missing","include")||ne(J,"an","unnecessary","exclude")||ne(he,"a","duplicate","omit"))+_,suggest:[{desc:`Update the dependencies array to be: [${Y.map(te).join(", ")}]`,fix(n){return n.replaceText($,`[${Y.map(te).join(", ")}]`)}}]})}function v(g){let $=ft(g.callee,u);if($===-1)return;let w=g.arguments[$],k=g.callee,l=we(k).name,R=g.arguments[$+1],A=/Effect($|[^a-z])/g.test(l);if(!w){f({node:k,message:`React Hook ${l} requires an effect callback. Did you forget to pass a callback to the hook?`});return}if(!R&&!A){(l==="useMemo"||l==="useCallback")&&f({node:k,message:`React Hook ${l} does nothing when called with only one argument. Did you forget to pass an array of dependencies?`});return}switch(w.type){case"FunctionExpression":case"ArrowFunctionExpression":F(w,R,k,l,A);return;case"Identifier":if(!R||R.elements&&R.elements.some(T=>T&&T.type==="Identifier"&&T.name===w.name))return;let S=r(g).set.get(w.name);if(S==null||S.defs==null)return;let D=S.defs[0];if(!D||!D.node||D.type!=="Variable"&&D.type!=="FunctionName")break;switch(D.node.type){case"FunctionDeclaration":F(D.node,R,k,l,A);return;case"VariableDeclarator":let T=D.node.init;if(!T)break;switch(T.type){case"ArrowFunctionExpression":case"FunctionExpression":F(T,R,k,l,A);return}break}break;default:f({node:k,message:`React Hook ${l} received a function whose dependencies are unknown. Pass an inline function instead.`});return}f({node:k,message:`React Hook ${l} has a missing dependency: '${w.name}'. Either include it or remove the dependency array.`,suggest:[{desc:`Update the dependencies array to be: [${w.name}]`,fix(S){return S.replaceText(R,`[${w.name}]`)}}]})}return{CallExpression:v}}};function ie({dependencies:e,declaredDependencies:t,stableDependencies:r,externalDependencies:a,isEffect:o}){let u=f();function f(){return{isUsed:!1,isSatisfiedRecursively:!1,isSubtreeUsed:!1,children:new Map}}e.forEach((v,g)=>{let $=m(u,g);$.isUsed=!0,s(u,g,w=>{w.isSubtreeUsed=!0})}),t.forEach(({key:v})=>{let g=m(u,v);g.isSatisfiedRecursively=!0}),r.forEach(v=>{let g=m(u,v);g.isSatisfiedRecursively=!0});function m(v,g){let $=g.split("."),w=v;for(let k of $){let l=w.children.get(k);l||(l=f(),w.children.set(k,l)),w=l}return w}function s(v,g,$){let w=g.split("."),k=v;for(let l of w){let R=k.children.get(l);if(!R)return;$(R),k=R}}let c=new Set,b=new Set;I(u,c,b,v=>v);function I(v,g,$,w){v.children.forEach((k,l)=>{let R=w(l);if(k.isSatisfiedRecursively){k.isSubtreeUsed&&$.add(R);return}if(k.isUsed){g.add(R);return}I(k,g,$,A=>R+"."+A)})}let M=[],O=new Set,F=new Set;return t.forEach(({key:v})=>{b.has(v)?M.indexOf(v)===-1?M.push(v):F.add(v):O.add(v)}),c.forEach(v=>{M.push(v)}),{suggestedDependencies:M,unnecessaryDependencies:O,duplicateDependencies:F,missingDependencies:c}}function z(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 z(e.consequent)!=null||z(e.alternate)!=null?"conditional":null;case"LogicalExpression":return z(e.left)!=null||z(e.right)!=null?"logical expression":null;case"JSXFragment":return"JSX fragment";case"JSXElement":return"JSX element";case"AssignmentExpression":return z(e.right)!=null?"assignment expression":null;case"NewExpression":return"object construction";case"Literal":return e.value instanceof RegExp?"regular expression":null;case"TypeCastExpression":return z(e.expression);case"TSAsExpression":return z(e.expression)}return null}function ut({declaredDependencies:e,declaredDependenciesNode:t,componentScope:r,scope:a}){let o=e.map(({key:f})=>{let m=r.variables.find(c=>c.name===f);if(m==null)return null;let s=m.defs[0];if(s==null)return null;if(s.type==="Variable"&&s.node.type==="VariableDeclarator"&&s.node.id.type==="Identifier"&&s.node.init!=null){let c=z(s.node.init);if(c!=null)return[m,c]}return s.type==="FunctionName"&&s.node.type==="FunctionDeclaration"?[m,"function"]:s.type==="ClassName"&&s.node.type==="ClassDeclaration"?[m,"class"]:null}).filter(Boolean);function u(f){let m=!1;for(let s=0;s<f.references.length;s++){let c=f.references[s];if(c.writeExpr){if(m)return!0;m=!0;continue}let b=c.from;for(;b!==a&&b!=null;)b=b.upper;if(b!==a&&!Re(t,c.identifier))return!0}return!1}return o.map(([f,m])=>({construction:f.defs[0],depType:m,isUsedOutsideOfHook:u(f)}))}function xe(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)?xe(e.parent):e.type==="MemberExpression"&&e.parent&&e.parent.type==="AssignmentExpression"&&e.parent.left===e?e.object:e}function se(e,t,r){t&&(e.optional?t.has(r)||t.set(r,!0):t.has(r)||t.set(r,!1))}function U(e,t){if(e.type==="Identifier"||e.type==="JSXIdentifier"){let r=e.name;return t&&t.set(r,!1),r}else if(e.type==="MemberExpression"&&!e.computed){let r=U(e.object,t),a=U(e.property,null),o=`${r}.${a}`;return se(e,t,o),o}else if(e.type==="OptionalMemberExpression"&&!e.computed){let r=U(e.object,t),a=U(e.property,null),o=`${r}.${a}`;return se(e,t,o),o}else if(e.type==="ChainExpression"&&!e.computed){let r=e.expression;if(r.type==="CallExpression")throw new Error(`Unsupported node type: ${r.type}`);let a=U(r.object,t),o=U(r.property,null),u=`${a}.${o}`;return se(r,t,u),u}else throw new Error(`Unsupported node type: ${e.type}`)}function we(e,t){return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.object.name==="React"&&e.property.type==="Identifier"&&!e.computed?e.property:e}function ft(e,t){let r=we(e);if(r.type!=="Identifier")return-1;switch(r.name){case"useEffect":case"useLayoutEffect":case"useCallback":case"useMemo":return 0;case"useImperativeHandle":return 1;default:if(r===e&&t&&t.additionalHooks){let a;try{a=U(r,null)}catch(o){if(/Unsupported node type/.test(o.message))return 0;throw o}return t.additionalHooks.test(a)?0:-1}else return-1}}function oe(e,t){let r=[e],a=null;for(;r.length;){if(a=r.shift(),dt(a,t))return a;if(Re(a,t))for(let[o,u]of Object.entries(a))o!=="parent"&&(Se(u)?(u.parent=a,r.push(u)):Array.isArray(u)&&u.forEach(f=>{Se(f)&&(f.parent=a,r.push(f))}))}return null}function pt(e){let t="";for(let r=0;r<e.length;r++)t+=e[r],r===0&&e.length===2?t+=" and ":r===e.length-2&&e.length>2?t+=", and ":r<e.length-1&&(t+=", ");return t}function Se(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function dt(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 Re(e,t){return e.range[0]<=t.range[0]&&e.range[1]>=t.range[1]}function mt(e){return!1}var B=require("@typescript-eslint/utils"),yt=B.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),ke="no-call-with-inferred-generics",gt=yt({name:ke,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){let t=e.options[0],r=new Map(t.functions.map(a=>[a.name,a]));return{CallExpression(a){let{callee:o}=a;if(o.type!==B.AST_NODE_TYPES.Identifier)return;let u=r.get(o.name);if(!u)return;let{minGenerics:f=1,allowAny:m,disallowTypes:s=t.disallowTypes}=u;(a.typeArguments?.params.length||0)<(f||0)&&e.report({node:a,messageId:"missingGenericDeclaration",data:{functionName:o.name,minGenerics:f||0}}),!(m&&!s)&&a.typeArguments?.params?.some(b=>!m&&b.type===B.AST_NODE_TYPES.TSAnyKeyword||s&&b.type===B.AST_NODE_TYPES.TSTypeReference&&b.typeName.type===B.AST_NODE_TYPES.Identifier&&s.includes(b.typeName.name))&&e.report({node:a,messageId:"anyUsedInGenerics",data:{functionName:o.name}})}}}}),ae={name:ke,rule:gt};var q=require("@typescript-eslint/utils"),ht=q.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ie="no-commented-out-code",bt=["function ","class ","interface ","type ","enum ","namespace ","import ","export ","const ","let ","var ","return "],Et=[") {","return;","if (","else {","for (","switch (","/>","</","},",": {"," } = ","={",/\w=("|')/,");"],St=ht({name:Ie,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:function(e){function t(r){if(r.startsWith("/"))return!1;let a=r.trimStart();if(r.startsWith("*")||a.startsWith("INFO:")||a.startsWith("TODO:")||a.startsWith("DOCS:")||a.startsWith("FIX:")||a.startsWith("eslint-disable")||r.includes("@deprecated")||r.includes("@example"))return!1;for(let o of bt)if(a.startsWith(o))return{wrongPattern:o};for(let o of Et)if(typeof o=="string"){if(r.includes(o))return{wrongPattern:o}}else if(o.test(r))return{wrongPattern:`regex(${o.toString()})`};return!1}return{Program(){let a=e.sourceCode.getAllComments();for(let o of a)if(o.type===q.TSESTree.AST_TOKEN_TYPES.Line||o.type===q.TSESTree.AST_TOKEN_TYPES.Block){let u=t(o.value);u&&e.report({node:o,messageId:"commentedOutCode",data:{wrongPattern:u.wrongPattern}})}}}}}),ce={name:Ie,rule:St};var Ce=require("@typescript-eslint/utils"),Tt=Ce.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ae="no-default-export",xt=Tt({name:Ae,meta:{type:"problem",docs:{description:"Disallow default exports"},schema:[],messages:{noDefaultExport:"Default exports are not allowed, use named exports instead."}},defaultOptions:[],create(e){return{ExportDefaultDeclaration(t){e.report({node:t,messageId:"noDefaultExport"})},ExportNamedDeclaration(t){for(let r of t.specifiers)r.exported.name==="default"&&e.report({node:t,messageId:"noDefaultExport"})}}}}),le={name:Ae,rule:xt};var N=require("@typescript-eslint/utils"),wt=N.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),$e="no-non-camel-case-functions",Rt=/^[a-z][a-zA-Z0-9]*$/;function ve(e){return e.typeName.type===N.AST_NODE_TYPES.TSQualifiedName&&e.typeName.left.type===N.AST_NODE_TYPES.Identifier&&e.typeName.left.name==="JSX"&&e.typeName.right.type===N.AST_NODE_TYPES.Identifier&&e.typeName.right.name==="Element"}var kt=wt({name:$e,meta:{type:"suggestion",docs:{description:"Enforce camelCase naming convention for function declarations"},schema:[],messages:{nonCamelCaseFunction:'Function name "{{functionName}}" should be in camelCase format'}},defaultOptions:[],create(e){return{FunctionDeclaration(t){if(t.id&&!Rt.test(t.id.name)){let r=t.returnType?.typeAnnotation;if(r&&(r.type===N.AST_NODE_TYPES.TSTypeReference?ve(r):r.type===N.AST_NODE_TYPES.TSUnionType&&r.types.some(o=>o.type===N.AST_NODE_TYPES.TSTypeReference&&ve(o))))return;e.report({node:t.id,messageId:"nonCamelCaseFunction",data:{functionName:t.id.name}})}}}}}),ue={name:$e,rule:kt};var C=require("@typescript-eslint/utils"),It=C.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function De(e){let t=[];for(let r of e.members)r.type===C.AST_NODE_TYPES.TSPropertySignature&&r.key.type===C.AST_NODE_TYPES.Identifier&&t.push([r.key.name,r]);return t}function Me(e,...t){for(let r of t)e.set(...r);return e}var Fe="no-unused-type-props-in-args",Ct=It({name:Fe,meta:{type:"problem",docs:{description:"Disallow unused undestructured object type properties"},messages:{unusedObjectTypeProperty:"Object type property '{{ propertyName }}' is defined but never used"},schema:[],fixable:"code"},defaultOptions:[],create:function(e){function t(u,f,m,s=!0){let c=f.name,b=e.sourceCode.getScope(u).references.find(M=>M.identifier.name===c)?.resolved;if(!b||b.references.filter(M=>M.isTypeReference).length>1)return;let I=b?.defs[0]?.node;if(!(s&&I?.parent?.type===C.AST_NODE_TYPES.ExportNamedDeclaration)){if(I?.type===C.AST_NODE_TYPES.TSTypeAliasDeclaration){r(u,m,I.typeAnnotation,!0);return}if(I?.type===C.AST_NODE_TYPES.TSInterfaceDeclaration){r(u,m,I.body,!0);return}}}function r(u,f,m,s){if(m.type===C.AST_NODE_TYPES.TSInterfaceBody){for(let c of m.body)c.type===C.AST_NODE_TYPES.TSPropertySignature&&c.key.type===C.AST_NODE_TYPES.Identifier&&f.set(c.key.name,c);return}if(m.type===C.AST_NODE_TYPES.TSTypeLiteral){Me(f,...De(m));return}if(m.type===C.AST_NODE_TYPES.TSIntersectionType){for(let c of m.types)r(u,f,c,!0);return}s||m.type===C.AST_NODE_TYPES.TSTypeReference&&m.typeName.type===C.AST_NODE_TYPES.Identifier&&t(u,m.typeName,f)}function a(u,f){for(let m of f)if(m.type==="ObjectPattern"&&m.typeAnnotation){let s=new Map;if(r(u,s,m.typeAnnotation.typeAnnotation,!1),s.size===0)continue;o(m,s)}else m.type===C.AST_NODE_TYPES.AssignmentPattern&&m.left.type===C.AST_NODE_TYPES.ObjectPattern&&a(u,[m.left])}function o(u,f){let m=[];if(u.properties.at(-1)?.type===C.AST_NODE_TYPES.RestElement)return;for(let I of u.properties)I.type===C.AST_NODE_TYPES.Property&&I.key.type===C.AST_NODE_TYPES.Identifier&&m.push(I.key.name);let c=[],b=[];for(let[I,M]of f)m.includes(I)||(b.push(I),c.push({node:M,messageId:"unusedObjectTypeProperty",data:{propertyName:I}}));for(let[I,M]of c.entries())e.report({...M,fix:I===c.length-1?O=>{let F=u.properties.at(-1),v=b.join(", ");return F?F?.type===C.AST_NODE_TYPES.RestElement?null:O.insertTextAfter(F,`, ${v}`):O.insertTextBeforeRange([u.range[0]+1,u.range[1]],`${v}`)}:void 0})}return{VariableDeclaration:function(u){let f=u.declarations[0];if(!f)return;let m=new Map,s=f.id.type===C.AST_NODE_TYPES.Identifier&&f.id.typeAnnotation?.typeAnnotation.type===C.AST_NODE_TYPES.TSTypeReference&&f.id.typeAnnotation.typeAnnotation.typeName.type===C.AST_NODE_TYPES.Identifier&&f.id.typeAnnotation.typeAnnotation.typeName.name==="FC"&&f.id.typeAnnotation.typeAnnotation.typeArguments?.params[0];if(s){if(s.type===C.AST_NODE_TYPES.TSTypeReference&&s.typeName.type===C.AST_NODE_TYPES.Identifier)t(u,s.typeName,m,!1);else if(s.type===C.AST_NODE_TYPES.TSTypeLiteral)Me(m,...De(s));else if(s.type===C.AST_NODE_TYPES.TSIntersectionType)for(let c of s.types)c.type===C.AST_NODE_TYPES.TSTypeReference&&c.typeName.type===C.AST_NODE_TYPES.Identifier?t(u,c.typeName,m,!1):r(u,m,c,!0);if(m.size!==0&&f.init?.type===C.AST_NODE_TYPES.ArrowFunctionExpression){let c=f.init.params[0];c&&c.type===C.AST_NODE_TYPES.ObjectPattern&&o(c,m)}}},FunctionDeclaration:function(u){a(u,u.params)},ArrowFunctionExpression:function(u){a(u,u.params)}}}}),fe={name:Fe,rule:Ct};var Pe=require("@typescript-eslint/utils"),At=Pe.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),He="prefer-named-functions",Oe=new Map,vt=At({name:He,meta:{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:{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}} () {}" or have a name that matches the regex "{{ignoreRegex}}"'}},defaultOptions:[{}],create(e){let t=e.options[0]||{},r=e.getSourceCode(),a=null;if(t.ignoreRegex){let o=Oe.get(t.ignoreRegex);o?a=o:(a=new RegExp(t.ignoreRegex),Oe.set(t.ignoreRegex,a))}return{VariableDeclarator(o){if(o.init&&o.init.type==="ArrowFunctionExpression"&&o.id.type==="Identifier"){let u=o.id.name;if(o.id.typeAnnotation||a&&a.test(u)||!t.disallowArrowFnWithImplicitReturns&&o.init.body.type!=="BlockStatement")return;e.report({node:o.id,messageId:a?"withIgnoreRegex":"default",data:{functionName:u,ignoreRegex:t.ignoreRegex}})}}}}}),pe={name:He,rule:vt};var je=require("@typescript-eslint/utils"),$t=je.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Le="require-description",Dt=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,Mt=/^eslint-disable-(next-)?line$/u,Ft=$t({name:Le,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){let t=e.sourceCode,r=new Set(e.options[0]&&e.options[0].ignore||[]);return{Program(){for(let a of t.getAllComments()){let o=Ot(a);o!=null&&(r.has(o.kind)||o.description||e.report({loc:Ht(a.loc),messageId:"missingDescription"}))}}}}}),_e={name:Le,rule:Ft};function Ot(e){let{text:t,description:r}=Pt(e.value);if(!t)return null;let a=Dt.exec(t);if(!a)return null;let o=a[1];if(!o)return null;let u=Mt.test(o);if(e.type==="Line"&&!u||u&&e.loc.start.line!==e.loc.end.line)return null;let f=t.slice(a.index+o.length);return{kind:o,value:f.trim(),description:r}}function Pt(e){let t=e.split(/\s-{2,}\s/u);return{text:t[0]?.trim(),description:t.length>1?t[1]?.trim()??null:null}}function Ht(e){return{start:{line:e.start.line,column:-1},end:e.end}}function Ne(e){return/^use[A-Z0-9]/.test(e)}function Z(e){return e.type==="Identifier"?Ne(e.name):e.type==="MemberExpression"&&!e.computed&&Z(e.property)?e.object.type==="Identifier":!1}function Ve(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function ze(e,t){return e.name===t||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===t}function Be(e){return!!(e.parent&&e.parent.callee&&ze(e.parent.callee,"forwardRef"))}function Ge(e){return!!(e.parent&&e.parent.callee&&ze(e.parent.callee,"memo"))}function de(e){for(;e;){let t=qe(e);if(t&&(Ve(t)||Z(t))||Be(e)||Ge(e))return!0;e=e.parent}return!1}function We(e){return!1}function me(e){return!1}var jt=/eslint +react-compiler\/react-compiler: +\["error/,Xe={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 s of e.sourceCode.getAllComments())if(jt.test(s.value))return{CallExpression(c){let b=null;c.callee.name==="useMemo"?b="useMemo":c.callee.name==="useCallback"&&(b="useCallback"),b&&e.report({node:c,message:`"${b}" is not necessary when using React Compiler.`})}}}let t=typeof e.getSource=="function"?s=>t(s):s=>e.sourceCode.getText(s),r=typeof e.getScope=="function"?()=>r():s=>e.sourceCode.getScope(s),a=null,o=[],u=[],f=new WeakSet;function m(s){for(let c of s.references){let b=c.identifier.parent;if(b.type==="VariableDeclarator"&&b.init&&b.init.type==="CallExpression"&&b.init.callee&&We(b.init.callee))for(let I of c.resolved.references)I!==c&&f.add(I.identifier)}}return{onCodePathSegmentStart:s=>u.push(s),onCodePathSegmentEnd:()=>u.pop(),onCodePathStart:()=>o.push(new Map),onCodePathEnd(s,c){let b=o.pop();if(b.size===0)return;let I=new Set;function M(l,R){let{cache:A}=M,S=A.get(l.id),D=new Set(R);if(D.has(l.id)){let T=[...D],P=T.slice(T.indexOf(l.id)+1);for(let L of P)I.add(L);return BigInt("0")}if(D.add(l.id),S!==void 0)return S;if(s.thrownSegments.includes(l))S=BigInt("0");else if(l.prevSegments.length===0)S=BigInt("1");else{S=BigInt("0");for(let T of l.prevSegments)S+=M(T,D)}return l.reachable&&S===BigInt("0")?A.delete(l.id):A.set(l.id,S),S}function O(l,R){let{cache:A}=O,S=A.get(l.id),D=new Set(R);if(D.has(l.id)){let T=Array.from(D),P=T.slice(T.indexOf(l.id)+1);for(let L of P)I.add(L);return BigInt("0")}if(D.add(l.id),S!==void 0)return S;if(s.thrownSegments.includes(l))S=BigInt("0");else if(l.nextSegments.length===0)S=BigInt("1");else{S=BigInt("0");for(let T of l.nextSegments)S+=O(T,D)}return A.set(l.id,S),S}function F(l){let{cache:R}=F,A=R.get(l.id);if(A===null)return 1/0;if(A!==void 0)return A;if(R.set(l.id,null),l.prevSegments.length===0)A=1;else{A=1/0;for(let S of l.prevSegments){let D=F(S);D<A&&(A=D)}A+=1}return R.set(l.id,A),A}M.cache=new Map,O.cache=new Map,F.cache=new Map;let v=O(s.initialSegment),g=qe(c),$=de(c),w=g?Ve(g)||Z(g):Be(c)||Ge(c),k=1/0;for(let l of s.finalSegments){if(!l.reachable)continue;let R=F(l);R<k&&(k=R)}for(let[l,R]of b){if(!l.reachable)continue;let A=l.nextSegments.length===0?k<=F(l):k<F(l),S=M(l)*O(l),D=I.has(l.id);for(let T of R)if(D&&!me(T)&&e.report({node:T,message:`React Hook "${t(T)}" 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.`}),w){if(c.async&&e.report({node:T,message:`React Hook "${t(T)}" cannot be called in an async function.`}),!D&&S!==v&&!me(T)){let L=`React Hook "${t(T)}" is called conditionally. React Hooks must be called in the exact same order in every component render.`+(A?" Did you accidentally call a React Hook after an early return?":"");e.report({node:T,message:L})}}else if(c.parent&&(c.parent.type==="MethodDefinition"||c.parent.type==="ClassProperty")&&c.parent.value===c){let P=`React Hook "${t(T)}" 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:T,message:P})}else if(g){let P=`React Hook "${t(T)}" is called in function "${t(g)}" 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:T,message:P})}else if(c.type==="Program"){let P=`React Hook "${t(T)}" 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:T,message:P})}else if($&&!me(T)){if(c.parent.type==="CallExpression"&&c.parent.callee.type==="Identifier"&&c.parent.callee.name==="useCallback"){let L=c.parent;if(L.parent.type==="VariableDeclarator"&&Ne(L.parent.id.name))return}let P=`React Hook "${t(T)}" 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:T,message:P})}}},CallExpression(s){if(Z(s.callee)){let c=Ue(o),b=Ue(u),I=c.get(b);I||(I=[],c.set(b,I)),I.push(s.callee)}s.callee.type==="Identifier"&&(s.callee.name==="useEffect"||We(s.callee))&&s.arguments.length>0&&(a=s)},Identifier(s){a==null&&f.has(s)&&s.parent.type!=="CallExpression"&&e.report({node:s,message:`\`${t(s)}\` 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"(s){s===a&&(a=null)},FunctionDeclaration(s){de(s)&&m(r(s))},ArrowFunctionExpression(s){de(s)&&m(r(s))}}}};function qe(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 Ue(e){return e[e.length-1]}var Ke={[fe.name]:fe.rule,[ce.name]:ce.rule,[ae.name]:ae.rule,"rules-of-hooks":Xe,"exhaustive-deps":Te,"require-description":_e.rule,[le.name]:le.rule,[ue.name]:ue.rule,[pe.name]:pe.rule};var Lt={rules:Ke};0&&(module.exports={extendedLintPlugin});
12
+ Learn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching`});let R=d.acquire(g),A=new Set,S=null;{let n=R.upper;for(;n&&(A.add(n),n.type!=="function");)n=n.upper;if(!n)return;S=n}let D=Array.isArray;function x(n){if(!D(n.defs))return!1;let s=n.defs[0];if(s==null||s.node.type!=="VariableDeclarator")return!1;let f=s.node.init;if(f==null)return!1;for(;f.type==="TSAsExpression";)f=f.expression;let m=s.node.parent;if(m==null&&(ae(S.block,s.node.id),m=s.node.parent,m==null))return!1;if(m.kind==="const"&&f.type==="Literal"&&(typeof f.value=="string"||typeof f.value=="number"||f.value===null))return!0;if(f.type!=="CallExpression")return!1;let h=f.callee;if(h.type==="MemberExpression"&&h.object.name==="React"&&h.property!=null&&!h.computed&&(h=h.property),h.type!=="Identifier")return!1;let y=s.node.id,{name:E}=h;if(E==="useRef"&&y.type==="Identifier")return!0;if(Et(h)&&y.type==="Identifier"){for(let T of n.references)T!==y&&F.add(T.identifier);return!0}else if(E==="useState"||E==="useReducer"){if(y.type==="ArrayPattern"&&y.elements.length===2&&D(n.identifiers)){if(y.elements[1]===n.identifiers[0]){if(E==="useState"){let T=n.references,H=0;for(let W=0;W<T.length;W++){if(T[W].isWrite()&&H++,H>1)return!1;i.set(T[W].identifier,y.elements[0])}}return!0}else if(y.elements[0]===n.identifiers[0]){if(E==="useState"){let T=n.references;for(let H=0;H<T.length;H++)c.add(T[H].identifier)}return!1}}}else if(E==="useTransition"&&y.type==="ArrayPattern"&&y.elements.length===2&&Array.isArray(n.identifiers)&&y.elements[1]===n.identifiers[0])return!0;return!1}function P(n){if(!D(n.defs))return!1;let s=n.defs[0];if(s==null||s.node==null||s.node.id==null)return!1;let f=s.node,m=S.childScopes,h=null,y;for(y=0;y<m.length;y++){let E=m[y],T=E.block;if(f.type==="FunctionDeclaration"&&T===f||f.type==="VariableDeclarator"&&T.parent===f){h=E;break}}if(h==null)return!1;for(y=0;y<h.through.length;y++){let E=h.through[y];if(E.resolved!=null&&A.has(E.resolved.scope)&&!L(E.resolved))return!1}return!0}let L=O(x,b),Qe=O(P,I),ge=new Map;function et(n){let s=n.from,f=!1;for(;s.block!==g;)s.type==="function"&&(f=s.block.parent!=null&&s.block.parent.type==="ReturnStatement"),s=s.upper;return f}let j=new Map,Q=new Map;he(R);function he(n){for(let s of n.references){if(!s.resolved||!A.has(s.resolved.scope))continue;let f=ae(g,s.identifier),m=ke(f),h=U(m,Q);if(u&&m.type==="Identifier"&&(m.parent.type==="MemberExpression"||m.parent.type==="OptionalMemberExpression")&&!m.parent.computed&&m.parent.property.type==="Identifier"&&m.parent.property.name==="current"&&et(s)&&ge.set(h,{reference:s,dependencyNode:m}),m.parent.type==="TSTypeQuery"||m.parent.type==="TSTypeReference")continue;let y=s.resolved.defs[0];if(y!=null&&!(y.node!=null&&y.node.init===g.parent)&&y.type!=="TypeParameter")if(j.has(h))j.get(h).references.push(s);else{let E=s.resolved,T=L(E)||Qe(E);j.set(h,{isStable:T,references:[s]})}}for(let s of n.childScopes)he(s)}ge.forEach(({reference:n,dependencyNode:s},f)=>{let m=n.resolved.references,h=!1;for(let y=0;y<m.length;y++){let{identifier:E}=m[y],{parent:T}=E;if(T!=null&&T.type==="MemberExpression"&&!T.computed&&T.property.type==="Identifier"&&T.property.name==="current"&&T.parent.type==="AssignmentExpression"&&T.parent.left===T){h=!0;break}}h||l({node:s.parent.property,message:`The ref value '${f}.current' will likely have changed by the time this effect cleanup function runs. If this ref points to a node rendered by React, copy '${f}.current' to a variable inside the effect, and use that variable in the cleanup function.`})});let ee=new Set;function tt(n,s){ee.has(s)||(ee.add(s),l({node:n,message:`Assignments to the '${s}' variable from inside React Hook ${t(w)} 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 ${t(w)}.`}))}let K=new Set;if(j.forEach(({isStable:n,references:s},f)=>{n&&K.add(f),s.forEach(m=>{m.writeExpr&&tt(m.writeExpr,f)})}),ee.size>0)return;if(!$){let n=null;if(j.forEach(({isStable:s,references:f},m)=>{n||f.forEach(h=>{if(n)return;let y=h.identifier;if(!i.has(y))return;let T=h.from;for(;T.type!=="function";)T=T.upper;T.block===g&&(n=m)})}),n){let{suggestedDependencies:s}=ie({dependencies:j,declaredDependencies:[],stableDependencies:K,externalDependencies:new Set,isEffect:!0});l({node:w,message:`React Hook ${k} contains a call to '${n}'. Without a list of dependencies, this can lead to an infinite chain of updates. To fix this, pass [`+s.join(", ")+`] as a second argument to the ${k} Hook.`,suggest:[{desc:`Add dependencies array: [${s.join(", ")}]`,fix(f){return f.insertTextAfter(g,`, [${s.join(", ")}]`)}}]})}return}let X=[],q=new Set;$.type!=="ArrayExpression"?l({node:$,message:`React Hook ${t(w)} 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(n=>{if(n===null)return;if(n.type==="SpreadElement"){l({node:n,message:`React Hook ${t(w)} has a spread element in its dependency array. This means we can't statically verify whether you've passed the correct dependencies.`});return}F.has(n)&&l({node:n,message:`Functions returned from \`useEffectEvent\` must not be included in the dependency array. Remove \`${t(n)}\` from the list.`,suggest:[{desc:`Remove the dependency \`${t(n)}\``,fix(h){return h.removeRange(n.range)}}]});let s;try{s=U(n,Q)}catch(h){if(/Unsupported node type/.test(h.message)){n.type==="Literal"?j.has(n.value)?l({node:n,message:`The ${n.raw} literal is not a valid dependency because it never changes. Did you mean to include ${n.value} in the array instead?`}):l({node:n,message:`The ${n.raw} literal is not a valid dependency because it never changes. You can safely remove it.`}):l({node:n,message:`React Hook ${t(w)} has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked.`});return}else throw h}let f=n;for(;f.type==="MemberExpression"||f.type==="OptionalMemberExpression"||f.type==="ChainExpression";)f=f.object||f.expression.object;let m=!S.through.some(h=>h.identifier===f);X.push({key:s,node:n}),m||q.add(s)});let{suggestedDependencies:nt,unnecessaryDependencies:J,missingDependencies:V,duplicateDependencies:be}=ie({dependencies:j,declaredDependencies:X,stableDependencies:K,externalDependencies:q,isEffect:u}),Y=nt;if(be.size+V.size+J.size===0){yt({declaredDependencies:X,declaredDependenciesNode:$,componentScope:S,scope:R}).forEach(({construction:s,isUsedOutsideOfHook:f,depType:m})=>{let h=m==="function"?"useCallback":"useMemo",y=m==="function"?"definition":"initialization",E=`wrap the ${y} of '${s.name.name}' in its own ${h}() Hook.`,T=f?`To fix this, ${E}`:`Move it inside the ${k} callback. Alternatively, ${E}`,H=m==="conditional"||m==="logical expression"?"could make":"makes",W=`The '${s.name.name}' ${m} ${H} the dependencies of ${k} Hook (at line ${$.loc.start.line}) change on every render. ${T}`,Ee;f&&s.type==="Variable"&&m==="function"&&(Ee=[{desc:`Wrap the ${y} of '${s.name.name}' in its own ${h}() Hook.`,fix(Se){let[st,it]=h==="useMemo"?["useMemo(() => { return ","; })"]:["useCallback(",")"];return[Se.insertTextBefore(s.node.init,st),Se.insertTextAfter(s.node.init,it)]}}]),l({node:s.node,message:W,suggest:Ee})});return}!u&&V.size>0&&(Y=ie({dependencies:j,declaredDependencies:[],stableDependencies:K,externalDependencies:q,isEffect:u}).suggestedDependencies);function rt(){if(X.length===0)return!0;let n=X.map(f=>f.key),s=n.slice().sort();return n.join(",")===s.join(",")}rt()&&Y.sort();function te(n){let s=n.split("."),f="";for(let m=0;m<s.length;m++){if(m!==0){let h=s.slice(0,m+1).join("."),y=Q.get(h)===!0;f+=y?"?.":"."}f+=s[m]}return f}function ne(n,s,f,m){return n.size===0?null:(n.size>1?"":s+" ")+f+" "+(n.size>1?"dependencies":"dependency")+": "+ht(Array.from(n).sort().map(h=>"'"+te(h)+"'"))+`. Either ${m} ${n.size>1?"them":"it"} or remove the dependency array.`}let _="";if(J.size>0){let n=null;if(Array.from(J.keys()).forEach(s=>{n===null&&s.endsWith(".current")&&(n=s)}),n!==null)_=` Mutable values like '${n}' aren't valid dependencies because mutating them doesn't re-render the component.`;else if(q.size>0){let s=Array.from(q)[0];R.set.has(s)||(_=` Outer scope values like '${s}' aren't valid dependencies because mutating them doesn't re-render the component.`)}}if(!_&&V.has("props")){let n=j.get("props");if(n==null)return;let s=n.references;if(!Array.isArray(s))return;let f=!0;for(let m=0;m<s.length;m++){let h=s[m],y=ae(S.block,h.identifier);if(!y){f=!1;break}let E=y.parent;if(E==null){f=!1;break}if(E.type!=="MemberExpression"&&E.type!=="OptionalMemberExpression"){f=!1;break}}f&&(_=` However, 'props' will change when *any* prop changes, so the preferred fix is to destructure the 'props' object outside of the ${k} call and refer to those specific props inside ${t(w)}.`)}if(!_&&V.size>0){let n=null;V.forEach(s=>{if(n)return;let f=S.set.get(s),m=j.get(s);if(m.references[0].resolved!==f)return;let h=f.defs[0];if(h==null||h.name==null||h.type!=="Parameter")return;let y=!1,E;for(let T=0;T<m.references.length;T++)if(E=m.references[T].identifier,E!=null&&E.parent!=null&&(E.parent.type==="CallExpression"||E.parent.type==="OptionalCallExpression")&&E.parent.callee===E){y=!0;break}y&&(n=s)}),n!==null&&(_=` If '${n}' changes too often, find the parent component that defines it and wrap that definition in useCallback.`)}if(!_&&V.size>0){let n=null;if(V.forEach(s=>{if(n!==null)return;let m=j.get(s).references,h,y;for(let E=0;E<m.length;E++){for(h=m[E].identifier,y=h.parent;y!=null&&y!==S.block;){if(y.type==="CallExpression"){let T=i.get(y.callee);if(T!=null){if(T.name===s)n={missingDep:s,setter:y.callee.name,form:"updater"};else if(c.has(h))n={missingDep:s,setter:y.callee.name,form:"reducer"};else{let H=m[E].resolved;if(H!=null){let W=H.defs[0];W!=null&&W.type==="Parameter"&&(n={missingDep:s,setter:y.callee.name,form:"inlineReducer"})}}break}}y=y.parent}if(n!==null)break}}),n!==null)switch(n.form){case"reducer":_=` You can also replace multiple useState variables with useReducer if '${n.setter}' needs the current value of '${n.missingDep}'.`;break;case"inlineReducer":_=` If '${n.setter}' needs the current value of '${n.missingDep}', you can also switch to useReducer instead of useState and read '${n.missingDep}' in the reducer.`;break;case"updater":_=` You can also do a functional update '${n.setter}(${n.missingDep.slice(0,1)} => ...)' if you only need '${n.missingDep}' in the '${n.setter}' call.`;break;default:throw new Error("Unknown case.")}}l({node:$,message:`React Hook ${t(w)} has `+(ne(V,"a","missing","include")||ne(J,"an","unnecessary","exclude")||ne(be,"a","duplicate","omit"))+_,suggest:[{desc:`Update the dependencies array to be: [${Y.map(te).join(", ")}]`,fix(n){return n.replaceText($,`[${Y.map(te).join(", ")}]`)}}]})}function v(g){let $=gt(g.callee,p);if($===-1)return;let w=g.arguments[$],k=g.callee,u=Ie(k).name,R=g.arguments[$+1],A=/Effect($|[^a-z])/g.test(u);if(!w){l({node:k,message:`React Hook ${u} requires an effect callback. Did you forget to pass a callback to the hook?`});return}if(!R&&!A){(u==="useMemo"||u==="useCallback")&&l({node:k,message:`React Hook ${u} does nothing when called with only one argument. Did you forget to pass an array of dependencies?`});return}switch(w.type){case"FunctionExpression":case"ArrowFunctionExpression":M(w,R,k,u,A);return;case"Identifier":if(!R||R.elements&&R.elements.some(x=>x&&x.type==="Identifier"&&x.name===w.name))return;let S=r(g).set.get(w.name);if(S==null||S.defs==null)return;let D=S.defs[0];if(!D||!D.node||D.type!=="Variable"&&D.type!=="FunctionName")break;switch(D.node.type){case"FunctionDeclaration":M(D.node,R,k,u,A);return;case"VariableDeclarator":let x=D.node.init;if(!x)break;switch(x.type){case"ArrowFunctionExpression":case"FunctionExpression":M(x,R,k,u,A);return}break}break;default:l({node:k,message:`React Hook ${u} received a function whose dependencies are unknown. Pass an inline function instead.`});return}l({node:k,message:`React Hook ${u} has a missing dependency: '${w.name}'. Either include it or remove the dependency array.`,suggest:[{desc:`Update the dependencies array to be: [${w.name}]`,fix(S){return S.replaceText(R,`[${w.name}]`)}}]})}return{CallExpression:v}}};function ie({dependencies:e,declaredDependencies:t,stableDependencies:r,externalDependencies:a,isEffect:o}){let p=l();function l(){return{isUsed:!1,isSatisfiedRecursively:!1,isSubtreeUsed:!1,children:new Map}}e.forEach((v,g)=>{let $=d(p,g);$.isUsed=!0,i(p,g,w=>{w.isSubtreeUsed=!0})}),t.forEach(({key:v})=>{let g=d(p,v);g.isSatisfiedRecursively=!0}),r.forEach(v=>{let g=d(p,v);g.isSatisfiedRecursively=!0});function d(v,g){let $=g.split("."),w=v;for(let k of $){let u=w.children.get(k);u||(u=l(),w.children.set(k,u)),w=u}return w}function i(v,g,$){let w=g.split("."),k=v;for(let u of w){let R=k.children.get(u);if(!R)return;$(R),k=R}}let c=new Set,b=new Set;I(p,c,b,v=>v);function I(v,g,$,w){v.children.forEach((k,u)=>{let R=w(u);if(k.isSatisfiedRecursively){k.isSubtreeUsed&&$.add(R);return}if(k.isUsed){g.add(R);return}I(k,g,$,A=>R+"."+A)})}let F=[],O=new Set,M=new Set;return t.forEach(({key:v})=>{b.has(v)?F.indexOf(v)===-1?F.push(v):M.add(v):O.add(v)}),c.forEach(v=>{F.push(v)}),{suggestedDependencies:F,unnecessaryDependencies:O,duplicateDependencies:M,missingDependencies:c}}function z(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 z(e.consequent)!=null||z(e.alternate)!=null?"conditional":null;case"LogicalExpression":return z(e.left)!=null||z(e.right)!=null?"logical expression":null;case"JSXFragment":return"JSX fragment";case"JSXElement":return"JSX element";case"AssignmentExpression":return z(e.right)!=null?"assignment expression":null;case"NewExpression":return"object construction";case"Literal":return e.value instanceof RegExp?"regular expression":null;case"TypeCastExpression":return z(e.expression);case"TSAsExpression":return z(e.expression)}return null}function yt({declaredDependencies:e,declaredDependenciesNode:t,componentScope:r,scope:a}){let o=e.map(({key:l})=>{let d=r.variables.find(c=>c.name===l);if(d==null)return null;let i=d.defs[0];if(i==null)return null;if(i.type==="Variable"&&i.node.type==="VariableDeclarator"&&i.node.id.type==="Identifier"&&i.node.init!=null){let c=z(i.node.init);if(c!=null)return[d,c]}return i.type==="FunctionName"&&i.node.type==="FunctionDeclaration"?[d,"function"]:i.type==="ClassName"&&i.node.type==="ClassDeclaration"?[d,"class"]:null}).filter(Boolean);function p(l){let d=!1;for(let i=0;i<l.references.length;i++){let c=l.references[i];if(c.writeExpr){if(d)return!0;d=!0;continue}let b=c.from;for(;b!==a&&b!=null;)b=b.upper;if(b!==a&&!Ce(t,c.identifier))return!0}return!1}return o.map(([l,d])=>({construction:l.defs[0],depType:d,isUsedOutsideOfHook:p(l)}))}function ke(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)?ke(e.parent):e.type==="MemberExpression"&&e.parent&&e.parent.type==="AssignmentExpression"&&e.parent.left===e?e.object:e}function oe(e,t,r){t&&(e.optional?t.has(r)||t.set(r,!0):t.has(r)||t.set(r,!1))}function U(e,t){if(e.type==="Identifier"||e.type==="JSXIdentifier"){let r=e.name;return t&&t.set(r,!1),r}else if(e.type==="MemberExpression"&&!e.computed){let r=U(e.object,t),a=U(e.property,null),o=`${r}.${a}`;return oe(e,t,o),o}else if(e.type==="OptionalMemberExpression"&&!e.computed){let r=U(e.object,t),a=U(e.property,null),o=`${r}.${a}`;return oe(e,t,o),o}else if(e.type==="ChainExpression"&&!e.computed){let r=e.expression;if(r.type==="CallExpression")throw new Error(`Unsupported node type: ${r.type}`);let a=U(r.object,t),o=U(r.property,null),p=`${a}.${o}`;return oe(r,t,p),p}else throw new Error(`Unsupported node type: ${e.type}`)}function Ie(e,t){return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.object.name==="React"&&e.property.type==="Identifier"&&!e.computed?e.property:e}function gt(e,t){let r=Ie(e);if(r.type!=="Identifier")return-1;switch(r.name){case"useEffect":case"useLayoutEffect":case"useCallback":case"useMemo":return 0;case"useImperativeHandle":return 1;default:if(r===e&&t&&t.additionalHooks){let a;try{a=U(r,null)}catch(o){if(/Unsupported node type/.test(o.message))return 0;throw o}return t.additionalHooks.test(a)?0:-1}else return-1}}function ae(e,t){let r=[e],a=null;for(;r.length;){if(a=r.shift(),bt(a,t))return a;if(Ce(a,t))for(let[o,p]of Object.entries(a))o!=="parent"&&(we(p)?(p.parent=a,r.push(p)):Array.isArray(p)&&p.forEach(l=>{we(l)&&(l.parent=a,r.push(l))}))}return null}function ht(e){let t="";for(let r=0;r<e.length;r++)t+=e[r],r===0&&e.length===2?t+=" and ":r===e.length-2&&e.length>2?t+=", and ":r<e.length-1&&(t+=", ");return t}function we(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function bt(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 Ce(e,t){return e.range[0]<=t.range[0]&&e.range[1]>=t.range[1]}function Et(e){return!1}var B=require("@typescript-eslint/utils"),St=B.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ae="no-call-with-inferred-generics",xt=St({name:Ae,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){let t=e.options[0],r=new Map(t.functions.map(a=>[a.name,a]));return{CallExpression(a){let{callee:o}=a;if(o.type!==B.AST_NODE_TYPES.Identifier)return;let p=r.get(o.name);if(!p)return;let{minGenerics:l=1,allowAny:d,disallowTypes:i=t.disallowTypes}=p;(a.typeArguments?.params.length||0)<(l||0)&&e.report({node:a,messageId:"missingGenericDeclaration",data:{functionName:o.name,minGenerics:l||0}}),!(d&&!i)&&a.typeArguments?.params?.some(b=>!d&&b.type===B.AST_NODE_TYPES.TSAnyKeyword||i&&b.type===B.AST_NODE_TYPES.TSTypeReference&&b.typeName.type===B.AST_NODE_TYPES.Identifier&&i.includes(b.typeName.name))&&e.report({node:a,messageId:"anyUsedInGenerics",data:{functionName:o.name}})}}}}),ce={name:Ae,rule:xt};var G=require("@typescript-eslint/utils"),Tt=G.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),ve="no-commented-out-code",wt=["function ","class ","interface ","type ","enum ","namespace ","import ","export ","const ","let ","var ","return "],Rt=[") {","return;","if (","else {","for (","switch (","/>","</","},",": {"," } = ","={",/\w=("|')/,");"],kt=Tt({name:ve,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:function(e){function t(r){if(r.startsWith("/"))return!1;let a=r.trimStart();if(r.startsWith("*")||a.startsWith("INFO:")||a.startsWith("TODO:")||a.startsWith("DOCS:")||a.startsWith("FIX:")||a.startsWith("eslint-disable")||r.includes("@deprecated")||r.includes("@example"))return!1;for(let o of wt)if(a.startsWith(o))return{wrongPattern:o};for(let o of Rt)if(typeof o=="string"){if(r.includes(o))return{wrongPattern:o}}else if(o.test(r))return{wrongPattern:`regex(${o.toString()})`};return!1}return{Program(){let a=e.sourceCode.getAllComments();for(let o of a)if(o.type===G.TSESTree.AST_TOKEN_TYPES.Line||o.type===G.TSESTree.AST_TOKEN_TYPES.Block){let p=t(o.value);p&&e.report({node:o,messageId:"commentedOutCode",data:{wrongPattern:p.wrongPattern}})}}}}}),le={name:ve,rule:kt};var $e=require("@typescript-eslint/utils"),It=$e.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),De="no-default-export",Ct=It({name:De,meta:{type:"problem",docs:{description:"Disallow default exports"},schema:[],messages:{noDefaultExport:"Default exports are not allowed, use named exports instead."}},defaultOptions:[],create(e){return{ExportDefaultDeclaration(t){e.report({node:t,messageId:"noDefaultExport"})},ExportNamedDeclaration(t){for(let r of t.specifiers)r.exported.name==="default"&&e.report({node:t,messageId:"noDefaultExport"})}}}}),ue={name:De,rule:Ct};var N=require("@typescript-eslint/utils"),At=N.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Me="no-non-camel-case-functions",vt=/^[a-z][a-zA-Z0-9]*$/;function Fe(e){return e.typeName.type===N.AST_NODE_TYPES.TSQualifiedName&&e.typeName.left.type===N.AST_NODE_TYPES.Identifier&&e.typeName.left.name==="JSX"&&e.typeName.right.type===N.AST_NODE_TYPES.Identifier&&e.typeName.right.name==="Element"}var $t=At({name:Me,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&&!vt.test(t.id.name)){let r=t.returnType?.typeAnnotation;if(r&&(r.type===N.AST_NODE_TYPES.TSTypeReference?Fe(r):r.type===N.AST_NODE_TYPES.TSUnionType&&r.types.some(o=>o.type===N.AST_NODE_TYPES.TSTypeReference&&Fe(o))))return;e.report({node:t.id,messageId:"nonCamelCaseFunction",data:{functionName:t.id.name}})}}}}}),pe={name:Me,rule:$t};var C=require("@typescript-eslint/utils"),Dt=C.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function Oe(e){let t=[];for(let r of e.members)r.type===C.AST_NODE_TYPES.TSPropertySignature&&r.key.type===C.AST_NODE_TYPES.Identifier&&t.push([r.key.name,r]);return t}function Pe(e,...t){for(let r of t)e.set(...r);return e}var je="no-unused-type-props-in-args",Ft=Dt({name:je,meta:{type:"problem",docs:{description:"Disallow unused undestructured object type properties"},messages:{unusedObjectTypeProperty:"Object type property '{{ propertyName }}' is defined but never used"},schema:[],fixable:"code"},defaultOptions:[],create:function(e){function t(p,l,d,i=!0){let c=l.name,b=e.sourceCode.getScope(p).references.find(F=>F.identifier.name===c)?.resolved;if(!b||b.references.filter(F=>F.isTypeReference).length>1)return;let I=b?.defs[0]?.node;if(!(i&&I?.parent?.type===C.AST_NODE_TYPES.ExportNamedDeclaration)){if(I?.type===C.AST_NODE_TYPES.TSTypeAliasDeclaration){r(p,d,I.typeAnnotation,!0);return}if(I?.type===C.AST_NODE_TYPES.TSInterfaceDeclaration){r(p,d,I.body,!0);return}}}function r(p,l,d,i){if(d.type===C.AST_NODE_TYPES.TSInterfaceBody){for(let c of d.body)c.type===C.AST_NODE_TYPES.TSPropertySignature&&c.key.type===C.AST_NODE_TYPES.Identifier&&l.set(c.key.name,c);return}if(d.type===C.AST_NODE_TYPES.TSTypeLiteral){Pe(l,...Oe(d));return}if(d.type===C.AST_NODE_TYPES.TSIntersectionType){for(let c of d.types)r(p,l,c,!0);return}i||d.type===C.AST_NODE_TYPES.TSTypeReference&&d.typeName.type===C.AST_NODE_TYPES.Identifier&&t(p,d.typeName,l)}function a(p,l){for(let d of l)if(d.type==="ObjectPattern"&&d.typeAnnotation){let i=new Map;if(r(p,i,d.typeAnnotation.typeAnnotation,!1),i.size===0)continue;o(d,i)}else d.type===C.AST_NODE_TYPES.AssignmentPattern&&d.left.type===C.AST_NODE_TYPES.ObjectPattern&&a(p,[d.left])}function o(p,l){let d=[];if(p.properties.at(-1)?.type===C.AST_NODE_TYPES.RestElement)return;for(let I of p.properties)I.type===C.AST_NODE_TYPES.Property&&I.key.type===C.AST_NODE_TYPES.Identifier&&d.push(I.key.name);let c=[],b=[];for(let[I,F]of l)d.includes(I)||(b.push(I),c.push({node:F,messageId:"unusedObjectTypeProperty",data:{propertyName:I}}));for(let[I,F]of c.entries())e.report({...F,fix:I===c.length-1?O=>{let M=p.properties.at(-1),v=b.join(", ");return M?M?.type===C.AST_NODE_TYPES.RestElement?null:O.insertTextAfter(M,`, ${v}`):O.insertTextBeforeRange([p.range[0]+1,p.range[1]],`${v}`)}:void 0})}return{VariableDeclaration:function(p){let l=p.declarations[0];if(!l)return;let d=new Map,i=l.id.type===C.AST_NODE_TYPES.Identifier&&l.id.typeAnnotation?.typeAnnotation.type===C.AST_NODE_TYPES.TSTypeReference&&l.id.typeAnnotation.typeAnnotation.typeName.type===C.AST_NODE_TYPES.Identifier&&l.id.typeAnnotation.typeAnnotation.typeName.name==="FC"&&l.id.typeAnnotation.typeAnnotation.typeArguments?.params[0];if(i){if(i.type===C.AST_NODE_TYPES.TSTypeReference&&i.typeName.type===C.AST_NODE_TYPES.Identifier)t(p,i.typeName,d,!1);else if(i.type===C.AST_NODE_TYPES.TSTypeLiteral)Pe(d,...Oe(i));else if(i.type===C.AST_NODE_TYPES.TSIntersectionType)for(let c of i.types)c.type===C.AST_NODE_TYPES.TSTypeReference&&c.typeName.type===C.AST_NODE_TYPES.Identifier?t(p,c.typeName,d,!1):r(p,d,c,!0);if(d.size!==0&&l.init?.type===C.AST_NODE_TYPES.ArrowFunctionExpression){let c=l.init.params[0];c&&c.type===C.AST_NODE_TYPES.ObjectPattern&&o(c,d)}}},FunctionDeclaration:function(p){a(p,p.params)},ArrowFunctionExpression:function(p){a(p,p.params)}}}}),fe={name:je,rule:Ft};var Le=require("@typescript-eslint/utils"),Mt=Le.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),_e="prefer-named-functions",He=new Map,Ot=Mt({name:_e,meta:{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:{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` or have a name that matches the rule ignore regex'}},defaultOptions:[{}],create(e){let t=e.options[0]||{},r=null;if(t.ignoreRegex){let a=He.get(t.ignoreRegex);a?r=a:(r=new RegExp(t.ignoreRegex),He.set(t.ignoreRegex,r))}return{VariableDeclarator(a){if(a.init&&a.init.type==="ArrowFunctionExpression"&&a.id.type==="Identifier"){let o=a.id.name;if(a.id.typeAnnotation||r&&r.test(o)||!t.disallowArrowFnWithImplicitReturns&&a.init.body.type!=="BlockStatement")return;e.report({node:a.id,messageId:r?"withIgnoreRegex":"default",data:{functionName:o,ignoreRegex:t.ignoreRegex}})}}}}}),de={name:_e,rule:Ot};var We=require("@typescript-eslint/utils"),Pt=We.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ue="require-description",jt=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,Ht=/^eslint-disable-(next-)?line$/u,Lt=Pt({name:Ue,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){let t=e.sourceCode,r=new Set(e.options[0]&&e.options[0].ignore||[]);return{Program(){for(let a of t.getAllComments()){let o=_t(a);o!=null&&(r.has(o.kind)||o.description||e.report({loc:Ut(a.loc),messageId:"missingDescription"}))}}}}}),Ne={name:Ue,rule:Lt};function _t(e){let{text:t,description:r}=Wt(e.value);if(!t)return null;let a=jt.exec(t);if(!a)return null;let o=a[1];if(!o)return null;let p=Ht.test(o);if(e.type==="Line"&&!p||p&&e.loc.start.line!==e.loc.end.line)return null;let l=t.slice(a.index+o.length);return{kind:o,value:l.trim(),description:r}}function Wt(e){let t=e.split(/\s-{2,}\s/u);return{text:t[0]?.trim(),description:t.length>1?t[1]?.trim()??null:null}}function Ut(e){return{start:{line:e.start.line,column:-1},end:e.end}}function Be(e){return/^use[A-Z0-9]/.test(e)}function Z(e){return e.type==="Identifier"?Be(e.name):e.type==="MemberExpression"&&!e.computed&&Z(e.property)?e.object.type==="Identifier":!1}function Xe(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function qe(e,t){return e.name===t||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===t}function Ge(e){return!!(e.parent&&e.parent.callee&&qe(e.parent.callee,"forwardRef"))}function Ke(e){return!!(e.parent&&e.parent.callee&&qe(e.parent.callee,"memo"))}function me(e){for(;e;){let t=Ye(e);if(t&&(Xe(t)||Z(t))||Ge(e)||Ke(e))return!0;e=e.parent}return!1}function Ve(e){return!1}function ye(e){return!1}var Nt=/eslint +react-compiler\/react-compiler: +\["error/,Je={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 i of e.sourceCode.getAllComments())if(Nt.test(i.value))return{CallExpression(c){let b=null;c.callee.name==="useMemo"?b="useMemo":c.callee.name==="useCallback"&&(b="useCallback"),b&&e.report({node:c,message:`"${b}" is not necessary when using React Compiler.`})}}}let t=typeof e.getSource=="function"?i=>t(i):i=>e.sourceCode.getText(i),r=typeof e.getScope=="function"?()=>r():i=>e.sourceCode.getScope(i),a=null,o=[],p=[],l=new WeakSet;function d(i){for(let c of i.references){let b=c.identifier.parent;if(b.type==="VariableDeclarator"&&b.init&&b.init.type==="CallExpression"&&b.init.callee&&Ve(b.init.callee))for(let I of c.resolved.references)I!==c&&l.add(I.identifier)}}return{onCodePathSegmentStart:i=>p.push(i),onCodePathSegmentEnd:()=>p.pop(),onCodePathStart:()=>o.push(new Map),onCodePathEnd(i,c){let b=o.pop();if(b.size===0)return;let I=new Set;function F(u,R){let{cache:A}=F,S=A.get(u.id),D=new Set(R);if(D.has(u.id)){let x=[...D],P=x.slice(x.indexOf(u.id)+1);for(let L of P)I.add(L);return BigInt("0")}if(D.add(u.id),S!==void 0)return S;if(i.thrownSegments.includes(u))S=BigInt("0");else if(u.prevSegments.length===0)S=BigInt("1");else{S=BigInt("0");for(let x of u.prevSegments)S+=F(x,D)}return u.reachable&&S===BigInt("0")?A.delete(u.id):A.set(u.id,S),S}function O(u,R){let{cache:A}=O,S=A.get(u.id),D=new Set(R);if(D.has(u.id)){let x=Array.from(D),P=x.slice(x.indexOf(u.id)+1);for(let L of P)I.add(L);return BigInt("0")}if(D.add(u.id),S!==void 0)return S;if(i.thrownSegments.includes(u))S=BigInt("0");else if(u.nextSegments.length===0)S=BigInt("1");else{S=BigInt("0");for(let x of u.nextSegments)S+=O(x,D)}return A.set(u.id,S),S}function M(u){let{cache:R}=M,A=R.get(u.id);if(A===null)return 1/0;if(A!==void 0)return A;if(R.set(u.id,null),u.prevSegments.length===0)A=1;else{A=1/0;for(let S of u.prevSegments){let D=M(S);D<A&&(A=D)}A+=1}return R.set(u.id,A),A}F.cache=new Map,O.cache=new Map,M.cache=new Map;let v=O(i.initialSegment),g=Ye(c),$=me(c),w=g?Xe(g)||Z(g):Ge(c)||Ke(c),k=1/0;for(let u of i.finalSegments){if(!u.reachable)continue;let R=M(u);R<k&&(k=R)}for(let[u,R]of b){if(!u.reachable)continue;let A=u.nextSegments.length===0?k<=M(u):k<M(u),S=F(u)*O(u),D=I.has(u.id);for(let x of R)if(D&&!ye(x)&&e.report({node:x,message:`React Hook "${t(x)}" may be executed more than once. Possibly because it is called in a loop. React Hooks must be called in the exact same order in every component render.`}),w){if(c.async&&e.report({node:x,message:`React Hook "${t(x)}" cannot be called in an async function.`}),!D&&S!==v&&!ye(x)){let L=`React Hook "${t(x)}" is called conditionally. React Hooks must be called in the exact same order in every component render.`+(A?" Did you accidentally call a React Hook after an early return?":"");e.report({node:x,message:L})}}else if(c.parent&&(c.parent.type==="MethodDefinition"||c.parent.type==="ClassProperty")&&c.parent.value===c){let P=`React Hook "${t(x)}" cannot be called in a class component. React Hooks must be called in a React function component or a custom React Hook function.`;e.report({node:x,message:P})}else if(g){let P=`React Hook "${t(x)}" is called in function "${t(g)}" that is neither a React function component nor a custom React Hook function. React component names must start with an uppercase letter. React Hook names must start with the word "use".`;e.report({node:x,message:P})}else if(c.type==="Program"){let P=`React Hook "${t(x)}" cannot be called at the top level. React Hooks must be called in a React function component or a custom React Hook function.`;e.report({node:x,message:P})}else if($&&!ye(x)){if(c.parent.type==="CallExpression"&&c.parent.callee.type==="Identifier"&&c.parent.callee.name==="useCallback"){let L=c.parent;if(L.parent.type==="VariableDeclarator"&&Be(L.parent.id.name))return}let P=`React Hook "${t(x)}" cannot be called inside a callback. React Hooks must be called in a React function component or a custom React Hook function.`;e.report({node:x,message:P})}}},CallExpression(i){if(Z(i.callee)){let c=ze(o),b=ze(p),I=c.get(b);I||(I=[],c.set(b,I)),I.push(i.callee)}i.callee.type==="Identifier"&&(i.callee.name==="useEffect"||Ve(i.callee))&&i.arguments.length>0&&(a=i)},Identifier(i){a==null&&l.has(i)&&i.parent.type!=="CallExpression"&&e.report({node:i,message:`\`${t(i)}\` 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"(i){i===a&&(a=null)},FunctionDeclaration(i){me(i)&&d(r(i))},ArrowFunctionExpression(i){me(i)&&d(r(i))}}}};function Ye(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 ze(e){return e[e.length-1]}var Ze={[fe.name]:fe.rule,[le.name]:le.rule,[ce.name]:ce.rule,"rules-of-hooks":Je,"exhaustive-deps":Re,"require-description":Ne.rule,[ue.name]:ue.rule,[pe.name]:pe.rule,[de.name]:de.rule,[se.name]:se.rule};var Vt={rules:Ze};0&&(module.exports={extendedLintPlugin});
@@ -1,4 +1,4 @@
1
- var Qe=/eslint +react-compiler\/react-compiler: +\["error/,Ee={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){if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let g of e.sourceCode.getAllComments())if(Qe.test(g.value))return{}}let t=typeof e.getSource=="function"?g=>t(g):g=>e.sourceCode.getText(g),i=typeof e.getScope=="function"?()=>i():g=>e.sourceCode.getScope(g),c=e.options&&e.options[0]&&e.options[0].additionalHooks?new RegExp(e.options[0].additionalHooks):void 0,o=e.options&&e.options[0]&&e.options[0].enableDangerousAutofixThisMayCauseInfiniteLoops||!1,u={additionalHooks:c,enableDangerousAutofixThisMayCauseInfiniteLoops:o};function f(g){o&&Array.isArray(g.suggest)&&g.suggest.length>0&&(g.fix=g.suggest[0].fix),e.report(g)}let m=e.getSourceCode().scopeManager,s=new WeakMap,a=new WeakSet,b=new WeakMap,I=new WeakMap,M=new WeakSet;function O(g,$){return function(w){if($.has(w))return $.get(w);let k=g(w);return $.set(w,k),k}}function F(g,$,w,k,l){l&&g.async&&f({node:g,message:`Effect callbacks are synchronous to prevent race conditions. Put the async function inside:
1
+ import{ESLintUtils as tt}from"@typescript-eslint/utils";var nt=tt.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ee="advanced-no-restricted-syntax",rt=nt({name:Ee,meta:{type:"suggestion",docs:{description:"Disallow specific syntax patterns"},schema:[{type:"object",properties:{disallow:{type:"array",items:{type:"object",properties:{selector:{type:"string"},message:{type:"string"},replace:{oneOf:[{type:"string"},{type:"object",properties:{regex:{type:"string"},with:{type:"string"}},required:["regex","with"],additionalProperties:!1}]},replaceType:{type:"string",enum:["suggestion","autofix"]}},required:["selector","message"],additionalProperties:!1}}},additionalProperties:!1}],messages:{default:"{{message}}"},fixable:"code",hasSuggestions:!0},defaultOptions:[{disallow:[]}],create(e){let t={};for(let{selector:r,message:o,replace:a,replaceType:p="suggestion"}of e.options[0].disallow??[])t[r]=l=>{let d=i=>{if(!a)return null;if(typeof a=="string")return i.replaceText(l,a);{let c=new RegExp(a.regex),b=e.sourceCode.getText(l);return i.replaceText(l,b.replace(c,a.with))}};e.report({node:l,messageId:"default",data:{message:o},fix:a&&p==="autofix"?d:void 0,suggest:a&&p==="suggestion"?[{messageId:"default",data:{message:`Replace with "${typeof a=="string"?a:a.with}"`},fix:d}]:void 0})};return t}}),ne={name:Ee,rule:rt};var st=/eslint +react-compiler\/react-compiler: +\["error/,xe={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){if(e.options[0]?.ignoreIfReactCompilerIsEnabled){for(let g of e.sourceCode.getAllComments())if(st.test(g.value))return{}}let t=typeof e.getSource=="function"?g=>t(g):g=>e.sourceCode.getText(g),r=typeof e.getScope=="function"?()=>r():g=>e.sourceCode.getScope(g),o=e.options&&e.options[0]&&e.options[0].additionalHooks?new RegExp(e.options[0].additionalHooks):void 0,a=e.options&&e.options[0]&&e.options[0].enableDangerousAutofixThisMayCauseInfiniteLoops||!1,p={additionalHooks:o,enableDangerousAutofixThisMayCauseInfiniteLoops:a};function l(g){a&&Array.isArray(g.suggest)&&g.suggest.length>0&&(g.fix=g.suggest[0].fix),e.report(g)}let d=e.getSourceCode().scopeManager,i=new WeakMap,c=new WeakSet,b=new WeakMap,I=new WeakMap,F=new WeakSet;function O(g,$){return function(w){if($.has(w))return $.get(w);let k=g(w);return $.set(w,k),k}}function M(g,$,w,k,u){u&&g.async&&l({node:g,message:`Effect callbacks are synchronous to prevent race conditions. Put the async function inside:
2
2
 
3
3
  useEffect(() => {
4
4
  async function fetchData() {
@@ -9,4 +9,4 @@ useEffect(() => {
9
9
  fetchData();
10
10
  }, [someId]); // Or [] if effect doesn't need props or state
11
11
 
12
- Learn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching`});let R=m.acquire(g),C=new Set,S=null;{let n=R.upper;for(;n&&(C.add(n),n.type!=="function");)n=n.upper;if(!n)return;S=n}let D=Array.isArray;function T(n){if(!D(n.defs))return!1;let r=n.defs[0];if(r==null||r.node.type!=="VariableDeclarator")return!1;let p=r.node.init;if(p==null)return!1;for(;p.type==="TSAsExpression";)p=p.expression;let d=r.node.parent;if(d==null&&(ie(S.block,r.node.id),d=r.node.parent,d==null))return!1;if(d.kind==="const"&&p.type==="Literal"&&(typeof p.value=="string"||typeof p.value=="number"||p.value===null))return!0;if(p.type!=="CallExpression")return!1;let h=p.callee;if(h.type==="MemberExpression"&&h.object.name==="React"&&h.property!=null&&!h.computed&&(h=h.property),h.type!=="Identifier")return!1;let y=r.node.id,{name:E}=h;if(E==="useRef"&&y.type==="Identifier")return!0;if(it(h)&&y.type==="Identifier"){for(let x of n.references)x!==y&&M.add(x.identifier);return!0}else if(E==="useState"||E==="useReducer"){if(y.type==="ArrayPattern"&&y.elements.length===2&&D(n.identifiers)){if(y.elements[1]===n.identifiers[0]){if(E==="useState"){let x=n.references,j=0;for(let W=0;W<x.length;W++){if(x[W].isWrite()&&j++,j>1)return!1;s.set(x[W].identifier,y.elements[0])}}return!0}else if(y.elements[0]===n.identifiers[0]){if(E==="useState"){let x=n.references;for(let j=0;j<x.length;j++)a.add(x[j].identifier)}return!1}}}else if(E==="useTransition"&&y.type==="ArrayPattern"&&y.elements.length===2&&Array.isArray(n.identifiers)&&y.elements[1]===n.identifiers[0])return!0;return!1}function P(n){if(!D(n.defs))return!1;let r=n.defs[0];if(r==null||r.node==null||r.node.id==null)return!1;let p=r.node,d=S.childScopes,h=null,y;for(y=0;y<d.length;y++){let E=d[y],x=E.block;if(p.type==="FunctionDeclaration"&&x===p||p.type==="VariableDeclarator"&&x.parent===p){h=E;break}}if(h==null)return!1;for(y=0;y<h.through.length;y++){let E=h.through[y];if(E.resolved!=null&&C.has(E.resolved.scope)&&!L(E.resolved))return!1}return!0}let L=O(T,b),Ge=O(P,I),de=new Map;function Xe(n){let r=n.from,p=!1;for(;r.block!==g;)r.type==="function"&&(p=r.block.parent!=null&&r.block.parent.type==="ReturnStatement"),r=r.upper;return p}let H=new Map,Z=new Map;me(R);function me(n){for(let r of n.references){if(!r.resolved||!C.has(r.resolved.scope))continue;let p=ie(g,r.identifier),d=Se(p),h=U(d,Z);if(l&&d.type==="Identifier"&&(d.parent.type==="MemberExpression"||d.parent.type==="OptionalMemberExpression")&&!d.parent.computed&&d.parent.property.type==="Identifier"&&d.parent.property.name==="current"&&Xe(r)&&de.set(h,{reference:r,dependencyNode:d}),d.parent.type==="TSTypeQuery"||d.parent.type==="TSTypeReference")continue;let y=r.resolved.defs[0];if(y!=null&&!(y.node!=null&&y.node.init===g.parent)&&y.type!=="TypeParameter")if(H.has(h))H.get(h).references.push(r);else{let E=r.resolved,x=L(E)||Ge(E);H.set(h,{isStable:x,references:[r]})}}for(let r of n.childScopes)me(r)}de.forEach(({reference:n,dependencyNode:r},p)=>{let d=n.resolved.references,h=!1;for(let y=0;y<d.length;y++){let{identifier:E}=d[y],{parent:x}=E;if(x!=null&&x.type==="MemberExpression"&&!x.computed&&x.property.type==="Identifier"&&x.property.name==="current"&&x.parent.type==="AssignmentExpression"&&x.parent.left===x){h=!0;break}}h||f({node:r.parent.property,message:`The ref value '${p}.current' will likely have changed by the time this effect cleanup function runs. If this ref points to a node rendered by React, copy '${p}.current' to a variable inside the effect, and use that variable in the cleanup function.`})});let Q=new Set;function qe(n,r){Q.has(r)||(Q.add(r),f({node:n,message:`Assignments to the '${r}' variable from inside React Hook ${t(w)} 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 ${t(w)}.`}))}let X=new Set;if(H.forEach(({isStable:n,references:r},p)=>{n&&X.add(p),r.forEach(d=>{d.writeExpr&&qe(d.writeExpr,p)})}),Q.size>0)return;if(!$){let n=null;if(H.forEach(({isStable:r,references:p},d)=>{n||p.forEach(h=>{if(n)return;let y=h.identifier;if(!s.has(y))return;let x=h.from;for(;x.type!=="function";)x=x.upper;x.block===g&&(n=d)})}),n){let{suggestedDependencies:r}=ne({dependencies:H,declaredDependencies:[],stableDependencies:X,externalDependencies:new Set,isEffect:!0});f({node:w,message:`React Hook ${k} contains a call to '${n}'. Without a list of dependencies, this can lead to an infinite chain of updates. To fix this, pass [`+r.join(", ")+`] as a second argument to the ${k} Hook.`,suggest:[{desc:`Add dependencies array: [${r.join(", ")}]`,fix(p){return p.insertTextAfter(g,`, [${r.join(", ")}]`)}}]})}return}let B=[],G=new Set;$.type!=="ArrayExpression"?f({node:$,message:`React Hook ${t(w)} 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(n=>{if(n===null)return;if(n.type==="SpreadElement"){f({node:n,message:`React Hook ${t(w)} has a spread element in its dependency array. This means we can't statically verify whether you've passed the correct dependencies.`});return}M.has(n)&&f({node:n,message:`Functions returned from \`useEffectEvent\` must not be included in the dependency array. Remove \`${t(n)}\` from the list.`,suggest:[{desc:`Remove the dependency \`${t(n)}\``,fix(h){return h.removeRange(n.range)}}]});let r;try{r=U(n,Z)}catch(h){if(/Unsupported node type/.test(h.message)){n.type==="Literal"?H.has(n.value)?f({node:n,message:`The ${n.raw} literal is not a valid dependency because it never changes. Did you mean to include ${n.value} in the array instead?`}):f({node:n,message:`The ${n.raw} literal is not a valid dependency because it never changes. You can safely remove it.`}):f({node:n,message:`React Hook ${t(w)} has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked.`});return}else throw h}let p=n;for(;p.type==="MemberExpression"||p.type==="OptionalMemberExpression"||p.type==="ChainExpression";)p=p.object||p.expression.object;let d=!S.through.some(h=>h.identifier===p);B.push({key:r,node:n}),d||G.add(r)});let{suggestedDependencies:Ke,unnecessaryDependencies:q,missingDependencies:N,duplicateDependencies:ye}=ne({dependencies:H,declaredDependencies:B,stableDependencies:X,externalDependencies:G,isEffect:l}),K=Ke;if(ye.size+N.size+q.size===0){et({declaredDependencies:B,declaredDependenciesNode:$,componentScope:S,scope:R}).forEach(({construction:r,isUsedOutsideOfHook:p,depType:d})=>{let h=d==="function"?"useCallback":"useMemo",y=d==="function"?"definition":"initialization",E=`wrap the ${y} of '${r.name.name}' in its own ${h}() Hook.`,x=p?`To fix this, ${E}`:`Move it inside the ${k} callback. Alternatively, ${E}`,j=d==="conditional"||d==="logical expression"?"could make":"makes",W=`The '${r.name.name}' ${d} ${j} the dependencies of ${k} Hook (at line ${$.loc.start.line}) change on every render. ${x}`,ge;p&&r.type==="Variable"&&d==="function"&&(ge=[{desc:`Wrap the ${y} of '${r.name.name}' in its own ${h}() Hook.`,fix(he){let[Ye,Ze]=h==="useMemo"?["useMemo(() => { return ","; })"]:["useCallback(",")"];return[he.insertTextBefore(r.node.init,Ye),he.insertTextAfter(r.node.init,Ze)]}}]),f({node:r.node,message:W,suggest:ge})});return}!l&&N.size>0&&(K=ne({dependencies:H,declaredDependencies:[],stableDependencies:X,externalDependencies:G,isEffect:l}).suggestedDependencies);function Je(){if(B.length===0)return!0;let n=B.map(p=>p.key),r=n.slice().sort();return n.join(",")===r.join(",")}Je()&&K.sort();function ee(n){let r=n.split("."),p="";for(let d=0;d<r.length;d++){if(d!==0){let h=r.slice(0,d+1).join("."),y=Z.get(h)===!0;p+=y?"?.":"."}p+=r[d]}return p}function te(n,r,p,d){return n.size===0?null:(n.size>1?"":r+" ")+p+" "+(n.size>1?"dependencies":"dependency")+": "+nt(Array.from(n).sort().map(h=>"'"+ee(h)+"'"))+`. Either ${d} ${n.size>1?"them":"it"} or remove the dependency array.`}let _="";if(q.size>0){let n=null;if(Array.from(q.keys()).forEach(r=>{n===null&&r.endsWith(".current")&&(n=r)}),n!==null)_=` Mutable values like '${n}' aren't valid dependencies because mutating them doesn't re-render the component.`;else if(G.size>0){let r=Array.from(G)[0];R.set.has(r)||(_=` Outer scope values like '${r}' aren't valid dependencies because mutating them doesn't re-render the component.`)}}if(!_&&N.has("props")){let n=H.get("props");if(n==null)return;let r=n.references;if(!Array.isArray(r))return;let p=!0;for(let d=0;d<r.length;d++){let h=r[d],y=ie(S.block,h.identifier);if(!y){p=!1;break}let E=y.parent;if(E==null){p=!1;break}if(E.type!=="MemberExpression"&&E.type!=="OptionalMemberExpression"){p=!1;break}}p&&(_=` However, 'props' will change when *any* prop changes, so the preferred fix is to destructure the 'props' object outside of the ${k} call and refer to those specific props inside ${t(w)}.`)}if(!_&&N.size>0){let n=null;N.forEach(r=>{if(n)return;let p=S.set.get(r),d=H.get(r);if(d.references[0].resolved!==p)return;let h=p.defs[0];if(h==null||h.name==null||h.type!=="Parameter")return;let y=!1,E;for(let x=0;x<d.references.length;x++)if(E=d.references[x].identifier,E!=null&&E.parent!=null&&(E.parent.type==="CallExpression"||E.parent.type==="OptionalCallExpression")&&E.parent.callee===E){y=!0;break}y&&(n=r)}),n!==null&&(_=` If '${n}' changes too often, find the parent component that defines it and wrap that definition in useCallback.`)}if(!_&&N.size>0){let n=null;if(N.forEach(r=>{if(n!==null)return;let d=H.get(r).references,h,y;for(let E=0;E<d.length;E++){for(h=d[E].identifier,y=h.parent;y!=null&&y!==S.block;){if(y.type==="CallExpression"){let x=s.get(y.callee);if(x!=null){if(x.name===r)n={missingDep:r,setter:y.callee.name,form:"updater"};else if(a.has(h))n={missingDep:r,setter:y.callee.name,form:"reducer"};else{let j=d[E].resolved;if(j!=null){let W=j.defs[0];W!=null&&W.type==="Parameter"&&(n={missingDep:r,setter:y.callee.name,form:"inlineReducer"})}}break}}y=y.parent}if(n!==null)break}}),n!==null)switch(n.form){case"reducer":_=` You can also replace multiple useState variables with useReducer if '${n.setter}' needs the current value of '${n.missingDep}'.`;break;case"inlineReducer":_=` If '${n.setter}' needs the current value of '${n.missingDep}', you can also switch to useReducer instead of useState and read '${n.missingDep}' in the reducer.`;break;case"updater":_=` You can also do a functional update '${n.setter}(${n.missingDep.slice(0,1)} => ...)' if you only need '${n.missingDep}' in the '${n.setter}' call.`;break;default:throw new Error("Unknown case.")}}f({node:$,message:`React Hook ${t(w)} has `+(te(N,"a","missing","include")||te(q,"an","unnecessary","exclude")||te(ye,"a","duplicate","omit"))+_,suggest:[{desc:`Update the dependencies array to be: [${K.map(ee).join(", ")}]`,fix(n){return n.replaceText($,`[${K.map(ee).join(", ")}]`)}}]})}function v(g){let $=tt(g.callee,u);if($===-1)return;let w=g.arguments[$],k=g.callee,l=Te(k).name,R=g.arguments[$+1],C=/Effect($|[^a-z])/g.test(l);if(!w){f({node:k,message:`React Hook ${l} requires an effect callback. Did you forget to pass a callback to the hook?`});return}if(!R&&!C){(l==="useMemo"||l==="useCallback")&&f({node:k,message:`React Hook ${l} does nothing when called with only one argument. Did you forget to pass an array of dependencies?`});return}switch(w.type){case"FunctionExpression":case"ArrowFunctionExpression":F(w,R,k,l,C);return;case"Identifier":if(!R||R.elements&&R.elements.some(T=>T&&T.type==="Identifier"&&T.name===w.name))return;let S=i(g).set.get(w.name);if(S==null||S.defs==null)return;let D=S.defs[0];if(!D||!D.node||D.type!=="Variable"&&D.type!=="FunctionName")break;switch(D.node.type){case"FunctionDeclaration":F(D.node,R,k,l,C);return;case"VariableDeclarator":let T=D.node.init;if(!T)break;switch(T.type){case"ArrowFunctionExpression":case"FunctionExpression":F(T,R,k,l,C);return}break}break;default:f({node:k,message:`React Hook ${l} received a function whose dependencies are unknown. Pass an inline function instead.`});return}f({node:k,message:`React Hook ${l} has a missing dependency: '${w.name}'. Either include it or remove the dependency array.`,suggest:[{desc:`Update the dependencies array to be: [${w.name}]`,fix(S){return S.replaceText(R,`[${w.name}]`)}}]})}return{CallExpression:v}}};function ne({dependencies:e,declaredDependencies:t,stableDependencies:i,externalDependencies:c,isEffect:o}){let u=f();function f(){return{isUsed:!1,isSatisfiedRecursively:!1,isSubtreeUsed:!1,children:new Map}}e.forEach((v,g)=>{let $=m(u,g);$.isUsed=!0,s(u,g,w=>{w.isSubtreeUsed=!0})}),t.forEach(({key:v})=>{let g=m(u,v);g.isSatisfiedRecursively=!0}),i.forEach(v=>{let g=m(u,v);g.isSatisfiedRecursively=!0});function m(v,g){let $=g.split("."),w=v;for(let k of $){let l=w.children.get(k);l||(l=f(),w.children.set(k,l)),w=l}return w}function s(v,g,$){let w=g.split("."),k=v;for(let l of w){let R=k.children.get(l);if(!R)return;$(R),k=R}}let a=new Set,b=new Set;I(u,a,b,v=>v);function I(v,g,$,w){v.children.forEach((k,l)=>{let R=w(l);if(k.isSatisfiedRecursively){k.isSubtreeUsed&&$.add(R);return}if(k.isUsed){g.add(R);return}I(k,g,$,C=>R+"."+C)})}let M=[],O=new Set,F=new Set;return t.forEach(({key:v})=>{b.has(v)?M.indexOf(v)===-1?M.push(v):F.add(v):O.add(v)}),a.forEach(v=>{M.push(v)}),{suggestedDependencies:M,unnecessaryDependencies:O,duplicateDependencies:F,missingDependencies:a}}function V(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 V(e.consequent)!=null||V(e.alternate)!=null?"conditional":null;case"LogicalExpression":return V(e.left)!=null||V(e.right)!=null?"logical expression":null;case"JSXFragment":return"JSX fragment";case"JSXElement":return"JSX element";case"AssignmentExpression":return V(e.right)!=null?"assignment expression":null;case"NewExpression":return"object construction";case"Literal":return e.value instanceof RegExp?"regular expression":null;case"TypeCastExpression":return V(e.expression);case"TSAsExpression":return V(e.expression)}return null}function et({declaredDependencies:e,declaredDependenciesNode:t,componentScope:i,scope:c}){let o=e.map(({key:f})=>{let m=i.variables.find(a=>a.name===f);if(m==null)return null;let s=m.defs[0];if(s==null)return null;if(s.type==="Variable"&&s.node.type==="VariableDeclarator"&&s.node.id.type==="Identifier"&&s.node.init!=null){let a=V(s.node.init);if(a!=null)return[m,a]}return s.type==="FunctionName"&&s.node.type==="FunctionDeclaration"?[m,"function"]:s.type==="ClassName"&&s.node.type==="ClassDeclaration"?[m,"class"]:null}).filter(Boolean);function u(f){let m=!1;for(let s=0;s<f.references.length;s++){let a=f.references[s];if(a.writeExpr){if(m)return!0;m=!0;continue}let b=a.from;for(;b!==c&&b!=null;)b=b.upper;if(b!==c&&!xe(t,a.identifier))return!0}return!1}return o.map(([f,m])=>({construction:f.defs[0],depType:m,isUsedOutsideOfHook:u(f)}))}function Se(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)?Se(e.parent):e.type==="MemberExpression"&&e.parent&&e.parent.type==="AssignmentExpression"&&e.parent.left===e?e.object:e}function re(e,t,i){t&&(e.optional?t.has(i)||t.set(i,!0):t.has(i)||t.set(i,!1))}function U(e,t){if(e.type==="Identifier"||e.type==="JSXIdentifier"){let i=e.name;return t&&t.set(i,!1),i}else if(e.type==="MemberExpression"&&!e.computed){let i=U(e.object,t),c=U(e.property,null),o=`${i}.${c}`;return re(e,t,o),o}else if(e.type==="OptionalMemberExpression"&&!e.computed){let i=U(e.object,t),c=U(e.property,null),o=`${i}.${c}`;return re(e,t,o),o}else if(e.type==="ChainExpression"&&!e.computed){let i=e.expression;if(i.type==="CallExpression")throw new Error(`Unsupported node type: ${i.type}`);let c=U(i.object,t),o=U(i.property,null),u=`${c}.${o}`;return re(i,t,u),u}else throw new Error(`Unsupported node type: ${e.type}`)}function Te(e,t){return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.object.name==="React"&&e.property.type==="Identifier"&&!e.computed?e.property:e}function tt(e,t){let i=Te(e);if(i.type!=="Identifier")return-1;switch(i.name){case"useEffect":case"useLayoutEffect":case"useCallback":case"useMemo":return 0;case"useImperativeHandle":return 1;default:if(i===e&&t&&t.additionalHooks){let c;try{c=U(i,null)}catch(o){if(/Unsupported node type/.test(o.message))return 0;throw o}return t.additionalHooks.test(c)?0:-1}else return-1}}function ie(e,t){let i=[e],c=null;for(;i.length;){if(c=i.shift(),rt(c,t))return c;if(xe(c,t))for(let[o,u]of Object.entries(c))o!=="parent"&&(be(u)?(u.parent=c,i.push(u)):Array.isArray(u)&&u.forEach(f=>{be(f)&&(f.parent=c,i.push(f))}))}return null}function nt(e){let t="";for(let i=0;i<e.length;i++)t+=e[i],i===0&&e.length===2?t+=" and ":i===e.length-2&&e.length>2?t+=", and ":i<e.length-1&&(t+=", ");return t}function be(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function rt(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 xe(e,t){return e.range[0]<=t.range[0]&&e.range[1]>=t.range[1]}function it(e){return!1}import{AST_NODE_TYPES as J,ESLintUtils as st}from"@typescript-eslint/utils";var ot=st.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),we="no-call-with-inferred-generics",at=ot({name:we,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){let t=e.options[0],i=new Map(t.functions.map(c=>[c.name,c]));return{CallExpression(c){let{callee:o}=c;if(o.type!==J.Identifier)return;let u=i.get(o.name);if(!u)return;let{minGenerics:f=1,allowAny:m,disallowTypes:s=t.disallowTypes}=u;(c.typeArguments?.params.length||0)<(f||0)&&e.report({node:c,messageId:"missingGenericDeclaration",data:{functionName:o.name,minGenerics:f||0}}),!(m&&!s)&&c.typeArguments?.params?.some(b=>!m&&b.type===J.TSAnyKeyword||s&&b.type===J.TSTypeReference&&b.typeName.type===J.Identifier&&s.includes(b.typeName.name))&&e.report({node:c,messageId:"anyUsedInGenerics",data:{functionName:o.name}})}}}}),se={name:we,rule:at};import{ESLintUtils as ct,TSESTree as Re}from"@typescript-eslint/utils";var lt=ct.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),ke="no-commented-out-code",ut=["function ","class ","interface ","type ","enum ","namespace ","import ","export ","const ","let ","var ","return "],ft=[") {","return;","if (","else {","for (","switch (","/>","</","},",": {"," } = ","={",/\w=("|')/,");"],pt=lt({name:ke,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:function(e){function t(i){if(i.startsWith("/"))return!1;let c=i.trimStart();if(i.startsWith("*")||c.startsWith("INFO:")||c.startsWith("TODO:")||c.startsWith("DOCS:")||c.startsWith("FIX:")||c.startsWith("eslint-disable")||i.includes("@deprecated")||i.includes("@example"))return!1;for(let o of ut)if(c.startsWith(o))return{wrongPattern:o};for(let o of ft)if(typeof o=="string"){if(i.includes(o))return{wrongPattern:o}}else if(o.test(i))return{wrongPattern:`regex(${o.toString()})`};return!1}return{Program(){let c=e.sourceCode.getAllComments();for(let o of c)if(o.type===Re.AST_TOKEN_TYPES.Line||o.type===Re.AST_TOKEN_TYPES.Block){let u=t(o.value);u&&e.report({node:o,messageId:"commentedOutCode",data:{wrongPattern:u.wrongPattern}})}}}}}),oe={name:ke,rule:pt};import{ESLintUtils as dt}from"@typescript-eslint/utils";var mt=dt.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ie="no-default-export",yt=mt({name:Ie,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 i of t.specifiers)i.exported.name==="default"&&e.report({node:t,messageId:"noDefaultExport"})}}}}),ae={name:Ie,rule:yt};import{AST_NODE_TYPES as z,ESLintUtils as gt}from"@typescript-eslint/utils";var ht=gt.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ae="no-non-camel-case-functions",bt=/^[a-z][a-zA-Z0-9]*$/;function Ce(e){return e.typeName.type===z.TSQualifiedName&&e.typeName.left.type===z.Identifier&&e.typeName.left.name==="JSX"&&e.typeName.right.type===z.Identifier&&e.typeName.right.name==="Element"}var Et=ht({name:Ae,meta:{type:"suggestion",docs:{description:"Enforce camelCase naming convention for function declarations"},schema:[],messages:{nonCamelCaseFunction:'Function name "{{functionName}}" should be in camelCase format'}},defaultOptions:[],create(e){return{FunctionDeclaration(t){if(t.id&&!bt.test(t.id.name)){let i=t.returnType?.typeAnnotation;if(i&&(i.type===z.TSTypeReference?Ce(i):i.type===z.TSUnionType&&i.types.some(o=>o.type===z.TSTypeReference&&Ce(o))))return;e.report({node:t.id,messageId:"nonCamelCaseFunction",data:{functionName:t.id.name}})}}}}}),ce={name:Ae,rule:Et};import{AST_NODE_TYPES as A,ESLintUtils as St}from"@typescript-eslint/utils";var Tt=St.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function ve(e){let t=[];for(let i of e.members)i.type===A.TSPropertySignature&&i.key.type===A.Identifier&&t.push([i.key.name,i]);return t}function $e(e,...t){for(let i of t)e.set(...i);return e}var De="no-unused-type-props-in-args",xt=Tt({name:De,meta:{type:"problem",docs:{description:"Disallow unused undestructured object type properties"},messages:{unusedObjectTypeProperty:"Object type property '{{ propertyName }}' is defined but never used"},schema:[],fixable:"code"},defaultOptions:[],create:function(e){function t(u,f,m,s=!0){let a=f.name,b=e.sourceCode.getScope(u).references.find(M=>M.identifier.name===a)?.resolved;if(!b||b.references.filter(M=>M.isTypeReference).length>1)return;let I=b?.defs[0]?.node;if(!(s&&I?.parent?.type===A.ExportNamedDeclaration)){if(I?.type===A.TSTypeAliasDeclaration){i(u,m,I.typeAnnotation,!0);return}if(I?.type===A.TSInterfaceDeclaration){i(u,m,I.body,!0);return}}}function i(u,f,m,s){if(m.type===A.TSInterfaceBody){for(let a of m.body)a.type===A.TSPropertySignature&&a.key.type===A.Identifier&&f.set(a.key.name,a);return}if(m.type===A.TSTypeLiteral){$e(f,...ve(m));return}if(m.type===A.TSIntersectionType){for(let a of m.types)i(u,f,a,!0);return}s||m.type===A.TSTypeReference&&m.typeName.type===A.Identifier&&t(u,m.typeName,f)}function c(u,f){for(let m of f)if(m.type==="ObjectPattern"&&m.typeAnnotation){let s=new Map;if(i(u,s,m.typeAnnotation.typeAnnotation,!1),s.size===0)continue;o(m,s)}else m.type===A.AssignmentPattern&&m.left.type===A.ObjectPattern&&c(u,[m.left])}function o(u,f){let m=[];if(u.properties.at(-1)?.type===A.RestElement)return;for(let I of u.properties)I.type===A.Property&&I.key.type===A.Identifier&&m.push(I.key.name);let a=[],b=[];for(let[I,M]of f)m.includes(I)||(b.push(I),a.push({node:M,messageId:"unusedObjectTypeProperty",data:{propertyName:I}}));for(let[I,M]of a.entries())e.report({...M,fix:I===a.length-1?O=>{let F=u.properties.at(-1),v=b.join(", ");return F?F?.type===A.RestElement?null:O.insertTextAfter(F,`, ${v}`):O.insertTextBeforeRange([u.range[0]+1,u.range[1]],`${v}`)}:void 0})}return{VariableDeclaration:function(u){let f=u.declarations[0];if(!f)return;let m=new Map,s=f.id.type===A.Identifier&&f.id.typeAnnotation?.typeAnnotation.type===A.TSTypeReference&&f.id.typeAnnotation.typeAnnotation.typeName.type===A.Identifier&&f.id.typeAnnotation.typeAnnotation.typeName.name==="FC"&&f.id.typeAnnotation.typeAnnotation.typeArguments?.params[0];if(s){if(s.type===A.TSTypeReference&&s.typeName.type===A.Identifier)t(u,s.typeName,m,!1);else if(s.type===A.TSTypeLiteral)$e(m,...ve(s));else if(s.type===A.TSIntersectionType)for(let a of s.types)a.type===A.TSTypeReference&&a.typeName.type===A.Identifier?t(u,a.typeName,m,!1):i(u,m,a,!0);if(m.size!==0&&f.init?.type===A.ArrowFunctionExpression){let a=f.init.params[0];a&&a.type===A.ObjectPattern&&o(a,m)}}},FunctionDeclaration:function(u){c(u,u.params)},ArrowFunctionExpression:function(u){c(u,u.params)}}}}),le={name:De,rule:xt};import{ESLintUtils as wt}from"@typescript-eslint/utils";var Rt=wt.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Fe="prefer-named-functions",Me=new Map,kt=Rt({name:Fe,meta:{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:{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}} () {}" or have a name that matches the regex "{{ignoreRegex}}"'}},defaultOptions:[{}],create(e){let t=e.options[0]||{},i=e.getSourceCode(),c=null;if(t.ignoreRegex){let o=Me.get(t.ignoreRegex);o?c=o:(c=new RegExp(t.ignoreRegex),Me.set(t.ignoreRegex,c))}return{VariableDeclarator(o){if(o.init&&o.init.type==="ArrowFunctionExpression"&&o.id.type==="Identifier"){let u=o.id.name;if(o.id.typeAnnotation||c&&c.test(u)||!t.disallowArrowFnWithImplicitReturns&&o.init.body.type!=="BlockStatement")return;e.report({node:o.id,messageId:c?"withIgnoreRegex":"default",data:{functionName:u,ignoreRegex:t.ignoreRegex}})}}}}}),ue={name:Fe,rule:kt};import{ESLintUtils as It}from"@typescript-eslint/utils";var Ct=It.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Oe="require-description",At=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,vt=/^eslint-disable-(next-)?line$/u,$t=Ct({name:Oe,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){let t=e.sourceCode,i=new Set(e.options[0]&&e.options[0].ignore||[]);return{Program(){for(let c of t.getAllComments()){let o=Dt(c);o!=null&&(i.has(o.kind)||o.description||e.report({loc:Ft(c.loc),messageId:"missingDescription"}))}}}}}),Pe={name:Oe,rule:$t};function Dt(e){let{text:t,description:i}=Mt(e.value);if(!t)return null;let c=At.exec(t);if(!c)return null;let o=c[1];if(!o)return null;let u=vt.test(o);if(e.type==="Line"&&!u||u&&e.loc.start.line!==e.loc.end.line)return null;let f=t.slice(c.index+o.length);return{kind:o,value:f.trim(),description:i}}function Mt(e){let t=e.split(/\s-{2,}\s/u);return{text:t[0]?.trim(),description:t.length>1?t[1]?.trim()??null:null}}function Ft(e){return{start:{line:e.start.line,column:-1},end:e.end}}function Le(e){return/^use[A-Z0-9]/.test(e)}function Y(e){return e.type==="Identifier"?Le(e.name):e.type==="MemberExpression"&&!e.computed&&Y(e.property)?e.object.type==="Identifier":!1}function _e(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function We(e,t){return e.name===t||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===t}function Ue(e){return!!(e.parent&&e.parent.callee&&We(e.parent.callee,"forwardRef"))}function Ne(e){return!!(e.parent&&e.parent.callee&&We(e.parent.callee,"memo"))}function fe(e){for(;e;){let t=ze(e);if(t&&(_e(t)||Y(t))||Ue(e)||Ne(e))return!0;e=e.parent}return!1}function He(e){return!1}function pe(e){return!1}var Ot=/eslint +react-compiler\/react-compiler: +\["error/,Ve={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 s of e.sourceCode.getAllComments())if(Ot.test(s.value))return{CallExpression(a){let b=null;a.callee.name==="useMemo"?b="useMemo":a.callee.name==="useCallback"&&(b="useCallback"),b&&e.report({node:a,message:`"${b}" is not necessary when using React Compiler.`})}}}let t=typeof e.getSource=="function"?s=>t(s):s=>e.sourceCode.getText(s),i=typeof e.getScope=="function"?()=>i():s=>e.sourceCode.getScope(s),c=null,o=[],u=[],f=new WeakSet;function m(s){for(let a of s.references){let b=a.identifier.parent;if(b.type==="VariableDeclarator"&&b.init&&b.init.type==="CallExpression"&&b.init.callee&&He(b.init.callee))for(let I of a.resolved.references)I!==a&&f.add(I.identifier)}}return{onCodePathSegmentStart:s=>u.push(s),onCodePathSegmentEnd:()=>u.pop(),onCodePathStart:()=>o.push(new Map),onCodePathEnd(s,a){let b=o.pop();if(b.size===0)return;let I=new Set;function M(l,R){let{cache:C}=M,S=C.get(l.id),D=new Set(R);if(D.has(l.id)){let T=[...D],P=T.slice(T.indexOf(l.id)+1);for(let L of P)I.add(L);return BigInt("0")}if(D.add(l.id),S!==void 0)return S;if(s.thrownSegments.includes(l))S=BigInt("0");else if(l.prevSegments.length===0)S=BigInt("1");else{S=BigInt("0");for(let T of l.prevSegments)S+=M(T,D)}return l.reachable&&S===BigInt("0")?C.delete(l.id):C.set(l.id,S),S}function O(l,R){let{cache:C}=O,S=C.get(l.id),D=new Set(R);if(D.has(l.id)){let T=Array.from(D),P=T.slice(T.indexOf(l.id)+1);for(let L of P)I.add(L);return BigInt("0")}if(D.add(l.id),S!==void 0)return S;if(s.thrownSegments.includes(l))S=BigInt("0");else if(l.nextSegments.length===0)S=BigInt("1");else{S=BigInt("0");for(let T of l.nextSegments)S+=O(T,D)}return C.set(l.id,S),S}function F(l){let{cache:R}=F,C=R.get(l.id);if(C===null)return 1/0;if(C!==void 0)return C;if(R.set(l.id,null),l.prevSegments.length===0)C=1;else{C=1/0;for(let S of l.prevSegments){let D=F(S);D<C&&(C=D)}C+=1}return R.set(l.id,C),C}M.cache=new Map,O.cache=new Map,F.cache=new Map;let v=O(s.initialSegment),g=ze(a),$=fe(a),w=g?_e(g)||Y(g):Ue(a)||Ne(a),k=1/0;for(let l of s.finalSegments){if(!l.reachable)continue;let R=F(l);R<k&&(k=R)}for(let[l,R]of b){if(!l.reachable)continue;let C=l.nextSegments.length===0?k<=F(l):k<F(l),S=M(l)*O(l),D=I.has(l.id);for(let T of R)if(D&&!pe(T)&&e.report({node:T,message:`React Hook "${t(T)}" 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.`}),w){if(a.async&&e.report({node:T,message:`React Hook "${t(T)}" cannot be called in an async function.`}),!D&&S!==v&&!pe(T)){let L=`React Hook "${t(T)}" is called conditionally. React Hooks must be called in the exact same order in every component render.`+(C?" Did you accidentally call a React Hook after an early return?":"");e.report({node:T,message:L})}}else if(a.parent&&(a.parent.type==="MethodDefinition"||a.parent.type==="ClassProperty")&&a.parent.value===a){let P=`React Hook "${t(T)}" 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:T,message:P})}else if(g){let P=`React Hook "${t(T)}" is called in function "${t(g)}" 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:T,message:P})}else if(a.type==="Program"){let P=`React Hook "${t(T)}" 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:T,message:P})}else if($&&!pe(T)){if(a.parent.type==="CallExpression"&&a.parent.callee.type==="Identifier"&&a.parent.callee.name==="useCallback"){let L=a.parent;if(L.parent.type==="VariableDeclarator"&&Le(L.parent.id.name))return}let P=`React Hook "${t(T)}" 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:T,message:P})}}},CallExpression(s){if(Y(s.callee)){let a=je(o),b=je(u),I=a.get(b);I||(I=[],a.set(b,I)),I.push(s.callee)}s.callee.type==="Identifier"&&(s.callee.name==="useEffect"||He(s.callee))&&s.arguments.length>0&&(c=s)},Identifier(s){c==null&&f.has(s)&&s.parent.type!=="CallExpression"&&e.report({node:s,message:`\`${t(s)}\` 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"(s){s===c&&(c=null)},FunctionDeclaration(s){fe(s)&&m(i(s))},ArrowFunctionExpression(s){fe(s)&&m(i(s))}}}};function ze(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 je(e){return e[e.length-1]}var Be={[le.name]:le.rule,[oe.name]:oe.rule,[se.name]:se.rule,"rules-of-hooks":Ve,"exhaustive-deps":Ee,"require-description":Pe.rule,[ae.name]:ae.rule,[ce.name]:ce.rule,[ue.name]:ue.rule};var mn={rules:Be};export{mn as extendedLintPlugin};
12
+ Learn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching`});let R=d.acquire(g),C=new Set,S=null;{let n=R.upper;for(;n&&(C.add(n),n.type!=="function");)n=n.upper;if(!n)return;S=n}let D=Array.isArray;function x(n){if(!D(n.defs))return!1;let s=n.defs[0];if(s==null||s.node.type!=="VariableDeclarator")return!1;let f=s.node.init;if(f==null)return!1;for(;f.type==="TSAsExpression";)f=f.expression;let m=s.node.parent;if(m==null&&(ie(S.block,s.node.id),m=s.node.parent,m==null))return!1;if(m.kind==="const"&&f.type==="Literal"&&(typeof f.value=="string"||typeof f.value=="number"||f.value===null))return!0;if(f.type!=="CallExpression")return!1;let h=f.callee;if(h.type==="MemberExpression"&&h.object.name==="React"&&h.property!=null&&!h.computed&&(h=h.property),h.type!=="Identifier")return!1;let y=s.node.id,{name:E}=h;if(E==="useRef"&&y.type==="Identifier")return!0;if(lt(h)&&y.type==="Identifier"){for(let T of n.references)T!==y&&F.add(T.identifier);return!0}else if(E==="useState"||E==="useReducer"){if(y.type==="ArrayPattern"&&y.elements.length===2&&D(n.identifiers)){if(y.elements[1]===n.identifiers[0]){if(E==="useState"){let T=n.references,H=0;for(let W=0;W<T.length;W++){if(T[W].isWrite()&&H++,H>1)return!1;i.set(T[W].identifier,y.elements[0])}}return!0}else if(y.elements[0]===n.identifiers[0]){if(E==="useState"){let T=n.references;for(let H=0;H<T.length;H++)c.add(T[H].identifier)}return!1}}}else if(E==="useTransition"&&y.type==="ArrayPattern"&&y.elements.length===2&&Array.isArray(n.identifiers)&&y.elements[1]===n.identifiers[0])return!0;return!1}function P(n){if(!D(n.defs))return!1;let s=n.defs[0];if(s==null||s.node==null||s.node.id==null)return!1;let f=s.node,m=S.childScopes,h=null,y;for(y=0;y<m.length;y++){let E=m[y],T=E.block;if(f.type==="FunctionDeclaration"&&T===f||f.type==="VariableDeclarator"&&T.parent===f){h=E;break}}if(h==null)return!1;for(y=0;y<h.through.length;y++){let E=h.through[y];if(E.resolved!=null&&C.has(E.resolved.scope)&&!L(E.resolved))return!1}return!0}let L=O(x,b),Ge=O(P,I),me=new Map;function Ke(n){let s=n.from,f=!1;for(;s.block!==g;)s.type==="function"&&(f=s.block.parent!=null&&s.block.parent.type==="ReturnStatement"),s=s.upper;return f}let j=new Map,Z=new Map;ye(R);function ye(n){for(let s of n.references){if(!s.resolved||!C.has(s.resolved.scope))continue;let f=ie(g,s.identifier),m=Te(f),h=U(m,Z);if(u&&m.type==="Identifier"&&(m.parent.type==="MemberExpression"||m.parent.type==="OptionalMemberExpression")&&!m.parent.computed&&m.parent.property.type==="Identifier"&&m.parent.property.name==="current"&&Ke(s)&&me.set(h,{reference:s,dependencyNode:m}),m.parent.type==="TSTypeQuery"||m.parent.type==="TSTypeReference")continue;let y=s.resolved.defs[0];if(y!=null&&!(y.node!=null&&y.node.init===g.parent)&&y.type!=="TypeParameter")if(j.has(h))j.get(h).references.push(s);else{let E=s.resolved,T=L(E)||Ge(E);j.set(h,{isStable:T,references:[s]})}}for(let s of n.childScopes)ye(s)}me.forEach(({reference:n,dependencyNode:s},f)=>{let m=n.resolved.references,h=!1;for(let y=0;y<m.length;y++){let{identifier:E}=m[y],{parent:T}=E;if(T!=null&&T.type==="MemberExpression"&&!T.computed&&T.property.type==="Identifier"&&T.property.name==="current"&&T.parent.type==="AssignmentExpression"&&T.parent.left===T){h=!0;break}}h||l({node:s.parent.property,message:`The ref value '${f}.current' will likely have changed by the time this effect cleanup function runs. If this ref points to a node rendered by React, copy '${f}.current' to a variable inside the effect, and use that variable in the cleanup function.`})});let Q=new Set;function Je(n,s){Q.has(s)||(Q.add(s),l({node:n,message:`Assignments to the '${s}' variable from inside React Hook ${t(w)} 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 ${t(w)}.`}))}let q=new Set;if(j.forEach(({isStable:n,references:s},f)=>{n&&q.add(f),s.forEach(m=>{m.writeExpr&&Je(m.writeExpr,f)})}),Q.size>0)return;if(!$){let n=null;if(j.forEach(({isStable:s,references:f},m)=>{n||f.forEach(h=>{if(n)return;let y=h.identifier;if(!i.has(y))return;let T=h.from;for(;T.type!=="function";)T=T.upper;T.block===g&&(n=m)})}),n){let{suggestedDependencies:s}=re({dependencies:j,declaredDependencies:[],stableDependencies:q,externalDependencies:new Set,isEffect:!0});l({node:w,message:`React Hook ${k} contains a call to '${n}'. Without a list of dependencies, this can lead to an infinite chain of updates. To fix this, pass [`+s.join(", ")+`] as a second argument to the ${k} Hook.`,suggest:[{desc:`Add dependencies array: [${s.join(", ")}]`,fix(f){return f.insertTextAfter(g,`, [${s.join(", ")}]`)}}]})}return}let B=[],X=new Set;$.type!=="ArrayExpression"?l({node:$,message:`React Hook ${t(w)} 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(n=>{if(n===null)return;if(n.type==="SpreadElement"){l({node:n,message:`React Hook ${t(w)} has a spread element in its dependency array. This means we can't statically verify whether you've passed the correct dependencies.`});return}F.has(n)&&l({node:n,message:`Functions returned from \`useEffectEvent\` must not be included in the dependency array. Remove \`${t(n)}\` from the list.`,suggest:[{desc:`Remove the dependency \`${t(n)}\``,fix(h){return h.removeRange(n.range)}}]});let s;try{s=U(n,Z)}catch(h){if(/Unsupported node type/.test(h.message)){n.type==="Literal"?j.has(n.value)?l({node:n,message:`The ${n.raw} literal is not a valid dependency because it never changes. Did you mean to include ${n.value} in the array instead?`}):l({node:n,message:`The ${n.raw} literal is not a valid dependency because it never changes. You can safely remove it.`}):l({node:n,message:`React Hook ${t(w)} has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked.`});return}else throw h}let f=n;for(;f.type==="MemberExpression"||f.type==="OptionalMemberExpression"||f.type==="ChainExpression";)f=f.object||f.expression.object;let m=!S.through.some(h=>h.identifier===f);B.push({key:s,node:n}),m||X.add(s)});let{suggestedDependencies:Ye,unnecessaryDependencies:G,missingDependencies:N,duplicateDependencies:ge}=re({dependencies:j,declaredDependencies:B,stableDependencies:q,externalDependencies:X,isEffect:u}),K=Ye;if(ge.size+N.size+G.size===0){it({declaredDependencies:B,declaredDependenciesNode:$,componentScope:S,scope:R}).forEach(({construction:s,isUsedOutsideOfHook:f,depType:m})=>{let h=m==="function"?"useCallback":"useMemo",y=m==="function"?"definition":"initialization",E=`wrap the ${y} of '${s.name.name}' in its own ${h}() Hook.`,T=f?`To fix this, ${E}`:`Move it inside the ${k} callback. Alternatively, ${E}`,H=m==="conditional"||m==="logical expression"?"could make":"makes",W=`The '${s.name.name}' ${m} ${H} the dependencies of ${k} Hook (at line ${$.loc.start.line}) change on every render. ${T}`,he;f&&s.type==="Variable"&&m==="function"&&(he=[{desc:`Wrap the ${y} of '${s.name.name}' in its own ${h}() Hook.`,fix(be){let[Qe,et]=h==="useMemo"?["useMemo(() => { return ","; })"]:["useCallback(",")"];return[be.insertTextBefore(s.node.init,Qe),be.insertTextAfter(s.node.init,et)]}}]),l({node:s.node,message:W,suggest:he})});return}!u&&N.size>0&&(K=re({dependencies:j,declaredDependencies:[],stableDependencies:q,externalDependencies:X,isEffect:u}).suggestedDependencies);function Ze(){if(B.length===0)return!0;let n=B.map(f=>f.key),s=n.slice().sort();return n.join(",")===s.join(",")}Ze()&&K.sort();function ee(n){let s=n.split("."),f="";for(let m=0;m<s.length;m++){if(m!==0){let h=s.slice(0,m+1).join("."),y=Z.get(h)===!0;f+=y?"?.":"."}f+=s[m]}return f}function te(n,s,f,m){return n.size===0?null:(n.size>1?"":s+" ")+f+" "+(n.size>1?"dependencies":"dependency")+": "+at(Array.from(n).sort().map(h=>"'"+ee(h)+"'"))+`. Either ${m} ${n.size>1?"them":"it"} or remove the dependency array.`}let _="";if(G.size>0){let n=null;if(Array.from(G.keys()).forEach(s=>{n===null&&s.endsWith(".current")&&(n=s)}),n!==null)_=` Mutable values like '${n}' aren't valid dependencies because mutating them doesn't re-render the component.`;else if(X.size>0){let s=Array.from(X)[0];R.set.has(s)||(_=` Outer scope values like '${s}' aren't valid dependencies because mutating them doesn't re-render the component.`)}}if(!_&&N.has("props")){let n=j.get("props");if(n==null)return;let s=n.references;if(!Array.isArray(s))return;let f=!0;for(let m=0;m<s.length;m++){let h=s[m],y=ie(S.block,h.identifier);if(!y){f=!1;break}let E=y.parent;if(E==null){f=!1;break}if(E.type!=="MemberExpression"&&E.type!=="OptionalMemberExpression"){f=!1;break}}f&&(_=` However, 'props' will change when *any* prop changes, so the preferred fix is to destructure the 'props' object outside of the ${k} call and refer to those specific props inside ${t(w)}.`)}if(!_&&N.size>0){let n=null;N.forEach(s=>{if(n)return;let f=S.set.get(s),m=j.get(s);if(m.references[0].resolved!==f)return;let h=f.defs[0];if(h==null||h.name==null||h.type!=="Parameter")return;let y=!1,E;for(let T=0;T<m.references.length;T++)if(E=m.references[T].identifier,E!=null&&E.parent!=null&&(E.parent.type==="CallExpression"||E.parent.type==="OptionalCallExpression")&&E.parent.callee===E){y=!0;break}y&&(n=s)}),n!==null&&(_=` If '${n}' changes too often, find the parent component that defines it and wrap that definition in useCallback.`)}if(!_&&N.size>0){let n=null;if(N.forEach(s=>{if(n!==null)return;let m=j.get(s).references,h,y;for(let E=0;E<m.length;E++){for(h=m[E].identifier,y=h.parent;y!=null&&y!==S.block;){if(y.type==="CallExpression"){let T=i.get(y.callee);if(T!=null){if(T.name===s)n={missingDep:s,setter:y.callee.name,form:"updater"};else if(c.has(h))n={missingDep:s,setter:y.callee.name,form:"reducer"};else{let H=m[E].resolved;if(H!=null){let W=H.defs[0];W!=null&&W.type==="Parameter"&&(n={missingDep:s,setter:y.callee.name,form:"inlineReducer"})}}break}}y=y.parent}if(n!==null)break}}),n!==null)switch(n.form){case"reducer":_=` You can also replace multiple useState variables with useReducer if '${n.setter}' needs the current value of '${n.missingDep}'.`;break;case"inlineReducer":_=` If '${n.setter}' needs the current value of '${n.missingDep}', you can also switch to useReducer instead of useState and read '${n.missingDep}' in the reducer.`;break;case"updater":_=` You can also do a functional update '${n.setter}(${n.missingDep.slice(0,1)} => ...)' if you only need '${n.missingDep}' in the '${n.setter}' call.`;break;default:throw new Error("Unknown case.")}}l({node:$,message:`React Hook ${t(w)} has `+(te(N,"a","missing","include")||te(G,"an","unnecessary","exclude")||te(ge,"a","duplicate","omit"))+_,suggest:[{desc:`Update the dependencies array to be: [${K.map(ee).join(", ")}]`,fix(n){return n.replaceText($,`[${K.map(ee).join(", ")}]`)}}]})}function v(g){let $=ot(g.callee,p);if($===-1)return;let w=g.arguments[$],k=g.callee,u=we(k).name,R=g.arguments[$+1],C=/Effect($|[^a-z])/g.test(u);if(!w){l({node:k,message:`React Hook ${u} requires an effect callback. Did you forget to pass a callback to the hook?`});return}if(!R&&!C){(u==="useMemo"||u==="useCallback")&&l({node:k,message:`React Hook ${u} does nothing when called with only one argument. Did you forget to pass an array of dependencies?`});return}switch(w.type){case"FunctionExpression":case"ArrowFunctionExpression":M(w,R,k,u,C);return;case"Identifier":if(!R||R.elements&&R.elements.some(x=>x&&x.type==="Identifier"&&x.name===w.name))return;let S=r(g).set.get(w.name);if(S==null||S.defs==null)return;let D=S.defs[0];if(!D||!D.node||D.type!=="Variable"&&D.type!=="FunctionName")break;switch(D.node.type){case"FunctionDeclaration":M(D.node,R,k,u,C);return;case"VariableDeclarator":let x=D.node.init;if(!x)break;switch(x.type){case"ArrowFunctionExpression":case"FunctionExpression":M(x,R,k,u,C);return}break}break;default:l({node:k,message:`React Hook ${u} received a function whose dependencies are unknown. Pass an inline function instead.`});return}l({node:k,message:`React Hook ${u} has a missing dependency: '${w.name}'. Either include it or remove the dependency array.`,suggest:[{desc:`Update the dependencies array to be: [${w.name}]`,fix(S){return S.replaceText(R,`[${w.name}]`)}}]})}return{CallExpression:v}}};function re({dependencies:e,declaredDependencies:t,stableDependencies:r,externalDependencies:o,isEffect:a}){let p=l();function l(){return{isUsed:!1,isSatisfiedRecursively:!1,isSubtreeUsed:!1,children:new Map}}e.forEach((v,g)=>{let $=d(p,g);$.isUsed=!0,i(p,g,w=>{w.isSubtreeUsed=!0})}),t.forEach(({key:v})=>{let g=d(p,v);g.isSatisfiedRecursively=!0}),r.forEach(v=>{let g=d(p,v);g.isSatisfiedRecursively=!0});function d(v,g){let $=g.split("."),w=v;for(let k of $){let u=w.children.get(k);u||(u=l(),w.children.set(k,u)),w=u}return w}function i(v,g,$){let w=g.split("."),k=v;for(let u of w){let R=k.children.get(u);if(!R)return;$(R),k=R}}let c=new Set,b=new Set;I(p,c,b,v=>v);function I(v,g,$,w){v.children.forEach((k,u)=>{let R=w(u);if(k.isSatisfiedRecursively){k.isSubtreeUsed&&$.add(R);return}if(k.isUsed){g.add(R);return}I(k,g,$,C=>R+"."+C)})}let F=[],O=new Set,M=new Set;return t.forEach(({key:v})=>{b.has(v)?F.indexOf(v)===-1?F.push(v):M.add(v):O.add(v)}),c.forEach(v=>{F.push(v)}),{suggestedDependencies:F,unnecessaryDependencies:O,duplicateDependencies:M,missingDependencies:c}}function V(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 V(e.consequent)!=null||V(e.alternate)!=null?"conditional":null;case"LogicalExpression":return V(e.left)!=null||V(e.right)!=null?"logical expression":null;case"JSXFragment":return"JSX fragment";case"JSXElement":return"JSX element";case"AssignmentExpression":return V(e.right)!=null?"assignment expression":null;case"NewExpression":return"object construction";case"Literal":return e.value instanceof RegExp?"regular expression":null;case"TypeCastExpression":return V(e.expression);case"TSAsExpression":return V(e.expression)}return null}function it({declaredDependencies:e,declaredDependenciesNode:t,componentScope:r,scope:o}){let a=e.map(({key:l})=>{let d=r.variables.find(c=>c.name===l);if(d==null)return null;let i=d.defs[0];if(i==null)return null;if(i.type==="Variable"&&i.node.type==="VariableDeclarator"&&i.node.id.type==="Identifier"&&i.node.init!=null){let c=V(i.node.init);if(c!=null)return[d,c]}return i.type==="FunctionName"&&i.node.type==="FunctionDeclaration"?[d,"function"]:i.type==="ClassName"&&i.node.type==="ClassDeclaration"?[d,"class"]:null}).filter(Boolean);function p(l){let d=!1;for(let i=0;i<l.references.length;i++){let c=l.references[i];if(c.writeExpr){if(d)return!0;d=!0;continue}let b=c.from;for(;b!==o&&b!=null;)b=b.upper;if(b!==o&&!Re(t,c.identifier))return!0}return!1}return a.map(([l,d])=>({construction:l.defs[0],depType:d,isUsedOutsideOfHook:p(l)}))}function Te(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)?Te(e.parent):e.type==="MemberExpression"&&e.parent&&e.parent.type==="AssignmentExpression"&&e.parent.left===e?e.object:e}function se(e,t,r){t&&(e.optional?t.has(r)||t.set(r,!0):t.has(r)||t.set(r,!1))}function U(e,t){if(e.type==="Identifier"||e.type==="JSXIdentifier"){let r=e.name;return t&&t.set(r,!1),r}else if(e.type==="MemberExpression"&&!e.computed){let r=U(e.object,t),o=U(e.property,null),a=`${r}.${o}`;return se(e,t,a),a}else if(e.type==="OptionalMemberExpression"&&!e.computed){let r=U(e.object,t),o=U(e.property,null),a=`${r}.${o}`;return se(e,t,a),a}else if(e.type==="ChainExpression"&&!e.computed){let r=e.expression;if(r.type==="CallExpression")throw new Error(`Unsupported node type: ${r.type}`);let o=U(r.object,t),a=U(r.property,null),p=`${o}.${a}`;return se(r,t,p),p}else throw new Error(`Unsupported node type: ${e.type}`)}function we(e,t){return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.object.name==="React"&&e.property.type==="Identifier"&&!e.computed?e.property:e}function ot(e,t){let r=we(e);if(r.type!=="Identifier")return-1;switch(r.name){case"useEffect":case"useLayoutEffect":case"useCallback":case"useMemo":return 0;case"useImperativeHandle":return 1;default:if(r===e&&t&&t.additionalHooks){let o;try{o=U(r,null)}catch(a){if(/Unsupported node type/.test(a.message))return 0;throw a}return t.additionalHooks.test(o)?0:-1}else return-1}}function ie(e,t){let r=[e],o=null;for(;r.length;){if(o=r.shift(),ct(o,t))return o;if(Re(o,t))for(let[a,p]of Object.entries(o))a!=="parent"&&(Se(p)?(p.parent=o,r.push(p)):Array.isArray(p)&&p.forEach(l=>{Se(l)&&(l.parent=o,r.push(l))}))}return null}function at(e){let t="";for(let r=0;r<e.length;r++)t+=e[r],r===0&&e.length===2?t+=" and ":r===e.length-2&&e.length>2?t+=", and ":r<e.length-1&&(t+=", ");return t}function Se(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}function ct(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 Re(e,t){return e.range[0]<=t.range[0]&&e.range[1]>=t.range[1]}function lt(e){return!1}import{AST_NODE_TYPES as J,ESLintUtils as ut}from"@typescript-eslint/utils";var pt=ut.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),ke="no-call-with-inferred-generics",ft=pt({name:ke,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){let t=e.options[0],r=new Map(t.functions.map(o=>[o.name,o]));return{CallExpression(o){let{callee:a}=o;if(a.type!==J.Identifier)return;let p=r.get(a.name);if(!p)return;let{minGenerics:l=1,allowAny:d,disallowTypes:i=t.disallowTypes}=p;(o.typeArguments?.params.length||0)<(l||0)&&e.report({node:o,messageId:"missingGenericDeclaration",data:{functionName:a.name,minGenerics:l||0}}),!(d&&!i)&&o.typeArguments?.params?.some(b=>!d&&b.type===J.TSAnyKeyword||i&&b.type===J.TSTypeReference&&b.typeName.type===J.Identifier&&i.includes(b.typeName.name))&&e.report({node:o,messageId:"anyUsedInGenerics",data:{functionName:a.name}})}}}}),oe={name:ke,rule:ft};import{ESLintUtils as dt,TSESTree as Ie}from"@typescript-eslint/utils";var mt=dt.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ce="no-commented-out-code",yt=["function ","class ","interface ","type ","enum ","namespace ","import ","export ","const ","let ","var ","return "],gt=[") {","return;","if (","else {","for (","switch (","/>","</","},",": {"," } = ","={",/\w=("|')/,");"],ht=mt({name:Ce,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:function(e){function t(r){if(r.startsWith("/"))return!1;let o=r.trimStart();if(r.startsWith("*")||o.startsWith("INFO:")||o.startsWith("TODO:")||o.startsWith("DOCS:")||o.startsWith("FIX:")||o.startsWith("eslint-disable")||r.includes("@deprecated")||r.includes("@example"))return!1;for(let a of yt)if(o.startsWith(a))return{wrongPattern:a};for(let a of gt)if(typeof a=="string"){if(r.includes(a))return{wrongPattern:a}}else if(a.test(r))return{wrongPattern:`regex(${a.toString()})`};return!1}return{Program(){let o=e.sourceCode.getAllComments();for(let a of o)if(a.type===Ie.AST_TOKEN_TYPES.Line||a.type===Ie.AST_TOKEN_TYPES.Block){let p=t(a.value);p&&e.report({node:a,messageId:"commentedOutCode",data:{wrongPattern:p.wrongPattern}})}}}}}),ae={name:Ce,rule:ht};import{ESLintUtils as bt}from"@typescript-eslint/utils";var Et=bt.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ae="no-default-export",St=Et({name:Ae,meta:{type:"problem",docs:{description:"Disallow default exports"},schema:[],messages:{noDefaultExport:"Default exports are not allowed, use named exports instead."}},defaultOptions:[],create(e){return{ExportDefaultDeclaration(t){e.report({node:t,messageId:"noDefaultExport"})},ExportNamedDeclaration(t){for(let r of t.specifiers)r.exported.name==="default"&&e.report({node:t,messageId:"noDefaultExport"})}}}}),ce={name:Ae,rule:St};import{AST_NODE_TYPES as z,ESLintUtils as xt}from"@typescript-eslint/utils";var Tt=xt.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),$e="no-non-camel-case-functions",wt=/^[a-z][a-zA-Z0-9]*$/;function ve(e){return e.typeName.type===z.TSQualifiedName&&e.typeName.left.type===z.Identifier&&e.typeName.left.name==="JSX"&&e.typeName.right.type===z.Identifier&&e.typeName.right.name==="Element"}var Rt=Tt({name:$e,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&&!wt.test(t.id.name)){let r=t.returnType?.typeAnnotation;if(r&&(r.type===z.TSTypeReference?ve(r):r.type===z.TSUnionType&&r.types.some(a=>a.type===z.TSTypeReference&&ve(a))))return;e.report({node:t.id,messageId:"nonCamelCaseFunction",data:{functionName:t.id.name}})}}}}}),le={name:$e,rule:Rt};import{AST_NODE_TYPES as A,ESLintUtils as kt}from"@typescript-eslint/utils";var It=kt.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`);function De(e){let t=[];for(let r of e.members)r.type===A.TSPropertySignature&&r.key.type===A.Identifier&&t.push([r.key.name,r]);return t}function Fe(e,...t){for(let r of t)e.set(...r);return e}var Me="no-unused-type-props-in-args",Ct=It({name:Me,meta:{type:"problem",docs:{description:"Disallow unused undestructured object type properties"},messages:{unusedObjectTypeProperty:"Object type property '{{ propertyName }}' is defined but never used"},schema:[],fixable:"code"},defaultOptions:[],create:function(e){function t(p,l,d,i=!0){let c=l.name,b=e.sourceCode.getScope(p).references.find(F=>F.identifier.name===c)?.resolved;if(!b||b.references.filter(F=>F.isTypeReference).length>1)return;let I=b?.defs[0]?.node;if(!(i&&I?.parent?.type===A.ExportNamedDeclaration)){if(I?.type===A.TSTypeAliasDeclaration){r(p,d,I.typeAnnotation,!0);return}if(I?.type===A.TSInterfaceDeclaration){r(p,d,I.body,!0);return}}}function r(p,l,d,i){if(d.type===A.TSInterfaceBody){for(let c of d.body)c.type===A.TSPropertySignature&&c.key.type===A.Identifier&&l.set(c.key.name,c);return}if(d.type===A.TSTypeLiteral){Fe(l,...De(d));return}if(d.type===A.TSIntersectionType){for(let c of d.types)r(p,l,c,!0);return}i||d.type===A.TSTypeReference&&d.typeName.type===A.Identifier&&t(p,d.typeName,l)}function o(p,l){for(let d of l)if(d.type==="ObjectPattern"&&d.typeAnnotation){let i=new Map;if(r(p,i,d.typeAnnotation.typeAnnotation,!1),i.size===0)continue;a(d,i)}else d.type===A.AssignmentPattern&&d.left.type===A.ObjectPattern&&o(p,[d.left])}function a(p,l){let d=[];if(p.properties.at(-1)?.type===A.RestElement)return;for(let I of p.properties)I.type===A.Property&&I.key.type===A.Identifier&&d.push(I.key.name);let c=[],b=[];for(let[I,F]of l)d.includes(I)||(b.push(I),c.push({node:F,messageId:"unusedObjectTypeProperty",data:{propertyName:I}}));for(let[I,F]of c.entries())e.report({...F,fix:I===c.length-1?O=>{let M=p.properties.at(-1),v=b.join(", ");return M?M?.type===A.RestElement?null:O.insertTextAfter(M,`, ${v}`):O.insertTextBeforeRange([p.range[0]+1,p.range[1]],`${v}`)}:void 0})}return{VariableDeclaration:function(p){let l=p.declarations[0];if(!l)return;let d=new Map,i=l.id.type===A.Identifier&&l.id.typeAnnotation?.typeAnnotation.type===A.TSTypeReference&&l.id.typeAnnotation.typeAnnotation.typeName.type===A.Identifier&&l.id.typeAnnotation.typeAnnotation.typeName.name==="FC"&&l.id.typeAnnotation.typeAnnotation.typeArguments?.params[0];if(i){if(i.type===A.TSTypeReference&&i.typeName.type===A.Identifier)t(p,i.typeName,d,!1);else if(i.type===A.TSTypeLiteral)Fe(d,...De(i));else if(i.type===A.TSIntersectionType)for(let c of i.types)c.type===A.TSTypeReference&&c.typeName.type===A.Identifier?t(p,c.typeName,d,!1):r(p,d,c,!0);if(d.size!==0&&l.init?.type===A.ArrowFunctionExpression){let c=l.init.params[0];c&&c.type===A.ObjectPattern&&a(c,d)}}},FunctionDeclaration:function(p){o(p,p.params)},ArrowFunctionExpression:function(p){o(p,p.params)}}}}),ue={name:Me,rule:Ct};import{ESLintUtils as At}from"@typescript-eslint/utils";var vt=At.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Pe="prefer-named-functions",Oe=new Map,$t=vt({name:Pe,meta:{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:{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` or have a name that matches the rule ignore regex'}},defaultOptions:[{}],create(e){let t=e.options[0]||{},r=null;if(t.ignoreRegex){let o=Oe.get(t.ignoreRegex);o?r=o:(r=new RegExp(t.ignoreRegex),Oe.set(t.ignoreRegex,r))}return{VariableDeclarator(o){if(o.init&&o.init.type==="ArrowFunctionExpression"&&o.id.type==="Identifier"){let a=o.id.name;if(o.id.typeAnnotation||r&&r.test(a)||!t.disallowArrowFnWithImplicitReturns&&o.init.body.type!=="BlockStatement")return;e.report({node:o.id,messageId:r?"withIgnoreRegex":"default",data:{functionName:a,ignoreRegex:t.ignoreRegex}})}}}}}),pe={name:Pe,rule:$t};import{ESLintUtils as Dt}from"@typescript-eslint/utils";var Ft=Dt.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),je="require-description",Mt=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,Ot=/^eslint-disable-(next-)?line$/u,Pt=Ft({name:je,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){let t=e.sourceCode,r=new Set(e.options[0]&&e.options[0].ignore||[]);return{Program(){for(let o of t.getAllComments()){let a=jt(o);a!=null&&(r.has(a.kind)||a.description||e.report({loc:Lt(o.loc),messageId:"missingDescription"}))}}}}}),He={name:je,rule:Pt};function jt(e){let{text:t,description:r}=Ht(e.value);if(!t)return null;let o=Mt.exec(t);if(!o)return null;let a=o[1];if(!a)return null;let p=Ot.test(a);if(e.type==="Line"&&!p||p&&e.loc.start.line!==e.loc.end.line)return null;let l=t.slice(o.index+a.length);return{kind:a,value:l.trim(),description:r}}function Ht(e){let t=e.split(/\s-{2,}\s/u);return{text:t[0]?.trim(),description:t.length>1?t[1]?.trim()??null:null}}function Lt(e){return{start:{line:e.start.line,column:-1},end:e.end}}function We(e){return/^use[A-Z0-9]/.test(e)}function Y(e){return e.type==="Identifier"?We(e.name):e.type==="MemberExpression"&&!e.computed&&Y(e.property)?e.object.type==="Identifier":!1}function Ue(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function Ne(e,t){return e.name===t||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===t}function Ve(e){return!!(e.parent&&e.parent.callee&&Ne(e.parent.callee,"forwardRef"))}function ze(e){return!!(e.parent&&e.parent.callee&&Ne(e.parent.callee,"memo"))}function fe(e){for(;e;){let t=Xe(e);if(t&&(Ue(t)||Y(t))||Ve(e)||ze(e))return!0;e=e.parent}return!1}function Le(e){return!1}function de(e){return!1}var _t=/eslint +react-compiler\/react-compiler: +\["error/,Be={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 i of e.sourceCode.getAllComments())if(_t.test(i.value))return{CallExpression(c){let b=null;c.callee.name==="useMemo"?b="useMemo":c.callee.name==="useCallback"&&(b="useCallback"),b&&e.report({node:c,message:`"${b}" is not necessary when using React Compiler.`})}}}let t=typeof e.getSource=="function"?i=>t(i):i=>e.sourceCode.getText(i),r=typeof e.getScope=="function"?()=>r():i=>e.sourceCode.getScope(i),o=null,a=[],p=[],l=new WeakSet;function d(i){for(let c of i.references){let b=c.identifier.parent;if(b.type==="VariableDeclarator"&&b.init&&b.init.type==="CallExpression"&&b.init.callee&&Le(b.init.callee))for(let I of c.resolved.references)I!==c&&l.add(I.identifier)}}return{onCodePathSegmentStart:i=>p.push(i),onCodePathSegmentEnd:()=>p.pop(),onCodePathStart:()=>a.push(new Map),onCodePathEnd(i,c){let b=a.pop();if(b.size===0)return;let I=new Set;function F(u,R){let{cache:C}=F,S=C.get(u.id),D=new Set(R);if(D.has(u.id)){let x=[...D],P=x.slice(x.indexOf(u.id)+1);for(let L of P)I.add(L);return BigInt("0")}if(D.add(u.id),S!==void 0)return S;if(i.thrownSegments.includes(u))S=BigInt("0");else if(u.prevSegments.length===0)S=BigInt("1");else{S=BigInt("0");for(let x of u.prevSegments)S+=F(x,D)}return u.reachable&&S===BigInt("0")?C.delete(u.id):C.set(u.id,S),S}function O(u,R){let{cache:C}=O,S=C.get(u.id),D=new Set(R);if(D.has(u.id)){let x=Array.from(D),P=x.slice(x.indexOf(u.id)+1);for(let L of P)I.add(L);return BigInt("0")}if(D.add(u.id),S!==void 0)return S;if(i.thrownSegments.includes(u))S=BigInt("0");else if(u.nextSegments.length===0)S=BigInt("1");else{S=BigInt("0");for(let x of u.nextSegments)S+=O(x,D)}return C.set(u.id,S),S}function M(u){let{cache:R}=M,C=R.get(u.id);if(C===null)return 1/0;if(C!==void 0)return C;if(R.set(u.id,null),u.prevSegments.length===0)C=1;else{C=1/0;for(let S of u.prevSegments){let D=M(S);D<C&&(C=D)}C+=1}return R.set(u.id,C),C}F.cache=new Map,O.cache=new Map,M.cache=new Map;let v=O(i.initialSegment),g=Xe(c),$=fe(c),w=g?Ue(g)||Y(g):Ve(c)||ze(c),k=1/0;for(let u of i.finalSegments){if(!u.reachable)continue;let R=M(u);R<k&&(k=R)}for(let[u,R]of b){if(!u.reachable)continue;let C=u.nextSegments.length===0?k<=M(u):k<M(u),S=F(u)*O(u),D=I.has(u.id);for(let x of R)if(D&&!de(x)&&e.report({node:x,message:`React Hook "${t(x)}" may be executed more than once. Possibly because it is called in a loop. React Hooks must be called in the exact same order in every component render.`}),w){if(c.async&&e.report({node:x,message:`React Hook "${t(x)}" cannot be called in an async function.`}),!D&&S!==v&&!de(x)){let L=`React Hook "${t(x)}" is called conditionally. React Hooks must be called in the exact same order in every component render.`+(C?" Did you accidentally call a React Hook after an early return?":"");e.report({node:x,message:L})}}else if(c.parent&&(c.parent.type==="MethodDefinition"||c.parent.type==="ClassProperty")&&c.parent.value===c){let P=`React Hook "${t(x)}" cannot be called in a class component. React Hooks must be called in a React function component or a custom React Hook function.`;e.report({node:x,message:P})}else if(g){let P=`React Hook "${t(x)}" is called in function "${t(g)}" that is neither a React function component nor a custom React Hook function. React component names must start with an uppercase letter. React Hook names must start with the word "use".`;e.report({node:x,message:P})}else if(c.type==="Program"){let P=`React Hook "${t(x)}" cannot be called at the top level. React Hooks must be called in a React function component or a custom React Hook function.`;e.report({node:x,message:P})}else if($&&!de(x)){if(c.parent.type==="CallExpression"&&c.parent.callee.type==="Identifier"&&c.parent.callee.name==="useCallback"){let L=c.parent;if(L.parent.type==="VariableDeclarator"&&We(L.parent.id.name))return}let P=`React Hook "${t(x)}" cannot be called inside a callback. React Hooks must be called in a React function component or a custom React Hook function.`;e.report({node:x,message:P})}}},CallExpression(i){if(Y(i.callee)){let c=_e(a),b=_e(p),I=c.get(b);I||(I=[],c.set(b,I)),I.push(i.callee)}i.callee.type==="Identifier"&&(i.callee.name==="useEffect"||Le(i.callee))&&i.arguments.length>0&&(o=i)},Identifier(i){o==null&&l.has(i)&&i.parent.type!=="CallExpression"&&e.report({node:i,message:`\`${t(i)}\` 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"(i){i===o&&(o=null)},FunctionDeclaration(i){fe(i)&&d(r(i))},ArrowFunctionExpression(i){fe(i)&&d(r(i))}}}};function Xe(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 _e(e){return e[e.length-1]}var qe={[ue.name]:ue.rule,[ae.name]:ae.rule,[oe.name]:oe.rule,"rules-of-hooks":Be,"exhaustive-deps":xe,"require-description":He.rule,[ce.name]:ce.rule,[le.name]:le.rule,[pe.name]:pe.rule,[ne.name]:ne.rule};var Tn={rules:qe};export{Tn as extendedLintPlugin};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ls-stack/extended-lint",
3
- "version": "0.10.0",
3
+ "version": "0.11.1",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "dist"