@ls-stack/extended-lint 0.90.3 → 0.91.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/extended-lint.js +1 -1
- package/dist/extended-lint.mjs +1 -1
- package/package.json +5 -2
package/dist/extended-lint.js
CHANGED
|
@@ -32,7 +32,7 @@ const ${e}: FC<${m}> = ({ ${l} }) => {
|
|
|
32
32
|
|
|
33
33
|
${u}`)),g.push(y.replaceText(s,d)),g}}]})}function nl(e,t,r){let n=e.arguments[0];if(!n||n.type!==V.AST_NODE_TYPES.JSXElement&&n.type!==V.AST_NODE_TYPES.JSXFragment)return;let s=n,o=Si(s,t);if(!o.hasUnstable)return;let i=Qa(s),a=Ti(s,[],t),l=s.type===V.AST_NODE_TYPES.JSXElement?hi(s,t):null,p=o.problematicProps.length===1?`prop "${o.problematicProps[0]}"`:`props "${o.problematicProps.join('", "')}"`;r.report({node:s,messageId:"unstableValueInMap",data:{problematicProps:p},suggest:[{messageId:"extractComponent",data:{componentName:i},fix:m=>{let y=Ei(i,s,[],a,t),u=el(i,a,l),d=e;for(;d.parent.type!==V.AST_NODE_TYPES.Program&&!(d.type===V.AST_NODE_TYPES.FunctionDeclaration||d.type===V.AST_NODE_TYPES.VariableDeclarator&&d.init&&(d.init.type===V.AST_NODE_TYPES.ArrowFunctionExpression||d.init.type===V.AST_NODE_TYPES.FunctionExpression));)d=d.parent;let c=[];return c.push(m.insertTextAfter(d,`
|
|
34
34
|
|
|
35
|
-
${y}`)),c.push(m.replaceText(s,u)),c}}]})}var Mt=require("@typescript-eslint/utils"),rl=Mt.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),bi="require-description",il=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,sl=/^eslint-disable-(next-)?line$/u,ol=rl({name:bi,meta:{type:"problem",docs:{description:"Require descriptions for eslint directives."},messages:{missingDescription:"Unexpected undescribed directive comment. Include descriptions to explain why the comment is necessary."},schema:[{type:"object",properties:{ignore:{type:"array",items:{type:"string",enum:["eslint","eslint-disable","eslint-disable-line","eslint-disable-next-line","eslint-enable","eslint-env","exported","global","globals"]},additionalItems:!1,uniqueItems:!0}},additionalProperties:!1}]},defaultOptions:[{ignore:[]}],create(e,[t]){let r=e.sourceCode,n=new Set(t.ignore||[]);return{Program(){for(let s of r.getAllComments()){let o=al(s);o!=null&&(n.has(o.kind)||o.description||e.report({loc:cl(s.loc),messageId:"missingDescription"}))}}}}}),xi={name:bi,rule:ol};function al(e){let{text:t,description:r}=pl(e.value);if(!t)return null;let n=il.exec(t);if(!n)return null;let s=n[1];if(!s)return null;let o=sl.test(s);if(e.type===Mt.TSESTree.AST_TOKEN_TYPES.Line&&!o||o&&e.loc.start.line!==e.loc.end.line)return null;let i=t.slice(n.index+s.length);return{kind:s,value:i.trim(),description:r}}var ll=/\s-{2,}\s/u;function pl(e){let t=e.split(ll);return{text:t[0]?.trim(),description:t.length>1?t[1]?.trim()??null:null}}function cl(e){return{start:{line:e.start.line,column:-1},end:e.end}}var ne=require("@typescript-eslint/utils"),We=require("zod/v4");var ul=We.z.object({varsToCheck:We.z.array(We.z.object({selector:We.z.string().optional(),fromFnCall:We.z.string().optional(),prop:We.z.string().or(We.z.array(We.z.string())),errorMsg:We.z.string().optional()}))}),Jn=z({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:[U(ul)]},defaultOptions:[{varsToCheck:[]}],create(e,[t]){let r=new Map;function n(i,a,l,p){let m=new Set;for(let u of i.properties)u.type===ne.AST_NODE_TYPES.Property&&u.key.type===ne.AST_NODE_TYPES.Identifier&&m.add(u.key.name);let y=a.filter(u=>!m.has(u));if(y.length>0)if(y.length===1)e.report({node:i,messageId:"propNotRead",data:{prop:y[0],fnName:p,customMsg:l||""}});else{let u=y.map(d=>`"${d}"`).join(", ");e.report({node:i,messageId:"propsNotRead",data:{props:u,fnName:p,customMsg:l||""}})}}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 t.varsToCheck)i.selector&&(o[i.selector]=a=>{if(a.type===ne.AST_NODE_TYPES.VariableDeclarator&&a.id.type===ne.AST_NODE_TYPES.Identifier&&r.set(a.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:a.id,fnName:s(a)}),a.type===ne.AST_NODE_TYPES.VariableDeclarator&&a.id.type===ne.AST_NODE_TYPES.ObjectPattern){let l=Array.isArray(i.prop)?i.prop:[i.prop];n(a.id,l,i.errorMsg,s(a))}});for(let i of t.varsToCheck)if(i.fromFnCall){let a=i.fromFnCall;if(a.startsWith("*.")){let p=`VariableDeclarator > CallExpression > MemberExpression[property.name="${a.slice(2)}"]`;o[p]=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 u=y.parent;if(u.id.type===ne.AST_NODE_TYPES.Identifier)r.set(u.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:u.id,fnName:i.fromFnCall||"unknown function"});else if(u.id.type===ne.AST_NODE_TYPES.ObjectPattern){let d=Array.isArray(i.prop)?i.prop:[i.prop];n(u.id,d,i.errorMsg,i.fromFnCall||"unknown function")}}}else if(a.includes(".")){let[l,p]=a.split("."),m=`VariableDeclarator > CallExpression > MemberExpression[object.name="${l}"][property.name="${p}"]`;o[m]=y=>{if(y.type!==ne.AST_NODE_TYPES.MemberExpression||y.parent.type!==ne.AST_NODE_TYPES.CallExpression)return;let u=y.parent;if(u.parent.type!==ne.AST_NODE_TYPES.VariableDeclarator)return;let d=u.parent;if(d.id.type===ne.AST_NODE_TYPES.Identifier)r.set(d.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:d.id,fnName:i.fromFnCall||"unknown function"});else if(d.id.type===ne.AST_NODE_TYPES.ObjectPattern){let c=Array.isArray(i.prop)?i.prop:[i.prop];n(d.id,c,i.errorMsg,i.fromFnCall||"unknown function")}}}else{let l=`VariableDeclarator > CallExpression > Identifier[name="${a}"]`;o[l]=p=>{if(p.type!==ne.AST_NODE_TYPES.Identifier||p.parent.type!==ne.AST_NODE_TYPES.CallExpression)return;let m=p.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 u=Array.isArray(i.prop)?i.prop:[i.prop];n(y.id,u,i.errorMsg,i.fromFnCall||"unknown function")}}}}return{...o,"Program:exit"(){for(let[i,{props:a,errorMsg:l,node:p,fnName:m}]of r){let u=e.sourceCode.getScope(p).set.get(i);if(u){let d=new Set(a);for(let c of u.references){let g=c.identifier,h=g.parent;if(!(h.type===ne.AST_NODE_TYPES.VariableDeclarator&&h.id===g)){if(h.type===ne.AST_NODE_TYPES.MemberExpression&&h.object===g&&h.property.type===ne.AST_NODE_TYPES.Identifier&&d.has(h.property.name)){if(d.delete(h.property.name),d.size===0)break;continue}if(h.type===ne.AST_NODE_TYPES.VariableDeclarator&&h.init===g&&h.id.type===ne.AST_NODE_TYPES.ObjectPattern){for(let S of h.id.properties)S.type===ne.AST_NODE_TYPES.Property&&S.key.type===ne.AST_NODE_TYPES.Identifier&&d.has(S.key.name)&&d.delete(S.key.name);if(d.size===0)break;continue}if(!(h.type===ne.AST_NODE_TYPES.MemberExpression&&h.object===g&&h.property.type===ne.AST_NODE_TYPES.Identifier&&!a.includes(h.property.name))){d.clear();break}}}if(d.size>0){let c=Array.from(d);if(c.length===1)e.report({node:p,messageId:"propNotRead",data:{prop:c[0],fnName:m,customMsg:l||""}});else{let g=c.map(h=>`"${h}"`).join(", ");e.report({node:p,messageId:"propsNotRead",data:{props:g,fnName:m,customMsg:l||""}})}}}}}}}});function Fi(e){return/^use[A-Z0-9]/.test(e)}function $t(e){return e.type==="Identifier"?Fi(e.name):e.type==="MemberExpression"&&!e.computed&&$t(e.property)?e.object.type==="Identifier":!1}function vi(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function Ri(e,t){return e.name===t||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===t}function Ni(e){return!!(e.parent&&e.parent.callee&&Ri(e.parent.callee,"forwardRef"))}function ki(e){return!!(e.parent&&e.parent.callee&&Ri(e.parent.callee,"memo"))}function Xn(e){for(;e;){let t=Oi(e);if(t&&(vi(t)||$t(t))||Ni(e)||ki(e))return!0;e=e.parent}return!1}function Ci(e){return!1}function Bn(e){return!1}var fl=/eslint +react-compiler\/react-compiler: +\["error/;function Ii(e){let t=null;if((e.type==="FunctionDeclaration"||e.type==="FunctionExpression"||e.type==="ArrowFunctionExpression"&&e.body.type==="BlockStatement")&&(t=e.body),!t||t.body.length===0)return!1;let r=t.body[0];return r.type==="ExpressionStatement"&&r.expression.type==="Literal"&&r.expression.value==="use no memo"}function Ai(e){let t=e.parent;for(;t;){if(t.type==="FunctionDeclaration"||t.type==="FunctionExpression"||t.type==="ArrowFunctionExpression")return t;t=t.parent}return null}var Pi={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 t=!!e.options[0]?.reactCompilerIsEnabled;if(t)return{CallExpression(p){let m=null;if(p.callee.name==="useMemo"?m="useMemo":p.callee.name==="useCallback"&&(m="useCallback"),m){let y=Ai(p);if(y&&Ii(y))return;e.report({node:p,message:`"${m}" is not necessary when using React Compiler.`})}}};if(e.options[0]?.ignoreIfReactCompilerIsEnabled||t){for(let p of e.sourceCode.getAllComments())if(fl.test(p.value))return{CallExpression(m){let y=null;if(m.callee.name==="useMemo"?y="useMemo":m.callee.name==="useCallback"&&(y="useCallback"),y){let u=Ai(m);if(u&&Ii(u))return;e.report({node:m,message:`"${y}" is not necessary when using React Compiler.`})}}}}let r=typeof e.getSource=="function"?p=>r(p):p=>e.sourceCode.getText(p),n=typeof e.getScope=="function"?()=>n():p=>e.sourceCode.getScope(p),s=null,o=[],i=[],a=new WeakSet;function l(p){for(let m of p.references){let y=m.identifier.parent;if(y.type==="VariableDeclarator"&&y.init&&y.init.type==="CallExpression"&&y.init.callee&&Ci(y.init.callee))for(let u of m.resolved.references)u!==m&&a.add(u.identifier)}}return{onCodePathSegmentStart:p=>i.push(p),onCodePathSegmentEnd:()=>i.pop(),onCodePathStart:()=>o.push(new Map),onCodePathEnd(p,m){let y=o.pop();if(y.size===0)return;let u=new Set;function d(b,C){let{cache:w}=d,N=w.get(b.id),k=new Set(C);if(k.has(b.id)){let O=[...k],f=O.slice(O.indexOf(b.id)+1);for(let x of f)u.add(x);return BigInt("0")}if(k.add(b.id),N!==void 0)return N;if(p.thrownSegments.includes(b))N=BigInt("0");else if(b.prevSegments.length===0)N=BigInt("1");else{N=BigInt("0");for(let O of b.prevSegments)N+=d(O,k)}return b.reachable&&N===BigInt("0")?w.delete(b.id):w.set(b.id,N),N}function c(b,C){let{cache:w}=c,N=w.get(b.id),k=new Set(C);if(k.has(b.id)){let O=Array.from(k),f=O.slice(O.indexOf(b.id)+1);for(let x of f)u.add(x);return BigInt("0")}if(k.add(b.id),N!==void 0)return N;if(p.thrownSegments.includes(b))N=BigInt("0");else if(b.nextSegments.length===0)N=BigInt("1");else{N=BigInt("0");for(let O of b.nextSegments)N+=c(O,k)}return w.set(b.id,N),N}function g(b){let{cache:C}=g,w=C.get(b.id);if(w===null)return 1/0;if(w!==void 0)return w;if(C.set(b.id,null),b.prevSegments.length===0)w=1;else{w=1/0;for(let N of b.prevSegments){let k=g(N);k<w&&(w=k)}w+=1}return C.set(b.id,w),w}d.cache=new Map,c.cache=new Map,g.cache=new Map;let h=c(p.initialSegment),S=Oi(m),I=Xn(m),A=S?vi(S)||$t(S):Ni(m)||ki(m),T=1/0;for(let b of p.finalSegments){if(!b.reachable)continue;let C=g(b);C<T&&(T=C)}for(let[b,C]of y){if(!b.reachable)continue;let w=b.nextSegments.length===0?T<=g(b):T<g(b),N=d(b)*c(b),k=u.has(b.id);for(let O of C)if(k&&!Bn(O)&&e.report({node:O,message:`React Hook "${r(O)}" 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(m.async&&e.report({node:O,message:`React Hook "${r(O)}" cannot be called in an async function.`}),!k&&N!==h&&!Bn(O)){let x=`React Hook "${r(O)}" 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:O,message:x})}}else if(m.parent&&(m.parent.type==="MethodDefinition"||m.parent.type==="ClassProperty")&&m.parent.value===m){let f=`React Hook "${r(O)}" 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:O,message:f})}else if(S){let f=`React Hook "${r(O)}" 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:O,message:f})}else if(m.type==="Program"){let f=`React Hook "${r(O)}" 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:O,message:f})}else if(I&&!Bn(O)){if(m.parent.type==="CallExpression"&&m.parent.callee.type==="Identifier"&&m.parent.callee.name==="useCallback"){let x=m.parent;if(x.parent.type==="VariableDeclarator"&&Fi(x.parent.id.name))return}let f=`React Hook "${r(O)}" 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:O,message:f})}}},CallExpression(p){if($t(p.callee)){let m=wi(o),y=wi(i),u=m.get(y);u||(u=[],m.set(y,u)),u.push(p.callee)}p.callee.type==="Identifier"&&(p.callee.name==="useEffect"||Ci(p.callee))&&p.arguments.length>0&&(s=p)},Identifier(p){s==null&&a.has(p)&&p.parent.type!=="CallExpression"&&e.report({node:p,message:`\`${r(p)}\` 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"(p){p===s&&(s=null)},FunctionDeclaration(p){Xn(p)&&l(n(p))},ArrowFunctionExpression(p){Xn(p)&&l(n(p))}}}};function Oi(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 wi(e){return e[e.length-1]}var Ee=require("@typescript-eslint/utils"),Ie=Re(require("zod/v4"));var ml=/^\s+$/,Hn=/\r?\n/,yl=/^(\s*)/,dl=/^(\s*)\S/,gl=/\r?\n/,Sl=Ie.object({indent:Ie.union([Ie.string().regex(ml),Ie.number().int().min(1)]).optional(),tags:Ie.array(Ie.string()).optional(),functions:Ie.array(Ie.string()).optional(),comments:Ie.array(Ie.string()).optional()}),Yn=z({name:"template-indent",meta:{type:"suggestion",docs:{description:"Fix whitespace-insensitive template indentation"},fixable:"code",schema:[U(Sl)],messages:{improperlyIndented:"Templates should be properly indented."}},defaultOptions:[{}],create(e){let t=e.sourceCode,{comments:r=["HTML","indent"],functions:n=["dedent","stripIndent"],tags:s=["outdent","dedent","gql","sql","html","styled"],indent:o}=e.options[0],i=r.map(S=>S.toLowerCase());function a(S){let I=S.split(Hn),A=I.filter(b=>b.trim()!=="");if(A.length===0)return S;let T=Number.POSITIVE_INFINITY;for(let b of A){let C=b.match(yl);C&&(T=Math.min(T,C[1]?.length??0))}return!isFinite(T)||T===0?S:I.map(b=>b.slice(T)).join(`
|
|
35
|
+
${y}`)),c.push(m.replaceText(s,u)),c}}]})}var Mt=require("@typescript-eslint/utils"),rl=Mt.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),bi="require-description",il=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|oxlint-(?:enable|disable(?:(?:-next)?-line)?)|exported|globals?)(?:\s|$)/u,sl=/^(?:eslint|oxlint)-disable-(next-)?line$/u,ol=rl({name:bi,meta:{type:"problem",docs:{description:"Require descriptions for eslint and oxlint 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","oxlint-disable","oxlint-disable-line","oxlint-disable-next-line","oxlint-enable","exported","global","globals"]},additionalItems:!1,uniqueItems:!0}},additionalProperties:!1}]},defaultOptions:[{ignore:[]}],create(e,[t]){let r=e.sourceCode,n=new Set(t.ignore||[]);return{Program(){for(let s of r.getAllComments()){let o=al(s);o!=null&&(n.has(o.kind)||o.description||e.report({loc:cl(s.loc),messageId:"missingDescription"}))}}}}}),xi={name:bi,rule:ol};function al(e){let{text:t,description:r}=pl(e.value);if(!t)return null;let n=il.exec(t);if(!n)return null;let s=n[1];if(!s)return null;let o=sl.test(s);if(e.type===Mt.TSESTree.AST_TOKEN_TYPES.Line&&!o||o&&e.loc.start.line!==e.loc.end.line)return null;let i=t.slice(n.index+s.length);return{kind:s,value:i.trim(),description:r}}var ll=/\s-{2,}\s/u;function pl(e){let t=e.split(ll);return{text:t[0]?.trim(),description:t.length>1?t[1]?.trim()??null:null}}function cl(e){return{start:{line:e.start.line,column:0},end:e.end}}var ne=require("@typescript-eslint/utils"),We=require("zod/v4");var ul=We.z.object({varsToCheck:We.z.array(We.z.object({selector:We.z.string().optional(),fromFnCall:We.z.string().optional(),prop:We.z.string().or(We.z.array(We.z.string())),errorMsg:We.z.string().optional()}))}),Jn=z({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:[U(ul)]},defaultOptions:[{varsToCheck:[]}],create(e,[t]){let r=new Map;function n(i,a,l,p){let m=new Set;for(let u of i.properties)u.type===ne.AST_NODE_TYPES.Property&&u.key.type===ne.AST_NODE_TYPES.Identifier&&m.add(u.key.name);let y=a.filter(u=>!m.has(u));if(y.length>0)if(y.length===1)e.report({node:i,messageId:"propNotRead",data:{prop:y[0],fnName:p,customMsg:l||""}});else{let u=y.map(d=>`"${d}"`).join(", ");e.report({node:i,messageId:"propsNotRead",data:{props:u,fnName:p,customMsg:l||""}})}}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 t.varsToCheck)i.selector&&(o[i.selector]=a=>{if(a.type===ne.AST_NODE_TYPES.VariableDeclarator&&a.id.type===ne.AST_NODE_TYPES.Identifier&&r.set(a.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:a.id,fnName:s(a)}),a.type===ne.AST_NODE_TYPES.VariableDeclarator&&a.id.type===ne.AST_NODE_TYPES.ObjectPattern){let l=Array.isArray(i.prop)?i.prop:[i.prop];n(a.id,l,i.errorMsg,s(a))}});for(let i of t.varsToCheck)if(i.fromFnCall){let a=i.fromFnCall;if(a.startsWith("*.")){let p=`VariableDeclarator > CallExpression > MemberExpression[property.name="${a.slice(2)}"]`;o[p]=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 u=y.parent;if(u.id.type===ne.AST_NODE_TYPES.Identifier)r.set(u.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:u.id,fnName:i.fromFnCall||"unknown function"});else if(u.id.type===ne.AST_NODE_TYPES.ObjectPattern){let d=Array.isArray(i.prop)?i.prop:[i.prop];n(u.id,d,i.errorMsg,i.fromFnCall||"unknown function")}}}else if(a.includes(".")){let[l,p]=a.split("."),m=`VariableDeclarator > CallExpression > MemberExpression[object.name="${l}"][property.name="${p}"]`;o[m]=y=>{if(y.type!==ne.AST_NODE_TYPES.MemberExpression||y.parent.type!==ne.AST_NODE_TYPES.CallExpression)return;let u=y.parent;if(u.parent.type!==ne.AST_NODE_TYPES.VariableDeclarator)return;let d=u.parent;if(d.id.type===ne.AST_NODE_TYPES.Identifier)r.set(d.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:d.id,fnName:i.fromFnCall||"unknown function"});else if(d.id.type===ne.AST_NODE_TYPES.ObjectPattern){let c=Array.isArray(i.prop)?i.prop:[i.prop];n(d.id,c,i.errorMsg,i.fromFnCall||"unknown function")}}}else{let l=`VariableDeclarator > CallExpression > Identifier[name="${a}"]`;o[l]=p=>{if(p.type!==ne.AST_NODE_TYPES.Identifier||p.parent.type!==ne.AST_NODE_TYPES.CallExpression)return;let m=p.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 u=Array.isArray(i.prop)?i.prop:[i.prop];n(y.id,u,i.errorMsg,i.fromFnCall||"unknown function")}}}}return{...o,"Program:exit"(){for(let[i,{props:a,errorMsg:l,node:p,fnName:m}]of r){let u=e.sourceCode.getScope(p).set.get(i);if(u){let d=new Set(a);for(let c of u.references){let g=c.identifier,h=g.parent;if(!(h.type===ne.AST_NODE_TYPES.VariableDeclarator&&h.id===g)){if(h.type===ne.AST_NODE_TYPES.MemberExpression&&h.object===g&&h.property.type===ne.AST_NODE_TYPES.Identifier&&d.has(h.property.name)){if(d.delete(h.property.name),d.size===0)break;continue}if(h.type===ne.AST_NODE_TYPES.VariableDeclarator&&h.init===g&&h.id.type===ne.AST_NODE_TYPES.ObjectPattern){for(let S of h.id.properties)S.type===ne.AST_NODE_TYPES.Property&&S.key.type===ne.AST_NODE_TYPES.Identifier&&d.has(S.key.name)&&d.delete(S.key.name);if(d.size===0)break;continue}if(!(h.type===ne.AST_NODE_TYPES.MemberExpression&&h.object===g&&h.property.type===ne.AST_NODE_TYPES.Identifier&&!a.includes(h.property.name))){d.clear();break}}}if(d.size>0){let c=Array.from(d);if(c.length===1)e.report({node:p,messageId:"propNotRead",data:{prop:c[0],fnName:m,customMsg:l||""}});else{let g=c.map(h=>`"${h}"`).join(", ");e.report({node:p,messageId:"propsNotRead",data:{props:g,fnName:m,customMsg:l||""}})}}}}}}}});function Fi(e){return/^use[A-Z0-9]/.test(e)}function $t(e){return e.type==="Identifier"?Fi(e.name):e.type==="MemberExpression"&&!e.computed&&$t(e.property)?e.object.type==="Identifier":!1}function vi(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function Ri(e,t){return e.name===t||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===t}function Ni(e){return!!(e.parent&&e.parent.callee&&Ri(e.parent.callee,"forwardRef"))}function ki(e){return!!(e.parent&&e.parent.callee&&Ri(e.parent.callee,"memo"))}function Xn(e){for(;e;){let t=Oi(e);if(t&&(vi(t)||$t(t))||Ni(e)||ki(e))return!0;e=e.parent}return!1}function Ci(e){return!1}function Bn(e){return!1}var fl=/eslint +react-compiler\/react-compiler: +\["error/;function Ii(e){let t=null;if((e.type==="FunctionDeclaration"||e.type==="FunctionExpression"||e.type==="ArrowFunctionExpression"&&e.body.type==="BlockStatement")&&(t=e.body),!t||t.body.length===0)return!1;let r=t.body[0];return r.type==="ExpressionStatement"&&r.expression.type==="Literal"&&r.expression.value==="use no memo"}function Ai(e){let t=e.parent;for(;t;){if(t.type==="FunctionDeclaration"||t.type==="FunctionExpression"||t.type==="ArrowFunctionExpression")return t;t=t.parent}return null}var Pi={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 t=!!e.options[0]?.reactCompilerIsEnabled;if(t)return{CallExpression(p){let m=null;if(p.callee.name==="useMemo"?m="useMemo":p.callee.name==="useCallback"&&(m="useCallback"),m){let y=Ai(p);if(y&&Ii(y))return;e.report({node:p,message:`"${m}" is not necessary when using React Compiler.`})}}};if(e.options[0]?.ignoreIfReactCompilerIsEnabled||t){for(let p of e.sourceCode.getAllComments())if(fl.test(p.value))return{CallExpression(m){let y=null;if(m.callee.name==="useMemo"?y="useMemo":m.callee.name==="useCallback"&&(y="useCallback"),y){let u=Ai(m);if(u&&Ii(u))return;e.report({node:m,message:`"${y}" is not necessary when using React Compiler.`})}}}}let r=typeof e.getSource=="function"?p=>r(p):p=>e.sourceCode.getText(p),n=typeof e.getScope=="function"?()=>n():p=>e.sourceCode.getScope(p),s=null,o=[],i=[],a=new WeakSet;function l(p){for(let m of p.references){let y=m.identifier.parent;if(y.type==="VariableDeclarator"&&y.init&&y.init.type==="CallExpression"&&y.init.callee&&Ci(y.init.callee))for(let u of m.resolved.references)u!==m&&a.add(u.identifier)}}return{onCodePathSegmentStart:p=>i.push(p),onCodePathSegmentEnd:()=>i.pop(),onCodePathStart:()=>o.push(new Map),onCodePathEnd(p,m){let y=o.pop();if(y.size===0)return;let u=new Set;function d(b,C){let{cache:w}=d,N=w.get(b.id),k=new Set(C);if(k.has(b.id)){let O=[...k],f=O.slice(O.indexOf(b.id)+1);for(let x of f)u.add(x);return BigInt("0")}if(k.add(b.id),N!==void 0)return N;if(p.thrownSegments.includes(b))N=BigInt("0");else if(b.prevSegments.length===0)N=BigInt("1");else{N=BigInt("0");for(let O of b.prevSegments)N+=d(O,k)}return b.reachable&&N===BigInt("0")?w.delete(b.id):w.set(b.id,N),N}function c(b,C){let{cache:w}=c,N=w.get(b.id),k=new Set(C);if(k.has(b.id)){let O=Array.from(k),f=O.slice(O.indexOf(b.id)+1);for(let x of f)u.add(x);return BigInt("0")}if(k.add(b.id),N!==void 0)return N;if(p.thrownSegments.includes(b))N=BigInt("0");else if(b.nextSegments.length===0)N=BigInt("1");else{N=BigInt("0");for(let O of b.nextSegments)N+=c(O,k)}return w.set(b.id,N),N}function g(b){let{cache:C}=g,w=C.get(b.id);if(w===null)return 1/0;if(w!==void 0)return w;if(C.set(b.id,null),b.prevSegments.length===0)w=1;else{w=1/0;for(let N of b.prevSegments){let k=g(N);k<w&&(w=k)}w+=1}return C.set(b.id,w),w}d.cache=new Map,c.cache=new Map,g.cache=new Map;let h=c(p.initialSegment),S=Oi(m),I=Xn(m),A=S?vi(S)||$t(S):Ni(m)||ki(m),T=1/0;for(let b of p.finalSegments){if(!b.reachable)continue;let C=g(b);C<T&&(T=C)}for(let[b,C]of y){if(!b.reachable)continue;let w=b.nextSegments.length===0?T<=g(b):T<g(b),N=d(b)*c(b),k=u.has(b.id);for(let O of C)if(k&&!Bn(O)&&e.report({node:O,message:`React Hook "${r(O)}" 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(m.async&&e.report({node:O,message:`React Hook "${r(O)}" cannot be called in an async function.`}),!k&&N!==h&&!Bn(O)){let x=`React Hook "${r(O)}" 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:O,message:x})}}else if(m.parent&&(m.parent.type==="MethodDefinition"||m.parent.type==="ClassProperty")&&m.parent.value===m){let f=`React Hook "${r(O)}" 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:O,message:f})}else if(S){let f=`React Hook "${r(O)}" 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:O,message:f})}else if(m.type==="Program"){let f=`React Hook "${r(O)}" 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:O,message:f})}else if(I&&!Bn(O)){if(m.parent.type==="CallExpression"&&m.parent.callee.type==="Identifier"&&m.parent.callee.name==="useCallback"){let x=m.parent;if(x.parent.type==="VariableDeclarator"&&Fi(x.parent.id.name))return}let f=`React Hook "${r(O)}" 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:O,message:f})}}},CallExpression(p){if($t(p.callee)){let m=wi(o),y=wi(i),u=m.get(y);u||(u=[],m.set(y,u)),u.push(p.callee)}p.callee.type==="Identifier"&&(p.callee.name==="useEffect"||Ci(p.callee))&&p.arguments.length>0&&(s=p)},Identifier(p){s==null&&a.has(p)&&p.parent.type!=="CallExpression"&&e.report({node:p,message:`\`${r(p)}\` 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"(p){p===s&&(s=null)},FunctionDeclaration(p){Xn(p)&&l(n(p))},ArrowFunctionExpression(p){Xn(p)&&l(n(p))}}}};function Oi(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 wi(e){return e[e.length-1]}var Ee=require("@typescript-eslint/utils"),Ie=Re(require("zod/v4"));var ml=/^\s+$/,Hn=/\r?\n/,yl=/^(\s*)/,dl=/^(\s*)\S/,gl=/\r?\n/,Sl=Ie.object({indent:Ie.union([Ie.string().regex(ml),Ie.number().int().min(1)]).optional(),tags:Ie.array(Ie.string()).optional(),functions:Ie.array(Ie.string()).optional(),comments:Ie.array(Ie.string()).optional()}),Yn=z({name:"template-indent",meta:{type:"suggestion",docs:{description:"Fix whitespace-insensitive template indentation"},fixable:"code",schema:[U(Sl)],messages:{improperlyIndented:"Templates should be properly indented."}},defaultOptions:[{}],create(e){let t=e.sourceCode,{comments:r=["HTML","indent"],functions:n=["dedent","stripIndent"],tags:s=["outdent","dedent","gql","sql","html","styled"],indent:o}=e.options[0],i=r.map(S=>S.toLowerCase());function a(S){let I=S.split(Hn),A=I.filter(b=>b.trim()!=="");if(A.length===0)return S;let T=Number.POSITIVE_INFINITY;for(let b of A){let C=b.match(yl);C&&(T=Math.min(T,C[1]?.length??0))}return!isFinite(T)||T===0?S:I.map(b=>b.slice(T)).join(`
|
|
36
36
|
`)}function l(S,I,A){return S.split(Hn).map(b=>b.trim()===""?b:A.repeat(I)+b).join(`
|
|
37
37
|
`)}function p(S){if(S.type===Ee.AST_NODE_TYPES.Identifier)return S.name;if(S.type===Ee.AST_NODE_TYPES.MemberExpression){let I=S.object.type===Ee.AST_NODE_TYPES.Identifier?S.object.name:null,A=S.property.type===Ee.AST_NODE_TYPES.Identifier?S.property.name:null;return I&&A?`${I}.${A}`:A}return null}function m(S,I){if(!S)return!1;for(let A of I)if(A.includes(".")){let T=A.split(".");if(S.type===Ee.AST_NODE_TYPES.MemberExpression&&S.object.type===Ee.AST_NODE_TYPES.Identifier&&S.property.type===Ee.AST_NODE_TYPES.Identifier&&S.object.name===T[0]&&S.property.name===T[1])return!0}else if(S.type===Ee.AST_NODE_TYPES.Identifier&&S.name===A)return!0;return!1}function y(S,I){let A=S.parent;if(A.type!==Ee.AST_NODE_TYPES.TaggedTemplateExpression)return!1;let T=p(A.tag);return T?I.includes(T):!1}function u(S,I){if(!S||S.type!==Ee.AST_NODE_TYPES.CallExpression)return!1;let{method:A,argumentsLength:T,optionalCall:b=!0,optionalMember:C=!0}=I;return T!==void 0&&S.arguments.length!==T||!b&&S.optional||S.callee.type!==Ee.AST_NODE_TYPES.MemberExpression||!C&&S.callee.optional||S.callee.property.type!==Ee.AST_NODE_TYPES.Identifier?!1:S.callee.property.name===A}function d(S,I){if(!S||S.type!==Ee.AST_NODE_TYPES.CallExpression)return!1;let{name:A,argumentsLength:T,optionalCall:b=!0}=I;return T!==void 0&&S.arguments.length!==T||!b&&S.optional||S.callee.type!==Ee.AST_NODE_TYPES.Identifier?!1:S.callee.name===A}function c(S){return u(S.parent,{method:"toMatchInlineSnapshot",argumentsLength:1,optionalCall:!1,optionalMember:!1})&&S.parent.type===Ee.AST_NODE_TYPES.CallExpression&&S.parent.arguments[0]===S&&d(S.parent.callee.type===Ee.AST_NODE_TYPES.MemberExpression?S.parent.callee.object:null,{name:"expect",argumentsLength:1,optionalCall:!1,optionalMember:!1})}function g(S){if(i.length>0){let I=t.getTokenBefore(S,{includeComments:!0});if(I?.type===Ee.AST_TOKEN_TYPES.Block&&i.includes(I.value.trim().toLowerCase()))return!0}return!!(c(S)||s.length>0&&y(S,s)||n.length>0&&S.parent.type===Ee.AST_NODE_TYPES.CallExpression&&S.parent.arguments.includes(S)&&m(S.parent.callee,n))}function h(S){let I=`__PLACEHOLDER__${Math.random()}`,A=S.quasis.map(M=>t.getText(M).slice(1,M.tail?-1:-2)).join(I),T=A.match(gl);if(!T)return;let b=T[0],C=t.lines[t.getLocFromIndex(S.range[0]).line-1];if(!C)return;let N=C.match(dl)?.[1]??"",k;typeof o=="string"?k=o:typeof o=="number"?k=" ".repeat(o):k=N.startsWith(" ")?" ":" ";let f=a(A).replace(new RegExp(`^${b}|${b}[ ]*$`,"g"),""),x=b+l(f,1,N+k)+b+N,E=A.includes(`\r
|
|
38
38
|
`)?`\r
|
package/dist/extended-lint.mjs
CHANGED
|
@@ -32,7 +32,7 @@ const ${e}: FC<${m}> = ({ ${l} }) => {
|
|
|
32
32
|
|
|
33
33
|
${u}`)),g.push(y.replaceText(s,d)),g}}]})}function rl(e,t,r){let n=e.arguments[0];if(!n||n.type!==V.JSXElement&&n.type!==V.JSXFragment)return;let s=n,o=pi(s,t);if(!o.hasUnstable)return;let i=el(s),a=ci(s,[],t),l=s.type===V.JSXElement?fi(s,t):null,p=o.problematicProps.length===1?`prop "${o.problematicProps[0]}"`:`props "${o.problematicProps.join('", "')}"`;r.report({node:s,messageId:"unstableValueInMap",data:{problematicProps:p},suggest:[{messageId:"extractComponent",data:{componentName:i},fix:m=>{let y=ui(i,s,[],a,t),u=tl(i,a,l),d=e;for(;d.parent.type!==V.Program&&!(d.type===V.FunctionDeclaration||d.type===V.VariableDeclarator&&d.init&&(d.init.type===V.ArrowFunctionExpression||d.init.type===V.FunctionExpression));)d=d.parent;let c=[];return c.push(m.insertTextAfter(d,`
|
|
34
34
|
|
|
35
|
-
${y}`)),c.push(m.replaceText(s,u)),c}}]})}import{ESLintUtils as il,TSESTree as sl}from"@typescript-eslint/utils";var ol=il.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),mi="require-description",al=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u,ll=/^eslint-disable-(next-)?line$/u,pl=ol({name:mi,meta:{type:"problem",docs:{description:"Require descriptions for eslint directives."},messages:{missingDescription:"Unexpected undescribed directive comment. Include descriptions to explain why the comment is necessary."},schema:[{type:"object",properties:{ignore:{type:"array",items:{type:"string",enum:["eslint","eslint-disable","eslint-disable-line","eslint-disable-next-line","eslint-enable","eslint-env","exported","global","globals"]},additionalItems:!1,uniqueItems:!0}},additionalProperties:!1}]},defaultOptions:[{ignore:[]}],create(e,[t]){let r=e.sourceCode,n=new Set(t.ignore||[]);return{Program(){for(let s of r.getAllComments()){let o=cl(s);o!=null&&(n.has(o.kind)||o.description||e.report({loc:ml(s.loc),messageId:"missingDescription"}))}}}}}),yi={name:mi,rule:pl};function cl(e){let{text:t,description:r}=fl(e.value);if(!t)return null;let n=al.exec(t);if(!n)return null;let s=n[1];if(!s)return null;let o=ll.test(s);if(e.type===sl.AST_TOKEN_TYPES.Line&&!o||o&&e.loc.start.line!==e.loc.end.line)return null;let i=t.slice(n.index+s.length);return{kind:s,value:i.trim(),description:r}}var ul=/\s-{2,}\s/u;function fl(e){let t=e.split(ul);return{text:t[0]?.trim(),description:t.length>1?t[1]?.trim()??null:null}}function ml(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 Je}from"zod/v4";var yl=Je.object({varsToCheck:Je.array(Je.object({selector:Je.string().optional(),fromFnCall:Je.string().optional(),prop:Je.string().or(Je.array(Je.string())),errorMsg:Je.string().optional()}))}),Rn=z({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:[_(yl)]},defaultOptions:[{varsToCheck:[]}],create(e,[t]){let r=new Map;function n(i,a,l,p){let m=new Set;for(let u of i.properties)u.type===ne.Property&&u.key.type===ne.Identifier&&m.add(u.key.name);let y=a.filter(u=>!m.has(u));if(y.length>0)if(y.length===1)e.report({node:i,messageId:"propNotRead",data:{prop:y[0],fnName:p,customMsg:l||""}});else{let u=y.map(d=>`"${d}"`).join(", ");e.report({node:i,messageId:"propsNotRead",data:{props:u,fnName:p,customMsg:l||""}})}}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 t.varsToCheck)i.selector&&(o[i.selector]=a=>{if(a.type===ne.VariableDeclarator&&a.id.type===ne.Identifier&&r.set(a.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:a.id,fnName:s(a)}),a.type===ne.VariableDeclarator&&a.id.type===ne.ObjectPattern){let l=Array.isArray(i.prop)?i.prop:[i.prop];n(a.id,l,i.errorMsg,s(a))}});for(let i of t.varsToCheck)if(i.fromFnCall){let a=i.fromFnCall;if(a.startsWith("*.")){let p=`VariableDeclarator > CallExpression > MemberExpression[property.name="${a.slice(2)}"]`;o[p]=m=>{if(m.type!==ne.MemberExpression||m.parent.type!==ne.CallExpression)return;let y=m.parent;if(y.parent.type!==ne.VariableDeclarator)return;let u=y.parent;if(u.id.type===ne.Identifier)r.set(u.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:u.id,fnName:i.fromFnCall||"unknown function"});else if(u.id.type===ne.ObjectPattern){let d=Array.isArray(i.prop)?i.prop:[i.prop];n(u.id,d,i.errorMsg,i.fromFnCall||"unknown function")}}}else if(a.includes(".")){let[l,p]=a.split("."),m=`VariableDeclarator > CallExpression > MemberExpression[object.name="${l}"][property.name="${p}"]`;o[m]=y=>{if(y.type!==ne.MemberExpression||y.parent.type!==ne.CallExpression)return;let u=y.parent;if(u.parent.type!==ne.VariableDeclarator)return;let d=u.parent;if(d.id.type===ne.Identifier)r.set(d.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:d.id,fnName:i.fromFnCall||"unknown function"});else if(d.id.type===ne.ObjectPattern){let c=Array.isArray(i.prop)?i.prop:[i.prop];n(d.id,c,i.errorMsg,i.fromFnCall||"unknown function")}}}else{let l=`VariableDeclarator > CallExpression > Identifier[name="${a}"]`;o[l]=p=>{if(p.type!==ne.Identifier||p.parent.type!==ne.CallExpression)return;let m=p.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 u=Array.isArray(i.prop)?i.prop:[i.prop];n(y.id,u,i.errorMsg,i.fromFnCall||"unknown function")}}}}return{...o,"Program:exit"(){for(let[i,{props:a,errorMsg:l,node:p,fnName:m}]of r){let u=e.sourceCode.getScope(p).set.get(i);if(u){let d=new Set(a);for(let c of u.references){let g=c.identifier,h=g.parent;if(!(h.type===ne.VariableDeclarator&&h.id===g)){if(h.type===ne.MemberExpression&&h.object===g&&h.property.type===ne.Identifier&&d.has(h.property.name)){if(d.delete(h.property.name),d.size===0)break;continue}if(h.type===ne.VariableDeclarator&&h.init===g&&h.id.type===ne.ObjectPattern){for(let S of h.id.properties)S.type===ne.Property&&S.key.type===ne.Identifier&&d.has(S.key.name)&&d.delete(S.key.name);if(d.size===0)break;continue}if(!(h.type===ne.MemberExpression&&h.object===g&&h.property.type===ne.Identifier&&!a.includes(h.property.name))){d.clear();break}}}if(d.size>0){let c=Array.from(d);if(c.length===1)e.report({node:p,messageId:"propNotRead",data:{prop:c[0],fnName:m,customMsg:l||""}});else{let g=c.map(h=>`"${h}"`).join(", ");e.report({node:p,messageId:"propsNotRead",data:{props:g,fnName:m,customMsg:l||""}})}}}}}}}});function Ei(e){return/^use[A-Z0-9]/.test(e)}function kt(e){return e.type==="Identifier"?Ei(e.name):e.type==="MemberExpression"&&!e.computed&&kt(e.property)?e.object.type==="Identifier":!1}function hi(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function bi(e,t){return e.name===t||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===t}function xi(e){return!!(e.parent&&e.parent.callee&&bi(e.parent.callee,"forwardRef"))}function Ci(e){return!!(e.parent&&e.parent.callee&&bi(e.parent.callee,"memo"))}function Nn(e){for(;e;){let t=Ai(e);if(t&&(hi(t)||kt(t))||xi(e)||Ci(e))return!0;e=e.parent}return!1}function di(e){return!1}function kn(e){return!1}var dl=/eslint +react-compiler\/react-compiler: +\["error/;function gi(e){let t=null;if((e.type==="FunctionDeclaration"||e.type==="FunctionExpression"||e.type==="ArrowFunctionExpression"&&e.body.type==="BlockStatement")&&(t=e.body),!t||t.body.length===0)return!1;let r=t.body[0];return r.type==="ExpressionStatement"&&r.expression.type==="Literal"&&r.expression.value==="use no memo"}function Si(e){let t=e.parent;for(;t;){if(t.type==="FunctionDeclaration"||t.type==="FunctionExpression"||t.type==="ArrowFunctionExpression")return t;t=t.parent}return null}var Ii={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 t=!!e.options[0]?.reactCompilerIsEnabled;if(t)return{CallExpression(p){let m=null;if(p.callee.name==="useMemo"?m="useMemo":p.callee.name==="useCallback"&&(m="useCallback"),m){let y=Si(p);if(y&&gi(y))return;e.report({node:p,message:`"${m}" is not necessary when using React Compiler.`})}}};if(e.options[0]?.ignoreIfReactCompilerIsEnabled||t){for(let p of e.sourceCode.getAllComments())if(dl.test(p.value))return{CallExpression(m){let y=null;if(m.callee.name==="useMemo"?y="useMemo":m.callee.name==="useCallback"&&(y="useCallback"),y){let u=Si(m);if(u&&gi(u))return;e.report({node:m,message:`"${y}" is not necessary when using React Compiler.`})}}}}let r=typeof e.getSource=="function"?p=>r(p):p=>e.sourceCode.getText(p),n=typeof e.getScope=="function"?()=>n():p=>e.sourceCode.getScope(p),s=null,o=[],i=[],a=new WeakSet;function l(p){for(let m of p.references){let y=m.identifier.parent;if(y.type==="VariableDeclarator"&&y.init&&y.init.type==="CallExpression"&&y.init.callee&&di(y.init.callee))for(let u of m.resolved.references)u!==m&&a.add(u.identifier)}}return{onCodePathSegmentStart:p=>i.push(p),onCodePathSegmentEnd:()=>i.pop(),onCodePathStart:()=>o.push(new Map),onCodePathEnd(p,m){let y=o.pop();if(y.size===0)return;let u=new Set;function d(b,C){let{cache:w}=d,N=w.get(b.id),k=new Set(C);if(k.has(b.id)){let O=[...k],f=O.slice(O.indexOf(b.id)+1);for(let x of f)u.add(x);return BigInt("0")}if(k.add(b.id),N!==void 0)return N;if(p.thrownSegments.includes(b))N=BigInt("0");else if(b.prevSegments.length===0)N=BigInt("1");else{N=BigInt("0");for(let O of b.prevSegments)N+=d(O,k)}return b.reachable&&N===BigInt("0")?w.delete(b.id):w.set(b.id,N),N}function c(b,C){let{cache:w}=c,N=w.get(b.id),k=new Set(C);if(k.has(b.id)){let O=Array.from(k),f=O.slice(O.indexOf(b.id)+1);for(let x of f)u.add(x);return BigInt("0")}if(k.add(b.id),N!==void 0)return N;if(p.thrownSegments.includes(b))N=BigInt("0");else if(b.nextSegments.length===0)N=BigInt("1");else{N=BigInt("0");for(let O of b.nextSegments)N+=c(O,k)}return w.set(b.id,N),N}function g(b){let{cache:C}=g,w=C.get(b.id);if(w===null)return 1/0;if(w!==void 0)return w;if(C.set(b.id,null),b.prevSegments.length===0)w=1;else{w=1/0;for(let N of b.prevSegments){let k=g(N);k<w&&(w=k)}w+=1}return C.set(b.id,w),w}d.cache=new Map,c.cache=new Map,g.cache=new Map;let h=c(p.initialSegment),S=Ai(m),I=Nn(m),A=S?hi(S)||kt(S):xi(m)||Ci(m),T=1/0;for(let b of p.finalSegments){if(!b.reachable)continue;let C=g(b);C<T&&(T=C)}for(let[b,C]of y){if(!b.reachable)continue;let w=b.nextSegments.length===0?T<=g(b):T<g(b),N=d(b)*c(b),k=u.has(b.id);for(let O of C)if(k&&!kn(O)&&e.report({node:O,message:`React Hook "${r(O)}" 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(m.async&&e.report({node:O,message:`React Hook "${r(O)}" cannot be called in an async function.`}),!k&&N!==h&&!kn(O)){let x=`React Hook "${r(O)}" 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:O,message:x})}}else if(m.parent&&(m.parent.type==="MethodDefinition"||m.parent.type==="ClassProperty")&&m.parent.value===m){let f=`React Hook "${r(O)}" 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:O,message:f})}else if(S){let f=`React Hook "${r(O)}" 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:O,message:f})}else if(m.type==="Program"){let f=`React Hook "${r(O)}" 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:O,message:f})}else if(I&&!kn(O)){if(m.parent.type==="CallExpression"&&m.parent.callee.type==="Identifier"&&m.parent.callee.name==="useCallback"){let x=m.parent;if(x.parent.type==="VariableDeclarator"&&Ei(x.parent.id.name))return}let f=`React Hook "${r(O)}" 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:O,message:f})}}},CallExpression(p){if(kt(p.callee)){let m=Ti(o),y=Ti(i),u=m.get(y);u||(u=[],m.set(y,u)),u.push(p.callee)}p.callee.type==="Identifier"&&(p.callee.name==="useEffect"||di(p.callee))&&p.arguments.length>0&&(s=p)},Identifier(p){s==null&&a.has(p)&&p.parent.type!=="CallExpression"&&e.report({node:p,message:`\`${r(p)}\` 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"(p){p===s&&(s=null)},FunctionDeclaration(p){Nn(p)&&l(n(p))},ArrowFunctionExpression(p){Nn(p)&&l(n(p))}}}};function Ai(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 Ti(e){return e[e.length-1]}import{AST_NODE_TYPES as he,AST_TOKEN_TYPES as gl}from"@typescript-eslint/utils";import*as Ie from"zod/v4";var Sl=/^\s+$/,Pn=/\r?\n/,Tl=/^(\s*)/,El=/^(\s*)\S/,hl=/\r?\n/,bl=Ie.object({indent:Ie.union([Ie.string().regex(Sl),Ie.number().int().min(1)]).optional(),tags:Ie.array(Ie.string()).optional(),functions:Ie.array(Ie.string()).optional(),comments:Ie.array(Ie.string()).optional()}),On=z({name:"template-indent",meta:{type:"suggestion",docs:{description:"Fix whitespace-insensitive template indentation"},fixable:"code",schema:[_(bl)],messages:{improperlyIndented:"Templates should be properly indented."}},defaultOptions:[{}],create(e){let t=e.sourceCode,{comments:r=["HTML","indent"],functions:n=["dedent","stripIndent"],tags:s=["outdent","dedent","gql","sql","html","styled"],indent:o}=e.options[0],i=r.map(S=>S.toLowerCase());function a(S){let I=S.split(Pn),A=I.filter(b=>b.trim()!=="");if(A.length===0)return S;let T=Number.POSITIVE_INFINITY;for(let b of A){let C=b.match(Tl);C&&(T=Math.min(T,C[1]?.length??0))}return!isFinite(T)||T===0?S:I.map(b=>b.slice(T)).join(`
|
|
35
|
+
${y}`)),c.push(m.replaceText(s,u)),c}}]})}import{ESLintUtils as il,TSESTree as sl}from"@typescript-eslint/utils";var ol=il.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),mi="require-description",al=/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|oxlint-(?:enable|disable(?:(?:-next)?-line)?)|exported|globals?)(?:\s|$)/u,ll=/^(?:eslint|oxlint)-disable-(next-)?line$/u,pl=ol({name:mi,meta:{type:"problem",docs:{description:"Require descriptions for eslint and oxlint 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","oxlint-disable","oxlint-disable-line","oxlint-disable-next-line","oxlint-enable","exported","global","globals"]},additionalItems:!1,uniqueItems:!0}},additionalProperties:!1}]},defaultOptions:[{ignore:[]}],create(e,[t]){let r=e.sourceCode,n=new Set(t.ignore||[]);return{Program(){for(let s of r.getAllComments()){let o=cl(s);o!=null&&(n.has(o.kind)||o.description||e.report({loc:ml(s.loc),messageId:"missingDescription"}))}}}}}),yi={name:mi,rule:pl};function cl(e){let{text:t,description:r}=fl(e.value);if(!t)return null;let n=al.exec(t);if(!n)return null;let s=n[1];if(!s)return null;let o=ll.test(s);if(e.type===sl.AST_TOKEN_TYPES.Line&&!o||o&&e.loc.start.line!==e.loc.end.line)return null;let i=t.slice(n.index+s.length);return{kind:s,value:i.trim(),description:r}}var ul=/\s-{2,}\s/u;function fl(e){let t=e.split(ul);return{text:t[0]?.trim(),description:t.length>1?t[1]?.trim()??null:null}}function ml(e){return{start:{line:e.start.line,column:0},end:e.end}}import{AST_NODE_TYPES as ne}from"@typescript-eslint/utils";import{z as Je}from"zod/v4";var yl=Je.object({varsToCheck:Je.array(Je.object({selector:Je.string().optional(),fromFnCall:Je.string().optional(),prop:Je.string().or(Je.array(Je.string())),errorMsg:Je.string().optional()}))}),Rn=z({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:[_(yl)]},defaultOptions:[{varsToCheck:[]}],create(e,[t]){let r=new Map;function n(i,a,l,p){let m=new Set;for(let u of i.properties)u.type===ne.Property&&u.key.type===ne.Identifier&&m.add(u.key.name);let y=a.filter(u=>!m.has(u));if(y.length>0)if(y.length===1)e.report({node:i,messageId:"propNotRead",data:{prop:y[0],fnName:p,customMsg:l||""}});else{let u=y.map(d=>`"${d}"`).join(", ");e.report({node:i,messageId:"propsNotRead",data:{props:u,fnName:p,customMsg:l||""}})}}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 t.varsToCheck)i.selector&&(o[i.selector]=a=>{if(a.type===ne.VariableDeclarator&&a.id.type===ne.Identifier&&r.set(a.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:a.id,fnName:s(a)}),a.type===ne.VariableDeclarator&&a.id.type===ne.ObjectPattern){let l=Array.isArray(i.prop)?i.prop:[i.prop];n(a.id,l,i.errorMsg,s(a))}});for(let i of t.varsToCheck)if(i.fromFnCall){let a=i.fromFnCall;if(a.startsWith("*.")){let p=`VariableDeclarator > CallExpression > MemberExpression[property.name="${a.slice(2)}"]`;o[p]=m=>{if(m.type!==ne.MemberExpression||m.parent.type!==ne.CallExpression)return;let y=m.parent;if(y.parent.type!==ne.VariableDeclarator)return;let u=y.parent;if(u.id.type===ne.Identifier)r.set(u.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:u.id,fnName:i.fromFnCall||"unknown function"});else if(u.id.type===ne.ObjectPattern){let d=Array.isArray(i.prop)?i.prop:[i.prop];n(u.id,d,i.errorMsg,i.fromFnCall||"unknown function")}}}else if(a.includes(".")){let[l,p]=a.split("."),m=`VariableDeclarator > CallExpression > MemberExpression[object.name="${l}"][property.name="${p}"]`;o[m]=y=>{if(y.type!==ne.MemberExpression||y.parent.type!==ne.CallExpression)return;let u=y.parent;if(u.parent.type!==ne.VariableDeclarator)return;let d=u.parent;if(d.id.type===ne.Identifier)r.set(d.id.name,{props:Array.isArray(i.prop)?i.prop:[i.prop],errorMsg:i.errorMsg,node:d.id,fnName:i.fromFnCall||"unknown function"});else if(d.id.type===ne.ObjectPattern){let c=Array.isArray(i.prop)?i.prop:[i.prop];n(d.id,c,i.errorMsg,i.fromFnCall||"unknown function")}}}else{let l=`VariableDeclarator > CallExpression > Identifier[name="${a}"]`;o[l]=p=>{if(p.type!==ne.Identifier||p.parent.type!==ne.CallExpression)return;let m=p.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 u=Array.isArray(i.prop)?i.prop:[i.prop];n(y.id,u,i.errorMsg,i.fromFnCall||"unknown function")}}}}return{...o,"Program:exit"(){for(let[i,{props:a,errorMsg:l,node:p,fnName:m}]of r){let u=e.sourceCode.getScope(p).set.get(i);if(u){let d=new Set(a);for(let c of u.references){let g=c.identifier,h=g.parent;if(!(h.type===ne.VariableDeclarator&&h.id===g)){if(h.type===ne.MemberExpression&&h.object===g&&h.property.type===ne.Identifier&&d.has(h.property.name)){if(d.delete(h.property.name),d.size===0)break;continue}if(h.type===ne.VariableDeclarator&&h.init===g&&h.id.type===ne.ObjectPattern){for(let S of h.id.properties)S.type===ne.Property&&S.key.type===ne.Identifier&&d.has(S.key.name)&&d.delete(S.key.name);if(d.size===0)break;continue}if(!(h.type===ne.MemberExpression&&h.object===g&&h.property.type===ne.Identifier&&!a.includes(h.property.name))){d.clear();break}}}if(d.size>0){let c=Array.from(d);if(c.length===1)e.report({node:p,messageId:"propNotRead",data:{prop:c[0],fnName:m,customMsg:l||""}});else{let g=c.map(h=>`"${h}"`).join(", ");e.report({node:p,messageId:"propsNotRead",data:{props:g,fnName:m,customMsg:l||""}})}}}}}}}});function Ei(e){return/^use[A-Z0-9]/.test(e)}function kt(e){return e.type==="Identifier"?Ei(e.name):e.type==="MemberExpression"&&!e.computed&&kt(e.property)?e.object.type==="Identifier":!1}function hi(e){return e.type==="Identifier"&&/^[A-Z]/.test(e.name)}function bi(e,t){return e.name===t||e.type==="MemberExpression"&&e.object.name==="React"&&e.property.name===t}function xi(e){return!!(e.parent&&e.parent.callee&&bi(e.parent.callee,"forwardRef"))}function Ci(e){return!!(e.parent&&e.parent.callee&&bi(e.parent.callee,"memo"))}function Nn(e){for(;e;){let t=Ai(e);if(t&&(hi(t)||kt(t))||xi(e)||Ci(e))return!0;e=e.parent}return!1}function di(e){return!1}function kn(e){return!1}var dl=/eslint +react-compiler\/react-compiler: +\["error/;function gi(e){let t=null;if((e.type==="FunctionDeclaration"||e.type==="FunctionExpression"||e.type==="ArrowFunctionExpression"&&e.body.type==="BlockStatement")&&(t=e.body),!t||t.body.length===0)return!1;let r=t.body[0];return r.type==="ExpressionStatement"&&r.expression.type==="Literal"&&r.expression.value==="use no memo"}function Si(e){let t=e.parent;for(;t;){if(t.type==="FunctionDeclaration"||t.type==="FunctionExpression"||t.type==="ArrowFunctionExpression")return t;t=t.parent}return null}var Ii={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 t=!!e.options[0]?.reactCompilerIsEnabled;if(t)return{CallExpression(p){let m=null;if(p.callee.name==="useMemo"?m="useMemo":p.callee.name==="useCallback"&&(m="useCallback"),m){let y=Si(p);if(y&&gi(y))return;e.report({node:p,message:`"${m}" is not necessary when using React Compiler.`})}}};if(e.options[0]?.ignoreIfReactCompilerIsEnabled||t){for(let p of e.sourceCode.getAllComments())if(dl.test(p.value))return{CallExpression(m){let y=null;if(m.callee.name==="useMemo"?y="useMemo":m.callee.name==="useCallback"&&(y="useCallback"),y){let u=Si(m);if(u&&gi(u))return;e.report({node:m,message:`"${y}" is not necessary when using React Compiler.`})}}}}let r=typeof e.getSource=="function"?p=>r(p):p=>e.sourceCode.getText(p),n=typeof e.getScope=="function"?()=>n():p=>e.sourceCode.getScope(p),s=null,o=[],i=[],a=new WeakSet;function l(p){for(let m of p.references){let y=m.identifier.parent;if(y.type==="VariableDeclarator"&&y.init&&y.init.type==="CallExpression"&&y.init.callee&&di(y.init.callee))for(let u of m.resolved.references)u!==m&&a.add(u.identifier)}}return{onCodePathSegmentStart:p=>i.push(p),onCodePathSegmentEnd:()=>i.pop(),onCodePathStart:()=>o.push(new Map),onCodePathEnd(p,m){let y=o.pop();if(y.size===0)return;let u=new Set;function d(b,C){let{cache:w}=d,N=w.get(b.id),k=new Set(C);if(k.has(b.id)){let O=[...k],f=O.slice(O.indexOf(b.id)+1);for(let x of f)u.add(x);return BigInt("0")}if(k.add(b.id),N!==void 0)return N;if(p.thrownSegments.includes(b))N=BigInt("0");else if(b.prevSegments.length===0)N=BigInt("1");else{N=BigInt("0");for(let O of b.prevSegments)N+=d(O,k)}return b.reachable&&N===BigInt("0")?w.delete(b.id):w.set(b.id,N),N}function c(b,C){let{cache:w}=c,N=w.get(b.id),k=new Set(C);if(k.has(b.id)){let O=Array.from(k),f=O.slice(O.indexOf(b.id)+1);for(let x of f)u.add(x);return BigInt("0")}if(k.add(b.id),N!==void 0)return N;if(p.thrownSegments.includes(b))N=BigInt("0");else if(b.nextSegments.length===0)N=BigInt("1");else{N=BigInt("0");for(let O of b.nextSegments)N+=c(O,k)}return w.set(b.id,N),N}function g(b){let{cache:C}=g,w=C.get(b.id);if(w===null)return 1/0;if(w!==void 0)return w;if(C.set(b.id,null),b.prevSegments.length===0)w=1;else{w=1/0;for(let N of b.prevSegments){let k=g(N);k<w&&(w=k)}w+=1}return C.set(b.id,w),w}d.cache=new Map,c.cache=new Map,g.cache=new Map;let h=c(p.initialSegment),S=Ai(m),I=Nn(m),A=S?hi(S)||kt(S):xi(m)||Ci(m),T=1/0;for(let b of p.finalSegments){if(!b.reachable)continue;let C=g(b);C<T&&(T=C)}for(let[b,C]of y){if(!b.reachable)continue;let w=b.nextSegments.length===0?T<=g(b):T<g(b),N=d(b)*c(b),k=u.has(b.id);for(let O of C)if(k&&!kn(O)&&e.report({node:O,message:`React Hook "${r(O)}" 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(m.async&&e.report({node:O,message:`React Hook "${r(O)}" cannot be called in an async function.`}),!k&&N!==h&&!kn(O)){let x=`React Hook "${r(O)}" 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:O,message:x})}}else if(m.parent&&(m.parent.type==="MethodDefinition"||m.parent.type==="ClassProperty")&&m.parent.value===m){let f=`React Hook "${r(O)}" 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:O,message:f})}else if(S){let f=`React Hook "${r(O)}" 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:O,message:f})}else if(m.type==="Program"){let f=`React Hook "${r(O)}" 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:O,message:f})}else if(I&&!kn(O)){if(m.parent.type==="CallExpression"&&m.parent.callee.type==="Identifier"&&m.parent.callee.name==="useCallback"){let x=m.parent;if(x.parent.type==="VariableDeclarator"&&Ei(x.parent.id.name))return}let f=`React Hook "${r(O)}" 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:O,message:f})}}},CallExpression(p){if(kt(p.callee)){let m=Ti(o),y=Ti(i),u=m.get(y);u||(u=[],m.set(y,u)),u.push(p.callee)}p.callee.type==="Identifier"&&(p.callee.name==="useEffect"||di(p.callee))&&p.arguments.length>0&&(s=p)},Identifier(p){s==null&&a.has(p)&&p.parent.type!=="CallExpression"&&e.report({node:p,message:`\`${r(p)}\` 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"(p){p===s&&(s=null)},FunctionDeclaration(p){Nn(p)&&l(n(p))},ArrowFunctionExpression(p){Nn(p)&&l(n(p))}}}};function Ai(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 Ti(e){return e[e.length-1]}import{AST_NODE_TYPES as he,AST_TOKEN_TYPES as gl}from"@typescript-eslint/utils";import*as Ie from"zod/v4";var Sl=/^\s+$/,Pn=/\r?\n/,Tl=/^(\s*)/,El=/^(\s*)\S/,hl=/\r?\n/,bl=Ie.object({indent:Ie.union([Ie.string().regex(Sl),Ie.number().int().min(1)]).optional(),tags:Ie.array(Ie.string()).optional(),functions:Ie.array(Ie.string()).optional(),comments:Ie.array(Ie.string()).optional()}),On=z({name:"template-indent",meta:{type:"suggestion",docs:{description:"Fix whitespace-insensitive template indentation"},fixable:"code",schema:[_(bl)],messages:{improperlyIndented:"Templates should be properly indented."}},defaultOptions:[{}],create(e){let t=e.sourceCode,{comments:r=["HTML","indent"],functions:n=["dedent","stripIndent"],tags:s=["outdent","dedent","gql","sql","html","styled"],indent:o}=e.options[0],i=r.map(S=>S.toLowerCase());function a(S){let I=S.split(Pn),A=I.filter(b=>b.trim()!=="");if(A.length===0)return S;let T=Number.POSITIVE_INFINITY;for(let b of A){let C=b.match(Tl);C&&(T=Math.min(T,C[1]?.length??0))}return!isFinite(T)||T===0?S:I.map(b=>b.slice(T)).join(`
|
|
36
36
|
`)}function l(S,I,A){return S.split(Pn).map(b=>b.trim()===""?b:A.repeat(I)+b).join(`
|
|
37
37
|
`)}function p(S){if(S.type===he.Identifier)return S.name;if(S.type===he.MemberExpression){let I=S.object.type===he.Identifier?S.object.name:null,A=S.property.type===he.Identifier?S.property.name:null;return I&&A?`${I}.${A}`:A}return null}function m(S,I){if(!S)return!1;for(let A of I)if(A.includes(".")){let T=A.split(".");if(S.type===he.MemberExpression&&S.object.type===he.Identifier&&S.property.type===he.Identifier&&S.object.name===T[0]&&S.property.name===T[1])return!0}else if(S.type===he.Identifier&&S.name===A)return!0;return!1}function y(S,I){let A=S.parent;if(A.type!==he.TaggedTemplateExpression)return!1;let T=p(A.tag);return T?I.includes(T):!1}function u(S,I){if(!S||S.type!==he.CallExpression)return!1;let{method:A,argumentsLength:T,optionalCall:b=!0,optionalMember:C=!0}=I;return T!==void 0&&S.arguments.length!==T||!b&&S.optional||S.callee.type!==he.MemberExpression||!C&&S.callee.optional||S.callee.property.type!==he.Identifier?!1:S.callee.property.name===A}function d(S,I){if(!S||S.type!==he.CallExpression)return!1;let{name:A,argumentsLength:T,optionalCall:b=!0}=I;return T!==void 0&&S.arguments.length!==T||!b&&S.optional||S.callee.type!==he.Identifier?!1:S.callee.name===A}function c(S){return u(S.parent,{method:"toMatchInlineSnapshot",argumentsLength:1,optionalCall:!1,optionalMember:!1})&&S.parent.type===he.CallExpression&&S.parent.arguments[0]===S&&d(S.parent.callee.type===he.MemberExpression?S.parent.callee.object:null,{name:"expect",argumentsLength:1,optionalCall:!1,optionalMember:!1})}function g(S){if(i.length>0){let I=t.getTokenBefore(S,{includeComments:!0});if(I?.type===gl.Block&&i.includes(I.value.trim().toLowerCase()))return!0}return!!(c(S)||s.length>0&&y(S,s)||n.length>0&&S.parent.type===he.CallExpression&&S.parent.arguments.includes(S)&&m(S.parent.callee,n))}function h(S){let I=`__PLACEHOLDER__${Math.random()}`,A=S.quasis.map(M=>t.getText(M).slice(1,M.tail?-1:-2)).join(I),T=A.match(hl);if(!T)return;let b=T[0],C=t.lines[t.getLocFromIndex(S.range[0]).line-1];if(!C)return;let N=C.match(El)?.[1]??"",k;typeof o=="string"?k=o:typeof o=="number"?k=" ".repeat(o):k=N.startsWith(" ")?" ":" ";let f=a(A).replace(new RegExp(`^${b}|${b}[ ]*$`,"g"),""),x=b+l(f,1,N+k)+b+N,E=A.includes(`\r
|
|
38
38
|
`)?`\r
|
package/package.json
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ls-stack/extended-lint",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.91.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
7
7
|
],
|
|
8
|
-
"repository":
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "github:lucaslos/eslint-plugin-extended-lint"
|
|
11
|
+
},
|
|
9
12
|
"author": "Lucas Santos",
|
|
10
13
|
"main": "./dist/extended-lint.js",
|
|
11
14
|
"module": "./dist/extended-lint.mjs",
|