@ls-stack/extended-lint 0.76.1 → 0.76.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/extended-lint.js +1 -1
- package/dist/extended-lint.mjs +1 -1
- package/package.json +1 -1
package/dist/extended-lint.js
CHANGED
|
@@ -32,7 +32,7 @@ const ${e}: FC<${u}> = ({ ${c} }) => {
|
|
|
32
32
|
|
|
33
33
|
${y}`)),E.push(m.replaceText(s,C)),E}}]})}function Go(e,n,r){let t=e.arguments[0];if(!t||t.type!==$.AST_NODE_TYPES.JSXElement&&t.type!==$.AST_NODE_TYPES.JSXFragment)return;let s=t,o=Wr(s,n);if(!o.hasUnstable)return;let i=Yo(s),p=Jr(s,[],n),c=s.type===$.AST_NODE_TYPES.JSXElement?Xr(s,n):null,a=o.problematicProps.length===1?`prop "${o.problematicProps[0]}"`:`props "${o.problematicProps.join('", "')}"`;r.report({node:s,messageId:"unstableValueInMap",data:{problematicProps:a},suggest:[{messageId:"extractComponent",data:{componentName:i},fix:u=>{let m=Vr(i,s,[],p,n),y=qo(i,p,c),C=e;for(;C.parent.type!==$.AST_NODE_TYPES.Program&&!(C.type===$.AST_NODE_TYPES.FunctionDeclaration||C.type===$.AST_NODE_TYPES.VariableDeclarator&&C.init&&(C.init.type===$.AST_NODE_TYPES.ArrowFunctionExpression||C.init.type===$.AST_NODE_TYPES.FunctionExpression));)C=C.parent;let f=[];return f.push(u.insertTextAfter(C,`
|
|
34
34
|
|
|
35
|
-
${m}`)),f.push(u.replaceText(s,y)),f}}]})}var It=require("@typescript-eslint/utils"),Ko=It.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Br="require-description",Qo=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,ea=/^eslint-disable-(next-)?line$/u,ta=Ko({name:Br,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,[n]){let r=e.sourceCode,t=new Set(n.ignore||[]);return{Program(){for(let s of r.getAllComments()){let o=na(s);o!=null&&(t.has(o.kind)||o.description||e.report({loc:sa(s.loc),messageId:"missingDescription"}))}}}}}),Hr={name:Br,rule:ta};function na(e){let{text:n,description:r}=ia(e.value);if(!n)return null;let t=Qo.exec(n);if(!t)return null;let s=t[1];if(!s)return null;let o=ea.test(s);if(e.type===It.TSESTree.AST_TOKEN_TYPES.Line&&!o||o&&e.loc.start.line!==e.loc.end.line)return null;let i=n.slice(t.index+s.length);return{kind:s,value:i.trim(),description:r}}var ra=/\s-{2,}\s/u;function ia(e){let n=e.split(ra);return{text:n[0]?.trim(),description:n.length>1?n[1]?.trim()??null:null}}function sa(e){return{start:{line:e.start.line,column:-1},end:e.end}}var ne=require("@typescript-eslint/utils"),Me=require("zod/v4");var oa=Me.z.object({varsToCheck:Me.z.array(Me.z.object({selector:Me.z.string().optional(),fromFnCall:Me.z.string().optional(),prop:Me.z.string().or(Me.z.array(Me.z.string())),errorMsg:Me.z.string().optional()}))}),Rn=q({name:"require-reads-to-var-prop",meta:{type:"suggestion",docs:{description:"Require specific properties from variables to be read or ensure the variable is passed to functions/components"},messages:{propNotRead:'"{{fnName}}" requires reads to the prop "{{prop}}". {{customMsg}}',propsNotRead:'"{{fnName}}" requires reads to the props {{props}}. {{customMsg}}'},schema:[B(oa)]},defaultOptions:[{varsToCheck:[]}],create(e,[n]){let r=new Map;function t(i,p,c,a){let u=new Set;for(let y of i.properties)y.type===ne.AST_NODE_TYPES.Property&&y.key.type===ne.AST_NODE_TYPES.Identifier&&u.add(y.key.name);let m=p.filter(y=>!u.has(y));if(m.length>0)if(m.length===1)e.report({node:i,messageId:"propNotRead",data:{prop:m[0],fnName:a,customMsg:c||""}});else{let y=m.map(C=>`"${C}"`).join(", ");e.report({node:i,messageId:"propsNotRead",data:{props:y,fnName:a,customMsg:c||""}})}}function s(i){if(i.init?.type===ne.AST_NODE_TYPES.CallExpression){if(i.init.callee.type===ne.AST_NODE_TYPES.Identifier)return i.init.callee.name;if(i.init.callee.type===ne.AST_NODE_TYPES.MemberExpression&&i.init.callee.property.type===ne.AST_NODE_TYPES.Identifier)return i.init.callee.object.type===ne.AST_NODE_TYPES.Identifier?`${i.init.callee.object.name}.${i.init.callee.property.name}`:i.init.callee.property.name}return"unknown function"}let o={};for(let i of n.varsToCheck)i.selector&&(o[i.selector]=p=>{if(p.type===ne.AST_NODE_TYPES.VariableDeclarator&&p.id.type===ne.AST_NODE_TYPES.Identifier&&r.set(p.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:p.id,fnName:s(p)}),p.type===ne.AST_NODE_TYPES.VariableDeclarator&&p.id.type===ne.AST_NODE_TYPES.ObjectPattern){let c=Array.isArray(i.prop)?i.prop:[i.prop];t(p.id,c,i.errorMsg,s(p))}});for(let i of n.varsToCheck)if(i.fromFnCall){let p=i.fromFnCall;if(p.startsWith("*.")){let a=`VariableDeclarator > CallExpression > MemberExpression[property.name="${p.slice(2)}"]`;o[a]=u=>{if(u.type!==ne.AST_NODE_TYPES.MemberExpression||u.parent.type!==ne.AST_NODE_TYPES.CallExpression)return;let m=u.parent;if(m.parent.type!==ne.AST_NODE_TYPES.VariableDeclarator)return;let y=m.parent;if(y.id.type===ne.AST_NODE_TYPES.Identifier)r.set(y.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:y.id,fnName:i.fromFnCall||"unknown function"});else if(y.id.type===ne.AST_NODE_TYPES.ObjectPattern){let C=Array.isArray(i.prop)?i.prop:[i.prop];t(y.id,C,i.errorMsg,i.fromFnCall||"unknown function")}}}else if(p.includes(".")){let[c,a]=p.split("."),u=`VariableDeclarator > CallExpression > MemberExpression[object.name="${c}"][property.name="${a}"]`;o[u]=m=>{if(m.type!==ne.AST_NODE_TYPES.MemberExpression||m.parent.type!==ne.AST_NODE_TYPES.CallExpression)return;let y=m.parent;if(y.parent.type!==ne.AST_NODE_TYPES.VariableDeclarator)return;let C=y.parent;if(C.id.type===ne.AST_NODE_TYPES.Identifier)r.set(C.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:C.id,fnName:i.fromFnCall||"unknown function"});else if(C.id.type===ne.AST_NODE_TYPES.ObjectPattern){let f=Array.isArray(i.prop)?i.prop:[i.prop];t(C.id,f,i.errorMsg,i.fromFnCall||"unknown function")}}}else{let c=`VariableDeclarator > CallExpression > Identifier[name="${p}"]`;o[c]=a=>{if(a.type!==ne.AST_NODE_TYPES.Identifier||a.parent.type!==ne.AST_NODE_TYPES.CallExpression)return;let u=a.parent;if(u.parent.type!==ne.AST_NODE_TYPES.VariableDeclarator)return;let m=u.parent;if(m.id.type===ne.AST_NODE_TYPES.Identifier)r.set(m.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:m.id,fnName:i.fromFnCall||"unknown function"});else if(m.id.type===ne.AST_NODE_TYPES.ObjectPattern){let y=Array.isArray(i.prop)?i.prop:[i.prop];t(m.id,y,i.errorMsg,i.fromFnCall||"unknown function")}}}}return{...o,"Program:exit"(){for(let[i,{props:p,errorMsg:c,node:a,fnName:u}]of r){let y=e.sourceCode.getScope(a).set.get(i);if(y){let C=new Set(p);for(let f of y.references){let E=f.identifier,x=E.parent;if(!(x.type===ne.AST_NODE_TYPES.VariableDeclarator&&x.id===E)){if(x.type===ne.AST_NODE_TYPES.MemberExpression&&x.object===E&&x.property.type===ne.AST_NODE_TYPES.Identifier&&C.has(x.property.name)){if(C.delete(x.property.name),C.size===0)break;continue}if(x.type===ne.AST_NODE_TYPES.VariableDeclarator&&x.init===E&&x.id.type===ne.AST_NODE_TYPES.ObjectPattern){for(let S of x.id.properties)S.type===ne.AST_NODE_TYPES.Property&&S.key.type===ne.AST_NODE_TYPES.Identifier&&C.has(S.key.name)&&C.delete(S.key.name);if(C.size===0)break;continue}if(!(x.type===ne.AST_NODE_TYPES.MemberExpression&&x.object===E&&x.property.type===ne.AST_NODE_TYPES.Identifier&&!p.includes(x.property.name))){C.clear();break}}}if(C.size>0){let f=Array.from(C);if(f.length===1)e.report({node:a,messageId:"propNotRead",data:{prop:f[0],fnName:u,customMsg:c||""}});else{let E=f.map(x=>`"${x}"`).join(", ");e.report({node:a,messageId:"propsNotRead",data:{props:E,fnName:u,customMsg:c||""}})}}}}}}}});function Zr(e){return/^use[A-Z0-9]/.test(e)}function At(e){return e.type==="Identifier"?Zr(e.name):e.type==="MemberExpression"&&!e.computed&&At(e.property)?e.object.type==="Identifier":!1}function Gr(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function Kr(e,n){return e.name===n||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===n}function Qr(e){return!!(e.parent&&e.parent.callee&&Kr(e.parent.callee,"forwardRef"))}function ei(e){return!!(e.parent&&e.parent.callee&&Kr(e.parent.callee,"memo"))}function Fn(e){for(;e;){let n=ni(e);if(n&&(Gr(n)||At(n))||Qr(e)||ei(e))return!0;e=e.parent}return!1}function Yr(e){return!1}function kn(e){return!1}var aa=/eslint +react-compiler\/react-compiler: +\["error/,ti={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"},reactCompilerIsEnabled:{type:"boolean"}}}]},create(e){let n=!!e.options[0]?.reactCompilerIsEnabled;if(e.options[0]?.ignoreIfReactCompilerIsEnabled||n){for(let a of e.sourceCode.getAllComments())if(n||aa.test(a.value))return{CallExpression(u){let m=null;u.callee.name==="useMemo"?m="useMemo":u.callee.name==="useCallback"&&(m="useCallback"),m&&e.report({node:u,message:`"${m}" is not necessary when using React Compiler.`})}}}let r=typeof e.getSource=="function"?a=>r(a):a=>e.sourceCode.getText(a),t=typeof e.getScope=="function"?()=>t():a=>e.sourceCode.getScope(a),s=null,o=[],i=[],p=new WeakSet;function c(a){for(let u of a.references){let m=u.identifier.parent;if(m.type==="VariableDeclarator"&&m.init&&m.init.type==="CallExpression"&&m.init.callee&&Yr(m.init.callee))for(let y of u.resolved.references)y!==u&&p.add(y.identifier)}}return{onCodePathSegmentStart:a=>i.push(a),onCodePathSegmentEnd:()=>i.pop(),onCodePathStart:()=>o.push(new Map),onCodePathEnd(a,u){let m=o.pop();if(m.size===0)return;let y=new Set;function C(h,b){let{cache:w}=C,P=w.get(h.id),N=new Set(b);if(N.has(h.id)){let l=[...N],R=l.slice(l.indexOf(h.id)+1);for(let d of R)y.add(d);return BigInt("0")}if(N.add(h.id),P!==void 0)return P;if(a.thrownSegments.includes(h))P=BigInt("0");else if(h.prevSegments.length===0)P=BigInt("1");else{P=BigInt("0");for(let l of h.prevSegments)P+=C(l,N)}return h.reachable&&P===BigInt("0")?w.delete(h.id):w.set(h.id,P),P}function f(h,b){let{cache:w}=f,P=w.get(h.id),N=new Set(b);if(N.has(h.id)){let l=Array.from(N),R=l.slice(l.indexOf(h.id)+1);for(let d of R)y.add(d);return BigInt("0")}if(N.add(h.id),P!==void 0)return P;if(a.thrownSegments.includes(h))P=BigInt("0");else if(h.nextSegments.length===0)P=BigInt("1");else{P=BigInt("0");for(let l of h.nextSegments)P+=f(l,N)}return w.set(h.id,P),P}function E(h){let{cache:b}=E,w=b.get(h.id);if(w===null)return 1/0;if(w!==void 0)return w;if(b.set(h.id,null),h.prevSegments.length===0)w=1;else{w=1/0;for(let P of h.prevSegments){let N=E(P);N<w&&(w=N)}w+=1}return b.set(h.id,w),w}C.cache=new Map,f.cache=new Map,E.cache=new Map;let x=f(a.initialSegment),S=ni(u),I=Fn(u),A=S?Gr(S)||At(S):Qr(u)||ei(u),T=1/0;for(let h of a.finalSegments){if(!h.reachable)continue;let b=E(h);b<T&&(T=b)}for(let[h,b]of m){if(!h.reachable)continue;let w=h.nextSegments.length===0?T<=E(h):T<E(h),P=C(h)*f(h),N=y.has(h.id);for(let l of b)if(N&&!kn(l)&&e.report({node:l,message:`React Hook "${r(l)}" may be executed more than once. Possibly because it is called in a loop. React Hooks must be called in the exact same order in every component render.`}),A){if(u.async&&e.report({node:l,message:`React Hook "${r(l)}" cannot be called in an async function.`}),!N&&P!==x&&!kn(l)){let d=`React Hook "${r(l)}" is called conditionally. React Hooks must be called in the exact same order in every component render.`+(w?" Did you accidentally call a React Hook after an early return?":"");e.report({node:l,message:d})}}else if(u.parent&&(u.parent.type==="MethodDefinition"||u.parent.type==="ClassProperty")&&u.parent.value===u){let R=`React Hook "${r(l)}" 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:l,message:R})}else if(S){let R=`React Hook "${r(l)}" is called in function "${r(S)}" 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:l,message:R})}else if(u.type==="Program"){let R=`React Hook "${r(l)}" 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:l,message:R})}else if(I&&!kn(l)){if(u.parent.type==="CallExpression"&&u.parent.callee.type==="Identifier"&&u.parent.callee.name==="useCallback"){let d=u.parent;if(d.parent.type==="VariableDeclarator"&&Zr(d.parent.id.name))return}let R=`React Hook "${r(l)}" 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:l,message:R})}}},CallExpression(a){if(At(a.callee)){let u=qr(o),m=qr(i),y=u.get(m);y||(y=[],u.set(m,y)),y.push(a.callee)}a.callee.type==="Identifier"&&(a.callee.name==="useEffect"||Yr(a.callee))&&a.arguments.length>0&&(s=a)},Identifier(a){s==null&&p.has(a)&&a.parent.type!=="CallExpression"&&e.report({node:a,message:`\`${r(a)}\` is a function created with React Hook "useEffectEvent", and can only be called from the same component. They cannot be assigned to variables or passed down.`})},"CallExpression:exit"(a){a===s&&(s=null)},FunctionDeclaration(a){Fn(a)&&c(t(a))},ArrowFunctionExpression(a){Fn(a)&&c(t(a))}}}};function ni(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 qr(e){return e[e.length-1]}var ge=require("@typescript-eslint/utils"),xe=ve(require("zod/v4"));var la=/^\s+$/,Pn=/\r?\n/,pa=/^(\s*)/,ca=/^(\s*)\S/,ua=/\r?\n/,fa=xe.object({indent:xe.union([xe.string().regex(la),xe.number().int().min(1)]).optional(),tags:xe.array(xe.string()).optional(),functions:xe.array(xe.string()).optional(),comments:xe.array(xe.string()).optional()}),vn=q({name:"template-indent",meta:{type:"suggestion",docs:{description:"Fix whitespace-insensitive template indentation"},fixable:"code",schema:[B(fa)],messages:{improperlyIndented:"Templates should be properly indented."}},defaultOptions:[{}],create(e){let n=e.sourceCode,{comments:r=["HTML","indent"],functions:t=["dedent","stripIndent"],tags:s=["outdent","dedent","gql","sql","html","styled"],indent:o}=e.options[0],i=r.map(S=>S.toLowerCase());function p(S){let I=S.split(Pn),A=I.filter(h=>h.trim()!=="");if(A.length===0)return S;let T=Number.POSITIVE_INFINITY;for(let h of A){let b=h.match(pa);b&&(T=Math.min(T,b[1]?.length??0))}return!isFinite(T)||T===0?S:I.map(h=>h.slice(T)).join(`
|
|
35
|
+
${m}`)),f.push(u.replaceText(s,y)),f}}]})}var It=require("@typescript-eslint/utils"),Ko=It.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Br="require-description",Qo=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,ea=/^eslint-disable-(next-)?line$/u,ta=Ko({name:Br,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,[n]){let r=e.sourceCode,t=new Set(n.ignore||[]);return{Program(){for(let s of r.getAllComments()){let o=na(s);o!=null&&(t.has(o.kind)||o.description||e.report({loc:sa(s.loc),messageId:"missingDescription"}))}}}}}),Hr={name:Br,rule:ta};function na(e){let{text:n,description:r}=ia(e.value);if(!n)return null;let t=Qo.exec(n);if(!t)return null;let s=t[1];if(!s)return null;let o=ea.test(s);if(e.type===It.TSESTree.AST_TOKEN_TYPES.Line&&!o||o&&e.loc.start.line!==e.loc.end.line)return null;let i=n.slice(t.index+s.length);return{kind:s,value:i.trim(),description:r}}var ra=/\s-{2,}\s/u;function ia(e){let n=e.split(ra);return{text:n[0]?.trim(),description:n.length>1?n[1]?.trim()??null:null}}function sa(e){return{start:{line:e.start.line,column:-1},end:e.end}}var ne=require("@typescript-eslint/utils"),Me=require("zod/v4");var oa=Me.z.object({varsToCheck:Me.z.array(Me.z.object({selector:Me.z.string().optional(),fromFnCall:Me.z.string().optional(),prop:Me.z.string().or(Me.z.array(Me.z.string())),errorMsg:Me.z.string().optional()}))}),Rn=q({name:"require-reads-to-var-prop",meta:{type:"suggestion",docs:{description:"Require specific properties from variables to be read or ensure the variable is passed to functions/components"},messages:{propNotRead:'"{{fnName}}" requires reads to the prop "{{prop}}". {{customMsg}}',propsNotRead:'"{{fnName}}" requires reads to the props {{props}}. {{customMsg}}'},schema:[B(oa)]},defaultOptions:[{varsToCheck:[]}],create(e,[n]){let r=new Map;function t(i,p,c,a){let u=new Set;for(let y of i.properties)y.type===ne.AST_NODE_TYPES.Property&&y.key.type===ne.AST_NODE_TYPES.Identifier&&u.add(y.key.name);let m=p.filter(y=>!u.has(y));if(m.length>0)if(m.length===1)e.report({node:i,messageId:"propNotRead",data:{prop:m[0],fnName:a,customMsg:c||""}});else{let y=m.map(C=>`"${C}"`).join(", ");e.report({node:i,messageId:"propsNotRead",data:{props:y,fnName:a,customMsg:c||""}})}}function s(i){if(i.init?.type===ne.AST_NODE_TYPES.CallExpression){if(i.init.callee.type===ne.AST_NODE_TYPES.Identifier)return i.init.callee.name;if(i.init.callee.type===ne.AST_NODE_TYPES.MemberExpression&&i.init.callee.property.type===ne.AST_NODE_TYPES.Identifier)return i.init.callee.object.type===ne.AST_NODE_TYPES.Identifier?`${i.init.callee.object.name}.${i.init.callee.property.name}`:i.init.callee.property.name}return"unknown function"}let o={};for(let i of n.varsToCheck)i.selector&&(o[i.selector]=p=>{if(p.type===ne.AST_NODE_TYPES.VariableDeclarator&&p.id.type===ne.AST_NODE_TYPES.Identifier&&r.set(p.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:p.id,fnName:s(p)}),p.type===ne.AST_NODE_TYPES.VariableDeclarator&&p.id.type===ne.AST_NODE_TYPES.ObjectPattern){let c=Array.isArray(i.prop)?i.prop:[i.prop];t(p.id,c,i.errorMsg,s(p))}});for(let i of n.varsToCheck)if(i.fromFnCall){let p=i.fromFnCall;if(p.startsWith("*.")){let a=`VariableDeclarator > CallExpression > MemberExpression[property.name="${p.slice(2)}"]`;o[a]=u=>{if(u.type!==ne.AST_NODE_TYPES.MemberExpression||u.parent.type!==ne.AST_NODE_TYPES.CallExpression)return;let m=u.parent;if(m.parent.type!==ne.AST_NODE_TYPES.VariableDeclarator)return;let y=m.parent;if(y.id.type===ne.AST_NODE_TYPES.Identifier)r.set(y.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:y.id,fnName:i.fromFnCall||"unknown function"});else if(y.id.type===ne.AST_NODE_TYPES.ObjectPattern){let C=Array.isArray(i.prop)?i.prop:[i.prop];t(y.id,C,i.errorMsg,i.fromFnCall||"unknown function")}}}else if(p.includes(".")){let[c,a]=p.split("."),u=`VariableDeclarator > CallExpression > MemberExpression[object.name="${c}"][property.name="${a}"]`;o[u]=m=>{if(m.type!==ne.AST_NODE_TYPES.MemberExpression||m.parent.type!==ne.AST_NODE_TYPES.CallExpression)return;let y=m.parent;if(y.parent.type!==ne.AST_NODE_TYPES.VariableDeclarator)return;let C=y.parent;if(C.id.type===ne.AST_NODE_TYPES.Identifier)r.set(C.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:C.id,fnName:i.fromFnCall||"unknown function"});else if(C.id.type===ne.AST_NODE_TYPES.ObjectPattern){let f=Array.isArray(i.prop)?i.prop:[i.prop];t(C.id,f,i.errorMsg,i.fromFnCall||"unknown function")}}}else{let c=`VariableDeclarator > CallExpression > Identifier[name="${p}"]`;o[c]=a=>{if(a.type!==ne.AST_NODE_TYPES.Identifier||a.parent.type!==ne.AST_NODE_TYPES.CallExpression)return;let u=a.parent;if(u.parent.type!==ne.AST_NODE_TYPES.VariableDeclarator)return;let m=u.parent;if(m.id.type===ne.AST_NODE_TYPES.Identifier)r.set(m.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:m.id,fnName:i.fromFnCall||"unknown function"});else if(m.id.type===ne.AST_NODE_TYPES.ObjectPattern){let y=Array.isArray(i.prop)?i.prop:[i.prop];t(m.id,y,i.errorMsg,i.fromFnCall||"unknown function")}}}}return{...o,"Program:exit"(){for(let[i,{props:p,errorMsg:c,node:a,fnName:u}]of r){let y=e.sourceCode.getScope(a).set.get(i);if(y){let C=new Set(p);for(let f of y.references){let E=f.identifier,x=E.parent;if(!(x.type===ne.AST_NODE_TYPES.VariableDeclarator&&x.id===E)){if(x.type===ne.AST_NODE_TYPES.MemberExpression&&x.object===E&&x.property.type===ne.AST_NODE_TYPES.Identifier&&C.has(x.property.name)){if(C.delete(x.property.name),C.size===0)break;continue}if(x.type===ne.AST_NODE_TYPES.VariableDeclarator&&x.init===E&&x.id.type===ne.AST_NODE_TYPES.ObjectPattern){for(let S of x.id.properties)S.type===ne.AST_NODE_TYPES.Property&&S.key.type===ne.AST_NODE_TYPES.Identifier&&C.has(S.key.name)&&C.delete(S.key.name);if(C.size===0)break;continue}if(!(x.type===ne.AST_NODE_TYPES.MemberExpression&&x.object===E&&x.property.type===ne.AST_NODE_TYPES.Identifier&&!p.includes(x.property.name))){C.clear();break}}}if(C.size>0){let f=Array.from(C);if(f.length===1)e.report({node:a,messageId:"propNotRead",data:{prop:f[0],fnName:u,customMsg:c||""}});else{let E=f.map(x=>`"${x}"`).join(", ");e.report({node:a,messageId:"propsNotRead",data:{props:E,fnName:u,customMsg:c||""}})}}}}}}}});function Zr(e){return/^use[A-Z0-9]/.test(e)}function At(e){return e.type==="Identifier"?Zr(e.name):e.type==="MemberExpression"&&!e.computed&&At(e.property)?e.object.type==="Identifier":!1}function Gr(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function Kr(e,n){return e.name===n||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===n}function Qr(e){return!!(e.parent&&e.parent.callee&&Kr(e.parent.callee,"forwardRef"))}function ei(e){return!!(e.parent&&e.parent.callee&&Kr(e.parent.callee,"memo"))}function Fn(e){for(;e;){let n=ni(e);if(n&&(Gr(n)||At(n))||Qr(e)||ei(e))return!0;e=e.parent}return!1}function Yr(e){return!1}function kn(e){return!1}var aa=/eslint +react-compiler\/react-compiler: +\["error/,ti={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"},reactCompilerIsEnabled:{type:"boolean"}}}]},create(e){let n=!!e.options[0]?.reactCompilerIsEnabled;if(n)return{CallExpression(a){let u=null;a.callee.name==="useMemo"?u="useMemo":a.callee.name==="useCallback"&&(u="useCallback"),u&&e.report({node:a,message:`"${u}" is not necessary when using React Compiler.`})}};if(e.options[0]?.ignoreIfReactCompilerIsEnabled||n){for(let a of e.sourceCode.getAllComments())if(aa.test(a.value))return{CallExpression(u){let m=null;u.callee.name==="useMemo"?m="useMemo":u.callee.name==="useCallback"&&(m="useCallback"),m&&e.report({node:u,message:`"${m}" is not necessary when using React Compiler.`})}}}let r=typeof e.getSource=="function"?a=>r(a):a=>e.sourceCode.getText(a),t=typeof e.getScope=="function"?()=>t():a=>e.sourceCode.getScope(a),s=null,o=[],i=[],p=new WeakSet;function c(a){for(let u of a.references){let m=u.identifier.parent;if(m.type==="VariableDeclarator"&&m.init&&m.init.type==="CallExpression"&&m.init.callee&&Yr(m.init.callee))for(let y of u.resolved.references)y!==u&&p.add(y.identifier)}}return{onCodePathSegmentStart:a=>i.push(a),onCodePathSegmentEnd:()=>i.pop(),onCodePathStart:()=>o.push(new Map),onCodePathEnd(a,u){let m=o.pop();if(m.size===0)return;let y=new Set;function C(h,b){let{cache:w}=C,P=w.get(h.id),N=new Set(b);if(N.has(h.id)){let l=[...N],R=l.slice(l.indexOf(h.id)+1);for(let d of R)y.add(d);return BigInt("0")}if(N.add(h.id),P!==void 0)return P;if(a.thrownSegments.includes(h))P=BigInt("0");else if(h.prevSegments.length===0)P=BigInt("1");else{P=BigInt("0");for(let l of h.prevSegments)P+=C(l,N)}return h.reachable&&P===BigInt("0")?w.delete(h.id):w.set(h.id,P),P}function f(h,b){let{cache:w}=f,P=w.get(h.id),N=new Set(b);if(N.has(h.id)){let l=Array.from(N),R=l.slice(l.indexOf(h.id)+1);for(let d of R)y.add(d);return BigInt("0")}if(N.add(h.id),P!==void 0)return P;if(a.thrownSegments.includes(h))P=BigInt("0");else if(h.nextSegments.length===0)P=BigInt("1");else{P=BigInt("0");for(let l of h.nextSegments)P+=f(l,N)}return w.set(h.id,P),P}function E(h){let{cache:b}=E,w=b.get(h.id);if(w===null)return 1/0;if(w!==void 0)return w;if(b.set(h.id,null),h.prevSegments.length===0)w=1;else{w=1/0;for(let P of h.prevSegments){let N=E(P);N<w&&(w=N)}w+=1}return b.set(h.id,w),w}C.cache=new Map,f.cache=new Map,E.cache=new Map;let x=f(a.initialSegment),S=ni(u),I=Fn(u),A=S?Gr(S)||At(S):Qr(u)||ei(u),T=1/0;for(let h of a.finalSegments){if(!h.reachable)continue;let b=E(h);b<T&&(T=b)}for(let[h,b]of m){if(!h.reachable)continue;let w=h.nextSegments.length===0?T<=E(h):T<E(h),P=C(h)*f(h),N=y.has(h.id);for(let l of b)if(N&&!kn(l)&&e.report({node:l,message:`React Hook "${r(l)}" may be executed more than once. Possibly because it is called in a loop. React Hooks must be called in the exact same order in every component render.`}),A){if(u.async&&e.report({node:l,message:`React Hook "${r(l)}" cannot be called in an async function.`}),!N&&P!==x&&!kn(l)){let d=`React Hook "${r(l)}" is called conditionally. React Hooks must be called in the exact same order in every component render.`+(w?" Did you accidentally call a React Hook after an early return?":"");e.report({node:l,message:d})}}else if(u.parent&&(u.parent.type==="MethodDefinition"||u.parent.type==="ClassProperty")&&u.parent.value===u){let R=`React Hook "${r(l)}" 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:l,message:R})}else if(S){let R=`React Hook "${r(l)}" is called in function "${r(S)}" 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:l,message:R})}else if(u.type==="Program"){let R=`React Hook "${r(l)}" 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:l,message:R})}else if(I&&!kn(l)){if(u.parent.type==="CallExpression"&&u.parent.callee.type==="Identifier"&&u.parent.callee.name==="useCallback"){let d=u.parent;if(d.parent.type==="VariableDeclarator"&&Zr(d.parent.id.name))return}let R=`React Hook "${r(l)}" 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:l,message:R})}}},CallExpression(a){if(At(a.callee)){let u=qr(o),m=qr(i),y=u.get(m);y||(y=[],u.set(m,y)),y.push(a.callee)}a.callee.type==="Identifier"&&(a.callee.name==="useEffect"||Yr(a.callee))&&a.arguments.length>0&&(s=a)},Identifier(a){s==null&&p.has(a)&&a.parent.type!=="CallExpression"&&e.report({node:a,message:`\`${r(a)}\` is a function created with React Hook "useEffectEvent", and can only be called from the same component. They cannot be assigned to variables or passed down.`})},"CallExpression:exit"(a){a===s&&(s=null)},FunctionDeclaration(a){Fn(a)&&c(t(a))},ArrowFunctionExpression(a){Fn(a)&&c(t(a))}}}};function ni(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 qr(e){return e[e.length-1]}var ge=require("@typescript-eslint/utils"),xe=ve(require("zod/v4"));var la=/^\s+$/,Pn=/\r?\n/,pa=/^(\s*)/,ca=/^(\s*)\S/,ua=/\r?\n/,fa=xe.object({indent:xe.union([xe.string().regex(la),xe.number().int().min(1)]).optional(),tags:xe.array(xe.string()).optional(),functions:xe.array(xe.string()).optional(),comments:xe.array(xe.string()).optional()}),vn=q({name:"template-indent",meta:{type:"suggestion",docs:{description:"Fix whitespace-insensitive template indentation"},fixable:"code",schema:[B(fa)],messages:{improperlyIndented:"Templates should be properly indented."}},defaultOptions:[{}],create(e){let n=e.sourceCode,{comments:r=["HTML","indent"],functions:t=["dedent","stripIndent"],tags:s=["outdent","dedent","gql","sql","html","styled"],indent:o}=e.options[0],i=r.map(S=>S.toLowerCase());function p(S){let I=S.split(Pn),A=I.filter(h=>h.trim()!=="");if(A.length===0)return S;let T=Number.POSITIVE_INFINITY;for(let h of A){let b=h.match(pa);b&&(T=Math.min(T,b[1]?.length??0))}return!isFinite(T)||T===0?S:I.map(h=>h.slice(T)).join(`
|
|
36
36
|
`)}function c(S,I,A){return S.split(Pn).map(h=>h.trim()===""?h:A.repeat(I)+h).join(`
|
|
37
37
|
`)}function a(S){if(S.type===ge.AST_NODE_TYPES.Identifier)return S.name;if(S.type===ge.AST_NODE_TYPES.MemberExpression){let I=S.object.type===ge.AST_NODE_TYPES.Identifier?S.object.name:null,A=S.property.type===ge.AST_NODE_TYPES.Identifier?S.property.name:null;return I&&A?`${I}.${A}`:A}return null}function u(S,I){if(!S)return!1;for(let A of I)if(A.includes(".")){let T=A.split(".");if(S.type===ge.AST_NODE_TYPES.MemberExpression&&S.object.type===ge.AST_NODE_TYPES.Identifier&&S.property.type===ge.AST_NODE_TYPES.Identifier&&S.object.name===T[0]&&S.property.name===T[1])return!0}else if(S.type===ge.AST_NODE_TYPES.Identifier&&S.name===A)return!0;return!1}function m(S,I){let A=S.parent;if(A.type!==ge.AST_NODE_TYPES.TaggedTemplateExpression)return!1;let T=a(A.tag);return T?I.includes(T):!1}function y(S,I){if(!S||S.type!==ge.AST_NODE_TYPES.CallExpression)return!1;let{method:A,argumentsLength:T,optionalCall:h=!0,optionalMember:b=!0}=I;return T!==void 0&&S.arguments.length!==T||!h&&S.optional||S.callee.type!==ge.AST_NODE_TYPES.MemberExpression||!b&&S.callee.optional||S.callee.property.type!==ge.AST_NODE_TYPES.Identifier?!1:S.callee.property.name===A}function C(S,I){if(!S||S.type!==ge.AST_NODE_TYPES.CallExpression)return!1;let{name:A,argumentsLength:T,optionalCall:h=!0}=I;return T!==void 0&&S.arguments.length!==T||!h&&S.optional||S.callee.type!==ge.AST_NODE_TYPES.Identifier?!1:S.callee.name===A}function f(S){return y(S.parent,{method:"toMatchInlineSnapshot",argumentsLength:1,optionalCall:!1,optionalMember:!1})&&S.parent.type===ge.AST_NODE_TYPES.CallExpression&&S.parent.arguments[0]===S&&C(S.parent.callee.type===ge.AST_NODE_TYPES.MemberExpression?S.parent.callee.object:null,{name:"expect",argumentsLength:1,optionalCall:!1,optionalMember:!1})}function E(S){if(i.length>0){let I=n.getTokenBefore(S,{includeComments:!0});if(I?.type===ge.AST_TOKEN_TYPES.Block&&i.includes(I.value.trim().toLowerCase()))return!0}return!!(f(S)||s.length>0&&m(S,s)||t.length>0&&S.parent.type===ge.AST_NODE_TYPES.CallExpression&&S.parent.arguments.includes(S)&&u(S.parent.callee,t))}function x(S){let I=`__PLACEHOLDER__${Math.random()}`,A=S.quasis.map(j=>n.getText(j).slice(1,j.tail?-1:-2)).join(I),T=A.match(ua);if(!T)return;let h=T[0],b=n.lines[n.getLocFromIndex(S.range[0]).line-1];if(!b)return;let P=b.match(ca)?.[1]??"",N;typeof o=="string"?N=o:typeof o=="number"?N=" ".repeat(o):N=P.startsWith(" ")?" ":" ";let R=p(A).replace(new RegExp(`^${h}|${h}[ ]*$`,"g"),""),d=h+c(R,1,P+N)+h+P,g=A.includes(`\r
|
|
38
38
|
`)?`\r
|
package/dist/extended-lint.mjs
CHANGED
|
@@ -32,7 +32,7 @@ const ${e}: FC<${u}> = ({ ${c} }) => {
|
|
|
32
32
|
|
|
33
33
|
${y}`)),E.push(m.replaceText(s,C)),E}}]})}function na(e,n,r){let t=e.arguments[0];if(!t||t.type!==_.JSXElement&&t.type!==_.JSXFragment)return;let s=t,o=jr(s,n);if(!o.hasUnstable)return;let i=Qo(s),p=Lr(s,[],n),c=s.type===_.JSXElement?$r(s,n):null,a=o.problematicProps.length===1?`prop "${o.problematicProps[0]}"`:`props "${o.problematicProps.join('", "')}"`;r.report({node:s,messageId:"unstableValueInMap",data:{problematicProps:a},suggest:[{messageId:"extractComponent",data:{componentName:i},fix:u=>{let m=Mr(i,s,[],p,n),y=ea(i,p,c),C=e;for(;C.parent.type!==_.Program&&!(C.type===_.FunctionDeclaration||C.type===_.VariableDeclarator&&C.init&&(C.init.type===_.ArrowFunctionExpression||C.init.type===_.FunctionExpression));)C=C.parent;let f=[];return f.push(u.insertTextAfter(C,`
|
|
34
34
|
|
|
35
|
-
${m}`)),f.push(u.replaceText(s,y)),f}}]})}import{ESLintUtils as ra,TSESTree as ia}from"@typescript-eslint/utils";var sa=ra.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),_r="require-description",oa=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,aa=/^eslint-disable-(next-)?line$/u,la=sa({name:_r,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,[n]){let r=e.sourceCode,t=new Set(n.ignore||[]);return{Program(){for(let s of r.getAllComments()){let o=pa(s);o!=null&&(t.has(o.kind)||o.description||e.report({loc:fa(s.loc),messageId:"missingDescription"}))}}}}}),Ur={name:_r,rule:la};function pa(e){let{text:n,description:r}=ua(e.value);if(!n)return null;let t=oa.exec(n);if(!t)return null;let s=t[1];if(!s)return null;let o=aa.test(s);if(e.type===ia.AST_TOKEN_TYPES.Line&&!o||o&&e.loc.start.line!==e.loc.end.line)return null;let i=n.slice(t.index+s.length);return{kind:s,value:i.trim(),description:r}}var ca=/\s-{2,}\s/u;function ua(e){let n=e.split(ca);return{text:n[0]?.trim(),description:n.length>1?n[1]?.trim()??null:null}}function fa(e){return{start:{line:e.start.line,column:-1},end:e.end}}import{AST_NODE_TYPES as ne}from"@typescript-eslint/utils";import{z as $e}from"zod/v4";var ma=$e.object({varsToCheck:$e.array($e.object({selector:$e.string().optional(),fromFnCall:$e.string().optional(),prop:$e.string().or($e.array($e.string())),errorMsg:$e.string().optional()}))}),yn=q({name:"require-reads-to-var-prop",meta:{type:"suggestion",docs:{description:"Require specific properties from variables to be read or ensure the variable is passed to functions/components"},messages:{propNotRead:'"{{fnName}}" requires reads to the prop "{{prop}}". {{customMsg}}',propsNotRead:'"{{fnName}}" requires reads to the props {{props}}. {{customMsg}}'},schema:[B(ma)]},defaultOptions:[{varsToCheck:[]}],create(e,[n]){let r=new Map;function t(i,p,c,a){let u=new Set;for(let y of i.properties)y.type===ne.Property&&y.key.type===ne.Identifier&&u.add(y.key.name);let m=p.filter(y=>!u.has(y));if(m.length>0)if(m.length===1)e.report({node:i,messageId:"propNotRead",data:{prop:m[0],fnName:a,customMsg:c||""}});else{let y=m.map(C=>`"${C}"`).join(", ");e.report({node:i,messageId:"propsNotRead",data:{props:y,fnName:a,customMsg:c||""}})}}function s(i){if(i.init?.type===ne.CallExpression){if(i.init.callee.type===ne.Identifier)return i.init.callee.name;if(i.init.callee.type===ne.MemberExpression&&i.init.callee.property.type===ne.Identifier)return i.init.callee.object.type===ne.Identifier?`${i.init.callee.object.name}.${i.init.callee.property.name}`:i.init.callee.property.name}return"unknown function"}let o={};for(let i of n.varsToCheck)i.selector&&(o[i.selector]=p=>{if(p.type===ne.VariableDeclarator&&p.id.type===ne.Identifier&&r.set(p.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:p.id,fnName:s(p)}),p.type===ne.VariableDeclarator&&p.id.type===ne.ObjectPattern){let c=Array.isArray(i.prop)?i.prop:[i.prop];t(p.id,c,i.errorMsg,s(p))}});for(let i of n.varsToCheck)if(i.fromFnCall){let p=i.fromFnCall;if(p.startsWith("*.")){let a=`VariableDeclarator > CallExpression > MemberExpression[property.name="${p.slice(2)}"]`;o[a]=u=>{if(u.type!==ne.MemberExpression||u.parent.type!==ne.CallExpression)return;let m=u.parent;if(m.parent.type!==ne.VariableDeclarator)return;let y=m.parent;if(y.id.type===ne.Identifier)r.set(y.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:y.id,fnName:i.fromFnCall||"unknown function"});else if(y.id.type===ne.ObjectPattern){let C=Array.isArray(i.prop)?i.prop:[i.prop];t(y.id,C,i.errorMsg,i.fromFnCall||"unknown function")}}}else if(p.includes(".")){let[c,a]=p.split("."),u=`VariableDeclarator > CallExpression > MemberExpression[object.name="${c}"][property.name="${a}"]`;o[u]=m=>{if(m.type!==ne.MemberExpression||m.parent.type!==ne.CallExpression)return;let y=m.parent;if(y.parent.type!==ne.VariableDeclarator)return;let C=y.parent;if(C.id.type===ne.Identifier)r.set(C.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:C.id,fnName:i.fromFnCall||"unknown function"});else if(C.id.type===ne.ObjectPattern){let f=Array.isArray(i.prop)?i.prop:[i.prop];t(C.id,f,i.errorMsg,i.fromFnCall||"unknown function")}}}else{let c=`VariableDeclarator > CallExpression > Identifier[name="${p}"]`;o[c]=a=>{if(a.type!==ne.Identifier||a.parent.type!==ne.CallExpression)return;let u=a.parent;if(u.parent.type!==ne.VariableDeclarator)return;let m=u.parent;if(m.id.type===ne.Identifier)r.set(m.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:m.id,fnName:i.fromFnCall||"unknown function"});else if(m.id.type===ne.ObjectPattern){let y=Array.isArray(i.prop)?i.prop:[i.prop];t(m.id,y,i.errorMsg,i.fromFnCall||"unknown function")}}}}return{...o,"Program:exit"(){for(let[i,{props:p,errorMsg:c,node:a,fnName:u}]of r){let y=e.sourceCode.getScope(a).set.get(i);if(y){let C=new Set(p);for(let f of y.references){let E=f.identifier,x=E.parent;if(!(x.type===ne.VariableDeclarator&&x.id===E)){if(x.type===ne.MemberExpression&&x.object===E&&x.property.type===ne.Identifier&&C.has(x.property.name)){if(C.delete(x.property.name),C.size===0)break;continue}if(x.type===ne.VariableDeclarator&&x.init===E&&x.id.type===ne.ObjectPattern){for(let S of x.id.properties)S.type===ne.Property&&S.key.type===ne.Identifier&&C.has(S.key.name)&&C.delete(S.key.name);if(C.size===0)break;continue}if(!(x.type===ne.MemberExpression&&x.object===E&&x.property.type===ne.Identifier&&!p.includes(x.property.name))){C.clear();break}}}if(C.size>0){let f=Array.from(C);if(f.length===1)e.report({node:a,messageId:"propNotRead",data:{prop:f[0],fnName:u,customMsg:c||""}});else{let E=f.map(x=>`"${x}"`).join(", ");e.report({node:a,messageId:"propsNotRead",data:{props:E,fnName:u,customMsg:c||""}})}}}}}}}});function Jr(e){return/^use[A-Z0-9]/.test(e)}function gt(e){return e.type==="Identifier"?Jr(e.name):e.type==="MemberExpression"&&!e.computed&>(e.property)?e.object.type==="Identifier":!1}function Vr(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function Xr(e,n){return e.name===n||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===n}function Br(e){return!!(e.parent&&e.parent.callee&&Xr(e.parent.callee,"forwardRef"))}function Hr(e){return!!(e.parent&&e.parent.callee&&Xr(e.parent.callee,"memo"))}function dn(e){for(;e;){let n=qr(e);if(n&&(Vr(n)||gt(n))||Br(e)||Hr(e))return!0;e=e.parent}return!1}function zr(e){return!1}function gn(e){return!1}var ya=/eslint +react-compiler\/react-compiler: +\["error/,Yr={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"},reactCompilerIsEnabled:{type:"boolean"}}}]},create(e){let n=!!e.options[0]?.reactCompilerIsEnabled;if(e.options[0]?.ignoreIfReactCompilerIsEnabled||n){for(let a of e.sourceCode.getAllComments())if(n||ya.test(a.value))return{CallExpression(u){let m=null;u.callee.name==="useMemo"?m="useMemo":u.callee.name==="useCallback"&&(m="useCallback"),m&&e.report({node:u,message:`"${m}" is not necessary when using React Compiler.`})}}}let r=typeof e.getSource=="function"?a=>r(a):a=>e.sourceCode.getText(a),t=typeof e.getScope=="function"?()=>t():a=>e.sourceCode.getScope(a),s=null,o=[],i=[],p=new WeakSet;function c(a){for(let u of a.references){let m=u.identifier.parent;if(m.type==="VariableDeclarator"&&m.init&&m.init.type==="CallExpression"&&m.init.callee&&zr(m.init.callee))for(let y of u.resolved.references)y!==u&&p.add(y.identifier)}}return{onCodePathSegmentStart:a=>i.push(a),onCodePathSegmentEnd:()=>i.pop(),onCodePathStart:()=>o.push(new Map),onCodePathEnd(a,u){let m=o.pop();if(m.size===0)return;let y=new Set;function C(h,b){let{cache:w}=C,P=w.get(h.id),N=new Set(b);if(N.has(h.id)){let l=[...N],R=l.slice(l.indexOf(h.id)+1);for(let d of R)y.add(d);return BigInt("0")}if(N.add(h.id),P!==void 0)return P;if(a.thrownSegments.includes(h))P=BigInt("0");else if(h.prevSegments.length===0)P=BigInt("1");else{P=BigInt("0");for(let l of h.prevSegments)P+=C(l,N)}return h.reachable&&P===BigInt("0")?w.delete(h.id):w.set(h.id,P),P}function f(h,b){let{cache:w}=f,P=w.get(h.id),N=new Set(b);if(N.has(h.id)){let l=Array.from(N),R=l.slice(l.indexOf(h.id)+1);for(let d of R)y.add(d);return BigInt("0")}if(N.add(h.id),P!==void 0)return P;if(a.thrownSegments.includes(h))P=BigInt("0");else if(h.nextSegments.length===0)P=BigInt("1");else{P=BigInt("0");for(let l of h.nextSegments)P+=f(l,N)}return w.set(h.id,P),P}function E(h){let{cache:b}=E,w=b.get(h.id);if(w===null)return 1/0;if(w!==void 0)return w;if(b.set(h.id,null),h.prevSegments.length===0)w=1;else{w=1/0;for(let P of h.prevSegments){let N=E(P);N<w&&(w=N)}w+=1}return b.set(h.id,w),w}C.cache=new Map,f.cache=new Map,E.cache=new Map;let x=f(a.initialSegment),S=qr(u),I=dn(u),A=S?Vr(S)||gt(S):Br(u)||Hr(u),T=1/0;for(let h of a.finalSegments){if(!h.reachable)continue;let b=E(h);b<T&&(T=b)}for(let[h,b]of m){if(!h.reachable)continue;let w=h.nextSegments.length===0?T<=E(h):T<E(h),P=C(h)*f(h),N=y.has(h.id);for(let l of b)if(N&&!gn(l)&&e.report({node:l,message:`React Hook "${r(l)}" may be executed more than once. Possibly because it is called in a loop. React Hooks must be called in the exact same order in every component render.`}),A){if(u.async&&e.report({node:l,message:`React Hook "${r(l)}" cannot be called in an async function.`}),!N&&P!==x&&!gn(l)){let d=`React Hook "${r(l)}" is called conditionally. React Hooks must be called in the exact same order in every component render.`+(w?" Did you accidentally call a React Hook after an early return?":"");e.report({node:l,message:d})}}else if(u.parent&&(u.parent.type==="MethodDefinition"||u.parent.type==="ClassProperty")&&u.parent.value===u){let R=`React Hook "${r(l)}" 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:l,message:R})}else if(S){let R=`React Hook "${r(l)}" is called in function "${r(S)}" 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:l,message:R})}else if(u.type==="Program"){let R=`React Hook "${r(l)}" 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:l,message:R})}else if(I&&!gn(l)){if(u.parent.type==="CallExpression"&&u.parent.callee.type==="Identifier"&&u.parent.callee.name==="useCallback"){let d=u.parent;if(d.parent.type==="VariableDeclarator"&&Jr(d.parent.id.name))return}let R=`React Hook "${r(l)}" 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:l,message:R})}}},CallExpression(a){if(gt(a.callee)){let u=Wr(o),m=Wr(i),y=u.get(m);y||(y=[],u.set(m,y)),y.push(a.callee)}a.callee.type==="Identifier"&&(a.callee.name==="useEffect"||zr(a.callee))&&a.arguments.length>0&&(s=a)},Identifier(a){s==null&&p.has(a)&&a.parent.type!=="CallExpression"&&e.report({node:a,message:`\`${r(a)}\` is a function created with React Hook "useEffectEvent", and can only be called from the same component. They cannot be assigned to variables or passed down.`})},"CallExpression:exit"(a){a===s&&(s=null)},FunctionDeclaration(a){dn(a)&&c(t(a))},ArrowFunctionExpression(a){dn(a)&&c(t(a))}}}};function qr(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 Wr(e){return e[e.length-1]}import{AST_NODE_TYPES as Se,AST_TOKEN_TYPES as da}from"@typescript-eslint/utils";import*as be from"zod/v4";var ga=/^\s+$/,Sn=/\r?\n/,Sa=/^(\s*)/,Ta=/^(\s*)\S/,ha=/\r?\n/,Ea=be.object({indent:be.union([be.string().regex(ga),be.number().int().min(1)]).optional(),tags:be.array(be.string()).optional(),functions:be.array(be.string()).optional(),comments:be.array(be.string()).optional()}),Tn=q({name:"template-indent",meta:{type:"suggestion",docs:{description:"Fix whitespace-insensitive template indentation"},fixable:"code",schema:[B(Ea)],messages:{improperlyIndented:"Templates should be properly indented."}},defaultOptions:[{}],create(e){let n=e.sourceCode,{comments:r=["HTML","indent"],functions:t=["dedent","stripIndent"],tags:s=["outdent","dedent","gql","sql","html","styled"],indent:o}=e.options[0],i=r.map(S=>S.toLowerCase());function p(S){let I=S.split(Sn),A=I.filter(h=>h.trim()!=="");if(A.length===0)return S;let T=Number.POSITIVE_INFINITY;for(let h of A){let b=h.match(Sa);b&&(T=Math.min(T,b[1]?.length??0))}return!isFinite(T)||T===0?S:I.map(h=>h.slice(T)).join(`
|
|
35
|
+
${m}`)),f.push(u.replaceText(s,y)),f}}]})}import{ESLintUtils as ra,TSESTree as ia}from"@typescript-eslint/utils";var sa=ra.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),_r="require-description",oa=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,aa=/^eslint-disable-(next-)?line$/u,la=sa({name:_r,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,[n]){let r=e.sourceCode,t=new Set(n.ignore||[]);return{Program(){for(let s of r.getAllComments()){let o=pa(s);o!=null&&(t.has(o.kind)||o.description||e.report({loc:fa(s.loc),messageId:"missingDescription"}))}}}}}),Ur={name:_r,rule:la};function pa(e){let{text:n,description:r}=ua(e.value);if(!n)return null;let t=oa.exec(n);if(!t)return null;let s=t[1];if(!s)return null;let o=aa.test(s);if(e.type===ia.AST_TOKEN_TYPES.Line&&!o||o&&e.loc.start.line!==e.loc.end.line)return null;let i=n.slice(t.index+s.length);return{kind:s,value:i.trim(),description:r}}var ca=/\s-{2,}\s/u;function ua(e){let n=e.split(ca);return{text:n[0]?.trim(),description:n.length>1?n[1]?.trim()??null:null}}function fa(e){return{start:{line:e.start.line,column:-1},end:e.end}}import{AST_NODE_TYPES as ne}from"@typescript-eslint/utils";import{z as $e}from"zod/v4";var ma=$e.object({varsToCheck:$e.array($e.object({selector:$e.string().optional(),fromFnCall:$e.string().optional(),prop:$e.string().or($e.array($e.string())),errorMsg:$e.string().optional()}))}),yn=q({name:"require-reads-to-var-prop",meta:{type:"suggestion",docs:{description:"Require specific properties from variables to be read or ensure the variable is passed to functions/components"},messages:{propNotRead:'"{{fnName}}" requires reads to the prop "{{prop}}". {{customMsg}}',propsNotRead:'"{{fnName}}" requires reads to the props {{props}}. {{customMsg}}'},schema:[B(ma)]},defaultOptions:[{varsToCheck:[]}],create(e,[n]){let r=new Map;function t(i,p,c,a){let u=new Set;for(let y of i.properties)y.type===ne.Property&&y.key.type===ne.Identifier&&u.add(y.key.name);let m=p.filter(y=>!u.has(y));if(m.length>0)if(m.length===1)e.report({node:i,messageId:"propNotRead",data:{prop:m[0],fnName:a,customMsg:c||""}});else{let y=m.map(C=>`"${C}"`).join(", ");e.report({node:i,messageId:"propsNotRead",data:{props:y,fnName:a,customMsg:c||""}})}}function s(i){if(i.init?.type===ne.CallExpression){if(i.init.callee.type===ne.Identifier)return i.init.callee.name;if(i.init.callee.type===ne.MemberExpression&&i.init.callee.property.type===ne.Identifier)return i.init.callee.object.type===ne.Identifier?`${i.init.callee.object.name}.${i.init.callee.property.name}`:i.init.callee.property.name}return"unknown function"}let o={};for(let i of n.varsToCheck)i.selector&&(o[i.selector]=p=>{if(p.type===ne.VariableDeclarator&&p.id.type===ne.Identifier&&r.set(p.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:p.id,fnName:s(p)}),p.type===ne.VariableDeclarator&&p.id.type===ne.ObjectPattern){let c=Array.isArray(i.prop)?i.prop:[i.prop];t(p.id,c,i.errorMsg,s(p))}});for(let i of n.varsToCheck)if(i.fromFnCall){let p=i.fromFnCall;if(p.startsWith("*.")){let a=`VariableDeclarator > CallExpression > MemberExpression[property.name="${p.slice(2)}"]`;o[a]=u=>{if(u.type!==ne.MemberExpression||u.parent.type!==ne.CallExpression)return;let m=u.parent;if(m.parent.type!==ne.VariableDeclarator)return;let y=m.parent;if(y.id.type===ne.Identifier)r.set(y.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:y.id,fnName:i.fromFnCall||"unknown function"});else if(y.id.type===ne.ObjectPattern){let C=Array.isArray(i.prop)?i.prop:[i.prop];t(y.id,C,i.errorMsg,i.fromFnCall||"unknown function")}}}else if(p.includes(".")){let[c,a]=p.split("."),u=`VariableDeclarator > CallExpression > MemberExpression[object.name="${c}"][property.name="${a}"]`;o[u]=m=>{if(m.type!==ne.MemberExpression||m.parent.type!==ne.CallExpression)return;let y=m.parent;if(y.parent.type!==ne.VariableDeclarator)return;let C=y.parent;if(C.id.type===ne.Identifier)r.set(C.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:C.id,fnName:i.fromFnCall||"unknown function"});else if(C.id.type===ne.ObjectPattern){let f=Array.isArray(i.prop)?i.prop:[i.prop];t(C.id,f,i.errorMsg,i.fromFnCall||"unknown function")}}}else{let c=`VariableDeclarator > CallExpression > Identifier[name="${p}"]`;o[c]=a=>{if(a.type!==ne.Identifier||a.parent.type!==ne.CallExpression)return;let u=a.parent;if(u.parent.type!==ne.VariableDeclarator)return;let m=u.parent;if(m.id.type===ne.Identifier)r.set(m.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:m.id,fnName:i.fromFnCall||"unknown function"});else if(m.id.type===ne.ObjectPattern){let y=Array.isArray(i.prop)?i.prop:[i.prop];t(m.id,y,i.errorMsg,i.fromFnCall||"unknown function")}}}}return{...o,"Program:exit"(){for(let[i,{props:p,errorMsg:c,node:a,fnName:u}]of r){let y=e.sourceCode.getScope(a).set.get(i);if(y){let C=new Set(p);for(let f of y.references){let E=f.identifier,x=E.parent;if(!(x.type===ne.VariableDeclarator&&x.id===E)){if(x.type===ne.MemberExpression&&x.object===E&&x.property.type===ne.Identifier&&C.has(x.property.name)){if(C.delete(x.property.name),C.size===0)break;continue}if(x.type===ne.VariableDeclarator&&x.init===E&&x.id.type===ne.ObjectPattern){for(let S of x.id.properties)S.type===ne.Property&&S.key.type===ne.Identifier&&C.has(S.key.name)&&C.delete(S.key.name);if(C.size===0)break;continue}if(!(x.type===ne.MemberExpression&&x.object===E&&x.property.type===ne.Identifier&&!p.includes(x.property.name))){C.clear();break}}}if(C.size>0){let f=Array.from(C);if(f.length===1)e.report({node:a,messageId:"propNotRead",data:{prop:f[0],fnName:u,customMsg:c||""}});else{let E=f.map(x=>`"${x}"`).join(", ");e.report({node:a,messageId:"propsNotRead",data:{props:E,fnName:u,customMsg:c||""}})}}}}}}}});function Jr(e){return/^use[A-Z0-9]/.test(e)}function gt(e){return e.type==="Identifier"?Jr(e.name):e.type==="MemberExpression"&&!e.computed&>(e.property)?e.object.type==="Identifier":!1}function Vr(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function Xr(e,n){return e.name===n||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===n}function Br(e){return!!(e.parent&&e.parent.callee&&Xr(e.parent.callee,"forwardRef"))}function Hr(e){return!!(e.parent&&e.parent.callee&&Xr(e.parent.callee,"memo"))}function dn(e){for(;e;){let n=qr(e);if(n&&(Vr(n)||gt(n))||Br(e)||Hr(e))return!0;e=e.parent}return!1}function zr(e){return!1}function gn(e){return!1}var ya=/eslint +react-compiler\/react-compiler: +\["error/,Yr={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"},reactCompilerIsEnabled:{type:"boolean"}}}]},create(e){let n=!!e.options[0]?.reactCompilerIsEnabled;if(n)return{CallExpression(a){let u=null;a.callee.name==="useMemo"?u="useMemo":a.callee.name==="useCallback"&&(u="useCallback"),u&&e.report({node:a,message:`"${u}" is not necessary when using React Compiler.`})}};if(e.options[0]?.ignoreIfReactCompilerIsEnabled||n){for(let a of e.sourceCode.getAllComments())if(ya.test(a.value))return{CallExpression(u){let m=null;u.callee.name==="useMemo"?m="useMemo":u.callee.name==="useCallback"&&(m="useCallback"),m&&e.report({node:u,message:`"${m}" is not necessary when using React Compiler.`})}}}let r=typeof e.getSource=="function"?a=>r(a):a=>e.sourceCode.getText(a),t=typeof e.getScope=="function"?()=>t():a=>e.sourceCode.getScope(a),s=null,o=[],i=[],p=new WeakSet;function c(a){for(let u of a.references){let m=u.identifier.parent;if(m.type==="VariableDeclarator"&&m.init&&m.init.type==="CallExpression"&&m.init.callee&&zr(m.init.callee))for(let y of u.resolved.references)y!==u&&p.add(y.identifier)}}return{onCodePathSegmentStart:a=>i.push(a),onCodePathSegmentEnd:()=>i.pop(),onCodePathStart:()=>o.push(new Map),onCodePathEnd(a,u){let m=o.pop();if(m.size===0)return;let y=new Set;function C(h,b){let{cache:w}=C,P=w.get(h.id),N=new Set(b);if(N.has(h.id)){let l=[...N],R=l.slice(l.indexOf(h.id)+1);for(let d of R)y.add(d);return BigInt("0")}if(N.add(h.id),P!==void 0)return P;if(a.thrownSegments.includes(h))P=BigInt("0");else if(h.prevSegments.length===0)P=BigInt("1");else{P=BigInt("0");for(let l of h.prevSegments)P+=C(l,N)}return h.reachable&&P===BigInt("0")?w.delete(h.id):w.set(h.id,P),P}function f(h,b){let{cache:w}=f,P=w.get(h.id),N=new Set(b);if(N.has(h.id)){let l=Array.from(N),R=l.slice(l.indexOf(h.id)+1);for(let d of R)y.add(d);return BigInt("0")}if(N.add(h.id),P!==void 0)return P;if(a.thrownSegments.includes(h))P=BigInt("0");else if(h.nextSegments.length===0)P=BigInt("1");else{P=BigInt("0");for(let l of h.nextSegments)P+=f(l,N)}return w.set(h.id,P),P}function E(h){let{cache:b}=E,w=b.get(h.id);if(w===null)return 1/0;if(w!==void 0)return w;if(b.set(h.id,null),h.prevSegments.length===0)w=1;else{w=1/0;for(let P of h.prevSegments){let N=E(P);N<w&&(w=N)}w+=1}return b.set(h.id,w),w}C.cache=new Map,f.cache=new Map,E.cache=new Map;let x=f(a.initialSegment),S=qr(u),I=dn(u),A=S?Vr(S)||gt(S):Br(u)||Hr(u),T=1/0;for(let h of a.finalSegments){if(!h.reachable)continue;let b=E(h);b<T&&(T=b)}for(let[h,b]of m){if(!h.reachable)continue;let w=h.nextSegments.length===0?T<=E(h):T<E(h),P=C(h)*f(h),N=y.has(h.id);for(let l of b)if(N&&!gn(l)&&e.report({node:l,message:`React Hook "${r(l)}" may be executed more than once. Possibly because it is called in a loop. React Hooks must be called in the exact same order in every component render.`}),A){if(u.async&&e.report({node:l,message:`React Hook "${r(l)}" cannot be called in an async function.`}),!N&&P!==x&&!gn(l)){let d=`React Hook "${r(l)}" is called conditionally. React Hooks must be called in the exact same order in every component render.`+(w?" Did you accidentally call a React Hook after an early return?":"");e.report({node:l,message:d})}}else if(u.parent&&(u.parent.type==="MethodDefinition"||u.parent.type==="ClassProperty")&&u.parent.value===u){let R=`React Hook "${r(l)}" 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:l,message:R})}else if(S){let R=`React Hook "${r(l)}" is called in function "${r(S)}" 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:l,message:R})}else if(u.type==="Program"){let R=`React Hook "${r(l)}" 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:l,message:R})}else if(I&&!gn(l)){if(u.parent.type==="CallExpression"&&u.parent.callee.type==="Identifier"&&u.parent.callee.name==="useCallback"){let d=u.parent;if(d.parent.type==="VariableDeclarator"&&Jr(d.parent.id.name))return}let R=`React Hook "${r(l)}" 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:l,message:R})}}},CallExpression(a){if(gt(a.callee)){let u=Wr(o),m=Wr(i),y=u.get(m);y||(y=[],u.set(m,y)),y.push(a.callee)}a.callee.type==="Identifier"&&(a.callee.name==="useEffect"||zr(a.callee))&&a.arguments.length>0&&(s=a)},Identifier(a){s==null&&p.has(a)&&a.parent.type!=="CallExpression"&&e.report({node:a,message:`\`${r(a)}\` is a function created with React Hook "useEffectEvent", and can only be called from the same component. They cannot be assigned to variables or passed down.`})},"CallExpression:exit"(a){a===s&&(s=null)},FunctionDeclaration(a){dn(a)&&c(t(a))},ArrowFunctionExpression(a){dn(a)&&c(t(a))}}}};function qr(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 Wr(e){return e[e.length-1]}import{AST_NODE_TYPES as Se,AST_TOKEN_TYPES as da}from"@typescript-eslint/utils";import*as be from"zod/v4";var ga=/^\s+$/,Sn=/\r?\n/,Sa=/^(\s*)/,Ta=/^(\s*)\S/,ha=/\r?\n/,Ea=be.object({indent:be.union([be.string().regex(ga),be.number().int().min(1)]).optional(),tags:be.array(be.string()).optional(),functions:be.array(be.string()).optional(),comments:be.array(be.string()).optional()}),Tn=q({name:"template-indent",meta:{type:"suggestion",docs:{description:"Fix whitespace-insensitive template indentation"},fixable:"code",schema:[B(Ea)],messages:{improperlyIndented:"Templates should be properly indented."}},defaultOptions:[{}],create(e){let n=e.sourceCode,{comments:r=["HTML","indent"],functions:t=["dedent","stripIndent"],tags:s=["outdent","dedent","gql","sql","html","styled"],indent:o}=e.options[0],i=r.map(S=>S.toLowerCase());function p(S){let I=S.split(Sn),A=I.filter(h=>h.trim()!=="");if(A.length===0)return S;let T=Number.POSITIVE_INFINITY;for(let h of A){let b=h.match(Sa);b&&(T=Math.min(T,b[1]?.length??0))}return!isFinite(T)||T===0?S:I.map(h=>h.slice(T)).join(`
|
|
36
36
|
`)}function c(S,I,A){return S.split(Sn).map(h=>h.trim()===""?h:A.repeat(I)+h).join(`
|
|
37
37
|
`)}function a(S){if(S.type===Se.Identifier)return S.name;if(S.type===Se.MemberExpression){let I=S.object.type===Se.Identifier?S.object.name:null,A=S.property.type===Se.Identifier?S.property.name:null;return I&&A?`${I}.${A}`:A}return null}function u(S,I){if(!S)return!1;for(let A of I)if(A.includes(".")){let T=A.split(".");if(S.type===Se.MemberExpression&&S.object.type===Se.Identifier&&S.property.type===Se.Identifier&&S.object.name===T[0]&&S.property.name===T[1])return!0}else if(S.type===Se.Identifier&&S.name===A)return!0;return!1}function m(S,I){let A=S.parent;if(A.type!==Se.TaggedTemplateExpression)return!1;let T=a(A.tag);return T?I.includes(T):!1}function y(S,I){if(!S||S.type!==Se.CallExpression)return!1;let{method:A,argumentsLength:T,optionalCall:h=!0,optionalMember:b=!0}=I;return T!==void 0&&S.arguments.length!==T||!h&&S.optional||S.callee.type!==Se.MemberExpression||!b&&S.callee.optional||S.callee.property.type!==Se.Identifier?!1:S.callee.property.name===A}function C(S,I){if(!S||S.type!==Se.CallExpression)return!1;let{name:A,argumentsLength:T,optionalCall:h=!0}=I;return T!==void 0&&S.arguments.length!==T||!h&&S.optional||S.callee.type!==Se.Identifier?!1:S.callee.name===A}function f(S){return y(S.parent,{method:"toMatchInlineSnapshot",argumentsLength:1,optionalCall:!1,optionalMember:!1})&&S.parent.type===Se.CallExpression&&S.parent.arguments[0]===S&&C(S.parent.callee.type===Se.MemberExpression?S.parent.callee.object:null,{name:"expect",argumentsLength:1,optionalCall:!1,optionalMember:!1})}function E(S){if(i.length>0){let I=n.getTokenBefore(S,{includeComments:!0});if(I?.type===da.Block&&i.includes(I.value.trim().toLowerCase()))return!0}return!!(f(S)||s.length>0&&m(S,s)||t.length>0&&S.parent.type===Se.CallExpression&&S.parent.arguments.includes(S)&&u(S.parent.callee,t))}function x(S){let I=`__PLACEHOLDER__${Math.random()}`,A=S.quasis.map(j=>n.getText(j).slice(1,j.tail?-1:-2)).join(I),T=A.match(ha);if(!T)return;let h=T[0],b=n.lines[n.getLocFromIndex(S.range[0]).line-1];if(!b)return;let P=b.match(Ta)?.[1]??"",N;typeof o=="string"?N=o:typeof o=="number"?N=" ".repeat(o):N=P.startsWith(" ")?" ":" ";let R=p(A).replace(new RegExp(`^${h}|${h}[ ]*$`,"g"),""),d=h+c(R,1,P+N)+h+P,g=A.includes(`\r
|
|
38
38
|
`)?`\r
|