@ls-stack/extended-lint 0.74.0 → 0.75.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 +1 -1
package/dist/extended-lint.js
CHANGED
|
@@ -43,7 +43,7 @@ ${P}`),C.push(c)}yield E.insertTextBeforeRange([m,m],`${C.join(`
|
|
|
43
43
|
|
|
44
44
|
`)}
|
|
45
45
|
|
|
46
|
-
`)}}}return{Program(y){s.push(...y.body)},TSTypeAliasDeclaration(y){if(s.some(b=>b.type===Se.AST_NODE_TYPES.ExportNamedDeclaration&&b.declaration===y?!0:b===y)){let b=o(y);b&&n.set(y.id.name,{node:y,name:y.id.name,statement:b})}},TSInterfaceDeclaration(y){if(s.some(b=>b.type===Se.AST_NODE_TYPES.ExportNamedDeclaration&&b.declaration===y?!0:b===y)){let b=o(y);b&&n.set(y.id.name,{node:y,name:y.id.name,statement:b})}},TSTypeReference(y){if(y.typeName.type===Se.AST_NODE_TYPES.Identifier){if(u(y))return;let E=i(y),b=p(y),f=a(y);d.push({typeName:y.typeName.name,node:y,inFunctionArgs:E,inFCProps:b,inGenericArgAtFunctionCall:f,usagePosition:y.range[0]})}},"Program:exit"(){let y=new Map;function E(f){if(!t.checkOnly||t.checkOnly.length===0)return!0;for(let A of t.checkOnly)if(A==="function-args"&&f.inFunctionArgs||A==="FC"&&f.inFCProps||A==="generic-args-at-fn-calls"&&f.inGenericArgAtFunctionCall)return!0;return!1}for(let f of d){let{typeName:A,node:I}=f;if(!n.has(A)||!E(f))continue;let m=o(I),C=n.get(A);if(!m||!C||m===C.statement)continue;y.has(A)||y.set(A,[]);let h=y.get(A);if(!h)return;h.includes(m)||h.push(m)}let b=[];for(let[f,A]of y)if(A.length>0){if(A.length===0)continue;let I=A[0];if(!I)continue;let m=Number.MAX_SAFE_INTEGER,C=!1;for(let w of A)w.range[0]<I.range[0]&&(I=w);for(let w of d)E(w)&&w.typeName===f&&o(w.node)===I&&w.usagePosition<m&&(m=w.usagePosition,C=w.inFunctionArgs);if(!!(t.checkOnly&&t.checkOnly.length>0)){let w=Number.MAX_SAFE_INTEGER;for(let v of d){if(v.typeName!==f)continue;let c=o(v.node);if(!c)continue;let F=s.indexOf(c);F!==-1&&F<w&&(w=F)}let P=s.indexOf(I);if(w!==Number.MAX_SAFE_INTEGER&&P!==-1&&w<P)continue}else{let w=Number.MAX_SAFE_INTEGER;for(let v of d){if(v.typeName!==f||l(v.node))continue;let c=o(v.node);if(!c)continue;let F=s.indexOf(c);F!==-1&&F<w&&(w=F)}let P=s.indexOf(I);if(w!==Number.MAX_SAFE_INTEGER&&P!==-1&&w<P)continue}b.push({typeName:f,firstUsage:I,firstUsagePosition:m,firstUsageInFunctionArgs:C})}b.length>0&&g(b)}}}});var ie=require("@typescript-eslint/utils"),it=Oe(require("zod/v4"));var da=["tsx"],ga=/^[A-Z][A-Za-z0-9]*$/,Sa=it.object({extensions:it.array(it.string()).optional()}),Nn=q({name:"react-single-export",meta:{type:"problem",docs:{description:"Enforces only one export per React component file to support fast refresh"},messages:{multipleExports:"React component files should have only one export to support fast refresh, if you want to export multiple components, use a separate file for each component. Type-only exports are allowed."},schema:[B(Sa)]},defaultOptions:[{}],create(e,[t]){let r=e.getFilename(),n=t.extensions??da,s=!1;for(let m of n)if(r.endsWith(m)){s=!0;break}if(!s)return{};let o=e.sourceCode,i=new Set,p=new Map;function a(m){return ga.test(m)}function l(m){if(m.type!==ie.AST_NODE_TYPES.CallExpression)return!1;let C=m.callee;return C.type===ie.AST_NODE_TYPES.Identifier?C.name==="memo"||C.name==="forwardRef":C.type===ie.AST_NODE_TYPES.MemberExpression&&C.property.type===ie.AST_NODE_TYPES.Identifier?C.property.name==="memo"||C.property.name==="forwardRef":!1}function u(m){if(m.type===ie.AST_NODE_TYPES.JSXElement||m.type===ie.AST_NODE_TYPES.JSXFragment)return!0;if(m.type===ie.AST_NODE_TYPES.ArrayExpression){for(let C of m.elements)if(C&&(C.type===ie.AST_NODE_TYPES.JSXElement||C.type===ie.AST_NODE_TYPES.JSXFragment))return!0}return!1}function d(m){if(m.type!==ie.AST_NODE_TYPES.ArrowFunctionExpression)return!1;let C=m.body;if(C.type===ie.AST_NODE_TYPES.ArrowFunctionExpression){let h=C.body;if(u(h))return!0}return!1}function g(m){if(m.id.type!==ie.AST_NODE_TYPES.Identifier)return;let C=m.id.name,h=m.init;if(h){if(a(C)&&(h.type===ie.AST_NODE_TYPES.ArrowFunctionExpression||h.type===ie.AST_NODE_TYPES.FunctionExpression||l(h))){i.add(C);return}h.type===ie.AST_NODE_TYPES.Identifier&&p.set(C,h.name),a(C)||d(h)&&i.add(C)}}function x(m){if(m.type===ie.AST_NODE_TYPES.VariableDeclaration){for(let C of m.declarations)g(C);return}if(m.type===ie.AST_NODE_TYPES.FunctionDeclaration&&m.id){a(m.id.name)&&i.add(m.id.name);return}if(m.type===ie.AST_NODE_TYPES.ExportNamedDeclaration&&m.declaration){let C=m.declaration;if(C.type===ie.AST_NODE_TYPES.VariableDeclaration){for(let h of C.declarations)g(h);return}if(C.type===ie.AST_NODE_TYPES.FunctionDeclaration&&C.id){a(C.id.name)&&i.add(C.id.name);return}}}for(let m of o.ast.body)x(m);function y(m,C=new Set){if(i.has(m))return!0;if(C.has(m))return!1;C.add(m);let h=p.get(m);return h?y(h,C):!1}let E=[];function b(m,C,h){E.push({node:m,isType:C,isComponent:h})}for(let m of o.ast.body){if(m.type===ie.AST_NODE_TYPES.ExportNamedDeclaration){let C=m.exportKind==="type";if(m.declaration){let h=m.declaration;if(h.type===ie.AST_NODE_TYPES.TSTypeAliasDeclaration||h.type===ie.AST_NODE_TYPES.TSInterfaceDeclaration){b(h,!0,!1);continue}if(h.type===ie.AST_NODE_TYPES.VariableDeclaration){for(let w of h.declarations){if(w.id.type!==ie.AST_NODE_TYPES.Identifier)continue;let P=w.id.name,v=y(P);b(w,C,v)}continue}if(h.type===ie.AST_NODE_TYPES.FunctionDeclaration){let w=h.id?.name,P=w?y(w)||a(w):!1;b(h,C,P);continue}b(h,C,!1);continue}if(m.specifiers.length>0)for(let h of m.specifiers){if(h.local.type!==ie.AST_NODE_TYPES.Identifier)continue;let w=h.local.name,P=y(w);b(h,C,P)}continue}if(m.type===ie.AST_NODE_TYPES.ExportDefaultDeclaration){let C=m.declaration;if(C.type===ie.AST_NODE_TYPES.Identifier){let h=y(C.name)||a(C.name);b(m,!1,h);continue}if(C.type===ie.AST_NODE_TYPES.FunctionDeclaration||C.type===ie.AST_NODE_TYPES.ArrowFunctionExpression||C.type===ie.AST_NODE_TYPES.FunctionExpression||C.type===ie.AST_NODE_TYPES.CallExpression){b(m,!1,!0);continue}b(m,!1,!1);continue}}let f=!1;for(let m of E)if(!m.isType&&m.isComponent){f=!0;break}if(!f)return{};let A=[];for(let m of E)m.isType||A.push(m);let I=-1;for(let[m,C]of A.entries())if(C.isComponent){I=m;break}if(I===-1)return{};for(let[m,C]of A.entries())if(m!==I){e.report({node:C.node,messageId:"multipleExports"});break}return{}}});var Je=require("@typescript-eslint/utils"),At=require("zod/v4");function wt(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Ta(e){return e.callee.type===Je.AST_NODE_TYPES.Identifier?e.callee.name==="useState":e.callee.type===Je.AST_NODE_TYPES.MemberExpression&&e.callee.object.type===Je.AST_NODE_TYPES.Identifier&&e.callee.property.type===Je.AST_NODE_TYPES.Identifier?e.callee.object.name==="React"&&e.callee.property.name==="useState":!1}var ha=At.z.object({ignorePrefixes:At.z.array(At.z.string()).optional()});function ri(e,t){for(let r of t)if(e.startsWith(r))return e.slice(r.length);return e}function Ea(e){return`set${wt(e)}`}var Dn=q({name:"use-state-setter-naming",meta:{type:"problem",docs:{description:"Enforce consistent naming convention for useState destructuring where setter should be set{Value}"},messages:{incorrectSetterName:'useState setter should follow the pattern "set{{expectedName}}" with a "set" prefix but got "{{actualName}}"',useSuggestedName:'Use "{{expectedSetterName}}" instead'},hasSuggestions:!0,schema:[B(ha)]},defaultOptions:[{ignorePrefixes:[]}],create(e,[t]){return{VariableDeclarator(r){if(!r.init||r.init.type!==Je.AST_NODE_TYPES.CallExpression||!Ta(r.init)||r.id.type!==Je.AST_NODE_TYPES.ArrayPattern||r.id.elements.length!==2)return;let[n,s]=r.id.elements;if(!n||!s||n.type!==Je.AST_NODE_TYPES.Identifier||s.type!==Je.AST_NODE_TYPES.Identifier)return;let o=n.name,i=s.name,p=t.ignorePrefixes||[],a=ri(o,p),l=ri(i,p);if(a===""){if(!l.startsWith("set")){let d=`set${wt(o)}`;e.report({node:s,messageId:"incorrectSetterName",data:{expectedName:wt(o),actualName:i},suggest:[{messageId:"useSuggestedName",data:{expectedSetterName:d},fix:g=>g.replaceText(s,d)}]})}return}let u=Ea(a);l!==u&&e.report({node:s,messageId:"incorrectSetterName",data:{expectedName:wt(a),actualName:i},suggest:[{messageId:"useSuggestedName",data:{expectedSetterName:u},fix:d=>d.replaceText(s,u)}]})}}}});var ye=require("@typescript-eslint/utils"),Ke=require("zod/v4");var ba=Ke.z.object({name:Ke.z.string(),defaults:Ke.z.array(Ke.z.unknown())}),xa=Ke.z.object({functions:Ke.z.array(ba)});function Rt(e,t){if(e===t)return!0;if(e===null||t===null||e===void 0||t===void 0)return e===t;if(typeof e!=typeof t||typeof e!="object"||Array.isArray(e)!==Array.isArray(t))return!1;if(Array.isArray(e)&&Array.isArray(t))return e.length!==t.length?!1:e.every((s,o)=>Rt(s,t[o]));let r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(let s of r){if(!n.includes(s))return!1;let o=Object.getOwnPropertyDescriptor(e,s),i=Object.getOwnPropertyDescriptor(t,s);if(!o||!i)return!1;let p=o.value,a=i.value;if(!Rt(p,a))return!1}return!0}function Ca(e,t){let r=new Set;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return r;for(let n in e){if(!(n in t))continue;let s=Object.getOwnPropertyDescriptor(e,n),o=Object.getOwnPropertyDescriptor(t,n);s&&o&&Rt(s.value,o.value)&&r.add(n)}return r}function ii(e){if(e.type===ye.AST_NODE_TYPES.SpreadElement)return Symbol("COMPLEX_EXPRESSION");switch(e.type){case ye.AST_NODE_TYPES.Literal:return e.value;case ye.AST_NODE_TYPES.ObjectExpression:{let t={};for(let r of e.properties)r.type===ye.AST_NODE_TYPES.Property&&r.key.type===ye.AST_NODE_TYPES.Identifier&&!r.computed&&(r.value.type===ye.AST_NODE_TYPES.Literal?t[r.key.name]=r.value.value:r.value.type===ye.AST_NODE_TYPES.ObjectExpression?t[r.key.name]=ii(r.value):t[r.key.name]=Symbol("COMPLEX_EXPRESSION"));return t}case ye.AST_NODE_TYPES.ArrayExpression:return e.elements.map(t=>{if(!(!t||t.type===ye.AST_NODE_TYPES.SpreadElement))return t.type===ye.AST_NODE_TYPES.Literal?t.value:Symbol("COMPLEX_EXPRESSION")});default:return Symbol("COMPLEX_EXPRESSION")}}function Ia(e){return e.type===ye.AST_NODE_TYPES.Identifier?e.name:e.type===ye.AST_NODE_TYPES.MemberExpression&&e.property.type===ye.AST_NODE_TYPES.Identifier&&!e.computed?e.property.name:null}var jn=q({name:"no-redundant-function-params",meta:{type:"suggestion",docs:{description:"Disallow calling functions with redundant default parameters"},messages:{redundantParams:"Function call has redundant parameters matching its default values and can be removed: {{details}}"},fixable:"code",schema:[B(xa)]},defaultOptions:[{functions:[]}],create(e,[t]){let r=new Map;for(let n of t.functions)r.set(n.name,n.defaults);return{CallExpression(n){let s=Ia(n.callee);if(!s)return;let o=r.get(s);if(!o)return;let i=n.arguments;if(i.length===0)return;let p=-1,a=!1,l=new Map,u=new Set,d=new Map,g=[];for(let y=0;y<i.length;y++){if(y>=o.length){p=y;continue}let E=o[y],b=i[y];if(!b||b.type===ye.AST_NODE_TYPES.SpreadElement){p=y;continue}let f=ii(b);if(E===void 0){p=y;continue}if(Rt(f,E)){b.type===ye.AST_NODE_TYPES.ObjectExpression?(u.add(y),g.push({type:"object",position:y+1})):(d.set(y,f),g.push({type:"simple",position:y+1,value:f}));continue}if(b.type===ye.AST_NODE_TYPES.ObjectExpression&&b.properties.length===0&&typeof E=="object"&&E!==null&&Object.keys(E).length>0){u.add(y),g.push({type:"object",position:y+1});continue}let A=Ca(f,E);if(A.size>0){let I=typeof E=="object"&&E!==null?Object.keys(E).length:0;if(b.type===ye.AST_NODE_TYPES.ObjectExpression&&b.properties.length===A.size&&b.properties.length===I){u.add(y),g.push({type:"object",position:y+1});continue}else a=!0,l.set(y,A),g.push({type:"partialObject",position:y+1,redundantProperties:Array.from(A)}),p=y}else p=y}if(p<i.length-1||a||u.size>0){let y=function(){let b=[];for(let f of g)if(f.type==="simple")b.push(`Param ${f.position} with value ${JSON.stringify(f.value)}`);else if(f.type==="object")b.push(`Param ${f.position} (object)`);else{let A=f.redundantProperties||[],I=o?o[f.position-1]:void 0;if(typeof I=="object"&&I!==null){let m=I;for(let C of A)if(C in m){let h=Object.getOwnPropertyDescriptor(m,C);h&&b.push(`Param ${f.position} property "${C}" with value ${JSON.stringify(h.value)}`)}}}return{messageId:"redundantParams",data:{details:b.join(", ")}}};var x=y;let E=y();e.report({node:n,messageId:E.messageId,data:E.data,fix(b){let f=[];if(a)for(let[I,m]of l){let C=i[I];if(C&&C.type===ye.AST_NODE_TYPES.ObjectExpression){let h=[];for(let P of C.properties)P.type===ye.AST_NODE_TYPES.Property&&P.key.type===ye.AST_NODE_TYPES.Identifier&&!P.computed&&m.has(P.key.name)||h.push(P);let w=h.map(P=>e.sourceCode.getText(P));f.push(b.replaceText(C,`{ ${w.join(", ")} }`))}}let A=-1;for(let I=i.length-1;I>=0;I--)if(!u.has(I)&&I<=p){A=I;break}if(A<i.length-1)if(A===-1){let I=e.sourceCode.getTokenAfter(n.callee),m=e.sourceCode.getLastToken(n);I&&m&&f.push(b.replaceTextRange([I.range[1],m.range[0]],""))}else{let I=i[A],m=e.sourceCode.getLastToken(n);m&&I&&f.push(b.replaceTextRange([I.range[1],m.range[0]],""))}return f.length>0?f:null}})}}}}});var we=require("@typescript-eslint/utils");function Aa(e){let t=e.parent;for(;t;){if(t.type===we.AST_NODE_TYPES.AwaitExpression||t.type===we.AST_NODE_TYPES.MemberExpression&&t.object===e&&t.property.type===we.AST_NODE_TYPES.Identifier&&t.property.name==="then"||t.type===we.AST_NODE_TYPES.ArrowFunctionExpression&&t.body===e)return!0;if(t.type===we.AST_NODE_TYPES.ArrayExpression&&t.parent.type===we.AST_NODE_TYPES.CallExpression){let r=t.parent;if(r.callee.type===we.AST_NODE_TYPES.MemberExpression&&r.callee.object.type===we.AST_NODE_TYPES.Identifier&&r.callee.object.name==="Promise"&&r.callee.property.type===we.AST_NODE_TYPES.Identifier&&["all","allSettled","race"].includes(r.callee.property.name))return!0}if(t.parent)t=t.parent;else break}return!1}function wa(e){let{callee:t}=e;return t.type===we.AST_NODE_TYPES.Identifier&&t.name==="require"||t.type===we.AST_NODE_TYPES.MemberExpression&&t.object.type===we.AST_NODE_TYPES.Identifier&&t.object.name==="require"}var Ln=q({name:"no-sync-dynamic-import",meta:{type:"problem",docs:{description:"Disallow synchronous dynamic imports and require statements, only allow async dynamic imports with await"},messages:{syncDynamicImport:"Synchronous dynamic import() is not allowed. Use regular import statement or await import() for dynamic imports.",requireNotAllowed:"require() statements are not allowed. Use ES6 import statements instead."},schema:[]},defaultOptions:[],create(e){return{ImportExpression(t){Aa(t)||e.report({node:t,messageId:"syncDynamicImport"})},TSImportType(t){e.report({node:t,messageId:"syncDynamicImport"})},CallExpression(t){wa(t)&&e.report({node:t,messageId:"requireNotAllowed"})}}}});var L=require("@typescript-eslint/utils"),Ft=require("zod/v4");var Ra=Ft.z.object({mainComponentRegex:Ft.z.string().optional(),mainComponentSelector:Ft.z.string().optional()}),Fa=/^[A-Z][A-Za-z0-9]*$/,Mn=q({name:"sort-react-components-and-styles",meta:{type:"suggestion",docs:{description:"Sort React components and styles with styles placed above their first usage"},fixable:"code",schema:[B(Ra)],messages:{stylesShouldBeAboveUsage:"Style definitions should be placed above the first component that uses them",mainComponentShouldBeFirst:"Main component should be placed before other components"}},defaultOptions:[{}],create(e,[t]){let r=e.sourceCode,n=t.mainComponentRegex?new RegExp(t.mainComponentRegex):void 0,s=t.mainComponentSelector;if(!e.filename.endsWith(".tsx"))return{};let i=new Set,p=new Map,a=[],l=[],u=new Set;function d(T){let S=T.node;if(S.type===L.AST_NODE_TYPES.VariableDeclaration){for(let R of S.declarations)if(R.id.type===L.AST_NODE_TYPES.Identifier&&R.id.name===T.name&&R.init)return R.init}if(S.type===L.AST_NODE_TYPES.ExportNamedDeclaration){let R=S.declaration;if(R&&R.type===L.AST_NODE_TYPES.VariableDeclaration){for(let O of R.declarations)if(O.id.type===L.AST_NODE_TYPES.Identifier&&O.id.name===T.name&&O.init)return O.init}}return null}function g(T){let S=new Set;return Ne(T,R=>(R.type===L.AST_NODE_TYPES.Identifier&&R.name!=="styled"&&R.name!=="css"&&S.add(R.name),!1),r),S}function x(T){return Fa.test(T)}function y(T){if(T.type!==L.AST_NODE_TYPES.CallExpression)return!1;let S=T.callee;return S.type===L.AST_NODE_TYPES.Identifier?S.name==="memo"||S.name==="forwardRef":S.type===L.AST_NODE_TYPES.MemberExpression&&S.property.type===L.AST_NODE_TYPES.Identifier?S.property.name==="memo"||S.property.name==="forwardRef":!1}function E(T){if(T.type===L.AST_NODE_TYPES.JSXElement||T.type===L.AST_NODE_TYPES.JSXFragment)return!0;if(T.type===L.AST_NODE_TYPES.BlockStatement){for(let S of T.body)if(S.type===L.AST_NODE_TYPES.ReturnStatement&&S.argument)return E(S.argument)}if(T.type===L.AST_NODE_TYPES.ArrayExpression){for(let S of T.elements)if(S&&(S.type===L.AST_NODE_TYPES.JSXElement||S.type===L.AST_NODE_TYPES.JSXFragment))return!0}return!1}function b(T){if(T.type!==L.AST_NODE_TYPES.ArrowFunctionExpression)return!1;let S=T.body;if(S.type===L.AST_NODE_TYPES.ArrowFunctionExpression){let R=S.body;if(E(R))return!0}return!1}function f(T){if(T.type===L.AST_NODE_TYPES.TaggedTemplateExpression){let S=T.tag;if(S.type===L.AST_NODE_TYPES.MemberExpression&&S.object.type===L.AST_NODE_TYPES.Identifier&&S.object.name==="styled")return!0;if(S.type===L.AST_NODE_TYPES.CallExpression){let R=S.callee;if(R.type===L.AST_NODE_TYPES.Identifier&&R.name==="styled")return!0}}return!1}function A(T){if(T.type===L.AST_NODE_TYPES.TaggedTemplateExpression){let S=T.tag;if(S.type===L.AST_NODE_TYPES.Identifier&&S.name==="css")return!0}return!1}function I(T,S){if(T.id.type!==L.AST_NODE_TYPES.Identifier)return;let R=T.id.name,O=T.init;if(O){if(f(O)||A(O)){l.push({node:S,name:R});return}if((x(R)||O.type===L.AST_NODE_TYPES.ArrowFunctionExpression)&&(O.type===L.AST_NODE_TYPES.ArrowFunctionExpression||O.type===L.AST_NODE_TYPES.FunctionExpression||y(O))){if(O.type===L.AST_NODE_TYPES.ArrowFunctionExpression||O.type===L.AST_NODE_TYPES.FunctionExpression){if(E(O.body)){i.add(R);return}}else if(y(O)){i.add(R);return}}O.type===L.AST_NODE_TYPES.Identifier&&p.set(R,O.name),x(R)||b(O)&&i.add(R)}}function m(T){return T.type===L.AST_NODE_TYPES.ExportDefaultDeclaration||T.type===L.AST_NODE_TYPES.ExportNamedDeclaration}function C(T){if(T.type===L.AST_NODE_TYPES.FunctionDeclaration)return T.id?T.id.name:null;if(T.type===L.AST_NODE_TYPES.VariableDeclaration){let S=T.declarations[0];if(S&&S.id.type===L.AST_NODE_TYPES.Identifier)return S.id.name}if(T.type===L.AST_NODE_TYPES.ExportDefaultDeclaration){let S=T.declaration;if(S.type===L.AST_NODE_TYPES.FunctionDeclaration)return S.id?S.id.name:"default";if(S.type===L.AST_NODE_TYPES.Identifier)return S.name}if(T.type===L.AST_NODE_TYPES.ExportNamedDeclaration){let S=T.declaration;if(S&&S.type===L.AST_NODE_TYPES.FunctionDeclaration)return S.id?S.id.name:null;if(S&&S.type===L.AST_NODE_TYPES.VariableDeclaration){let R=S.declarations[0];if(R&&R.id.type===L.AST_NODE_TYPES.Identifier)return R.id.name}}return null}function h(T,S){return s?u.has(T):n?n.test(S):m(T)}function w(T){let S=new Set;Ne(T.node,R=>{if(R.type===L.AST_NODE_TYPES.Identifier)for(let O of l)O.name===R.name&&(S.add(O.name),(O.firstUsagePosition===void 0||R.range[0]<O.firstUsagePosition)&&(O.firstUsagePosition=R.range[0]));if(R.type===L.AST_NODE_TYPES.JSXElement){let O=R.openingElement;if(O.name.type===L.AST_NODE_TYPES.JSXIdentifier)for(let D of l)D.name===O.name.name&&(S.add(D.name),(D.firstUsagePosition===void 0||O.name.range[0]<D.firstUsagePosition)&&(D.firstUsagePosition=O.name.range[0]))}return!1},r),T.usedStyles=S}function P(T){if(T.type===L.AST_NODE_TYPES.VariableDeclaration){for(let S of T.declarations)I(S,T);return}if(T.type===L.AST_NODE_TYPES.FunctionDeclaration){x(T.id.name)&&E(T.body)&&i.add(T.id.name);return}if(T.type===L.AST_NODE_TYPES.ExportNamedDeclaration&&T.declaration){let S=T.declaration;if(S.type===L.AST_NODE_TYPES.VariableDeclaration){for(let R of S.declarations)I(R,T);return}if(S.type===L.AST_NODE_TYPES.FunctionDeclaration&&S.id){x(S.id.name)&&E(S.body)&&i.add(S.id.name);return}}if(T.type===L.AST_NODE_TYPES.ExportDefaultDeclaration){let S=T.declaration;S.type===L.AST_NODE_TYPES.Identifier&&i.add(S.name),(S.type===L.AST_NODE_TYPES.FunctionDeclaration||S.type===L.AST_NODE_TYPES.ArrowFunctionExpression||S.type===L.AST_NODE_TYPES.FunctionExpression)&&(S.type===L.AST_NODE_TYPES.FunctionDeclaration?S.id?i.add(S.id.name):i.add("default"):E(S.body)&&i.add("default"))}}function v(T,S=new Set){if(i.has(T))return!0;if(S.has(T))return!1;S.add(T);let R=p.get(T);return R?v(R,S):!1}let c={};return s&&(c[s]=T=>{let S=T;for(;S.parent&&S.parent.type!==L.AST_NODE_TYPES.Program;)S=S.parent;S.parent&&(S.type===L.AST_NODE_TYPES.VariableDeclaration||S.type===L.AST_NODE_TYPES.FunctionDeclaration||S.type===L.AST_NODE_TYPES.ExportNamedDeclaration||S.type===L.AST_NODE_TYPES.ExportDefaultDeclaration)&&u.add(S)}),c["Program:exit"]=T=>{let S=0;for(let j of T.body){if(j.type===L.AST_NODE_TYPES.ImportDeclaration){S+=1;continue}break}for(let j of T.body)P(j);for(let j of T.body){let Y=C(j);if(Y&&v(Y)){let H=h(j,Y);a.push({node:j,name:Y,isMainComponent:H,usedStyles:new Set})}}for(let j of a)w(j);let R=new Set;for(let j of l)R.add(j.name);let O=new Map;for(let j=0;j<T.body.length;j+=1){let Y=T.body[j];for(let H of l)H.node===Y&&O.set(H.name,j)}let D=new Map;for(let j of l){let Y=d(j),H=new Set;if(Y){let ue=g(Y);for(let ge of ue)R.has(ge)&&ge!==j.name&&H.add(ge)}D.set(j.name,H)}let Z=new Map;for(let j of l){let Y=D.get(j.name);if(!Y)continue;let H=O.get(j.name);if(H!==void 0)for(let ue of Y){let ge=Z.get(ue);(ge===void 0||H<ge)&&Z.set(ue,H)}}let K=[];for(let j of l){if(j.firstUsagePosition===void 0)continue;let Y=T.body.indexOf(j.node),H=-1;for(let Te of a){if(!Te.usedStyles.has(j.name))continue;let Ce=T.body.indexOf(Te.node);(H===-1||Ce<H)&&(H=Ce)}let ue=Z.get(j.name);if(ue!==void 0&&(H===-1||ue<H)&&(H=ue),H===-1)continue;let ge=-1;for(let Te of a){let Ce=T.body.indexOf(Te.node);Ce<H&&Ce>ge&&(ge=Ce)}let Ee=Y<H,Re=Y>ge,Fe=-1,Ye=D.get(j.name);if(Ye)for(let Te of Ye){let Ce=O.get(Te);Ce!==void 0&&Ce>Fe&&(Fe=Ce)}let $n=Y>Fe;if(!(Ee&&Re&&$n)){let Te=ge+1;if(Fe+1>Te&&(Te=Fe+1),Te<S&&(Te=S),Te>H)continue;K.push({style:j,targetPosition:Te})}}let V=null;if(a.length>1){let j=a.map(H=>({c:H,idx:T.body.indexOf(H.node)})).sort((H,ue)=>H.idx-ue.idx)[0]?.c,Y=a.find(H=>H.isMainComponent)||null;j&&Y&&j.node!==Y.node&&(V={component:Y,targetBefore:j.node})}if(K.length>0||V){let j=K[0]?.style.node||V?.component.node||T,Y=K.length>0?"stylesShouldBeAboveUsage":"mainComponentShouldBeFirst";e.report({node:j,messageId:Y,fix:F(K,V,T.body)})}},c;function F(T,S,R){return function*(O){T.sort((Z,K)=>Z.targetPosition-K.targetPosition);for(let{style:Z}of T){let K=r.getCommentsBefore(Z.node),V=Z.node.range[0],j=Z.node.range[1];K.length>0&&K[0]&&(V=K[0].range[0]),V===Z.node.range[0]&&r.text.slice(0,V).trim().length===0&&(V=0),yield O.removeRange([V,j])}let D=new Map;for(let Z of T){let K=D.get(Z.targetPosition)||[];K.push(Z),D.set(Z.targetPosition,K)}for(let[Z,K]of D){let V=R[Z];if(!V)continue;let j=r.getCommentsBefore(V),Y=j.length>0&&j[0]?j[0].range[0]:V.range[0],H=[];for(let{style:ue}of K){let ge=r.getCommentsBefore(ue.node),Ee=r.getText(ue.node);ge.length>0&&(Ee=`${ge.map(Fe=>r.getText(Fe)).join(`
|
|
46
|
+
`)}}}return{Program(y){s.push(...y.body)},TSTypeAliasDeclaration(y){if(s.some(b=>b.type===Se.AST_NODE_TYPES.ExportNamedDeclaration&&b.declaration===y?!0:b===y)){let b=o(y);b&&n.set(y.id.name,{node:y,name:y.id.name,statement:b})}},TSInterfaceDeclaration(y){if(s.some(b=>b.type===Se.AST_NODE_TYPES.ExportNamedDeclaration&&b.declaration===y?!0:b===y)){let b=o(y);b&&n.set(y.id.name,{node:y,name:y.id.name,statement:b})}},TSTypeReference(y){if(y.typeName.type===Se.AST_NODE_TYPES.Identifier){if(u(y))return;let E=i(y),b=p(y),f=a(y);d.push({typeName:y.typeName.name,node:y,inFunctionArgs:E,inFCProps:b,inGenericArgAtFunctionCall:f,usagePosition:y.range[0]})}},"Program:exit"(){let y=new Map;function E(f){if(!t.checkOnly||t.checkOnly.length===0)return!0;for(let A of t.checkOnly)if(A==="function-args"&&f.inFunctionArgs||A==="FC"&&f.inFCProps||A==="generic-args-at-fn-calls"&&f.inGenericArgAtFunctionCall)return!0;return!1}for(let f of d){let{typeName:A,node:I}=f;if(!n.has(A)||!E(f))continue;let m=o(I),C=n.get(A);if(!m||!C||m===C.statement)continue;y.has(A)||y.set(A,[]);let h=y.get(A);if(!h)return;h.includes(m)||h.push(m)}let b=[];for(let[f,A]of y)if(A.length>0){if(A.length===0)continue;let I=A[0];if(!I)continue;let m=Number.MAX_SAFE_INTEGER,C=!1;for(let w of A)w.range[0]<I.range[0]&&(I=w);for(let w of d)E(w)&&w.typeName===f&&o(w.node)===I&&w.usagePosition<m&&(m=w.usagePosition,C=w.inFunctionArgs);if(!!(t.checkOnly&&t.checkOnly.length>0)){let w=Number.MAX_SAFE_INTEGER;for(let v of d){if(v.typeName!==f)continue;let c=o(v.node);if(!c)continue;let F=s.indexOf(c);F!==-1&&F<w&&(w=F)}let P=s.indexOf(I);if(w!==Number.MAX_SAFE_INTEGER&&P!==-1&&w<P)continue}else{let w=Number.MAX_SAFE_INTEGER;for(let v of d){if(v.typeName!==f||l(v.node))continue;let c=o(v.node);if(!c)continue;let F=s.indexOf(c);F!==-1&&F<w&&(w=F)}let P=s.indexOf(I);if(w!==Number.MAX_SAFE_INTEGER&&P!==-1&&w<P)continue}b.push({typeName:f,firstUsage:I,firstUsagePosition:m,firstUsageInFunctionArgs:C})}b.length>0&&g(b)}}}});var ie=require("@typescript-eslint/utils"),it=Oe(require("zod/v4"));var da=["tsx"],ga=/^[A-Z][A-Za-z0-9]*$/,Sa=it.object({extensions:it.array(it.string()).optional()}),Nn=q({name:"react-single-export",meta:{type:"problem",docs:{description:"Enforces only one export per React component file to support fast refresh"},messages:{multipleExports:"React component files should have only one export to support fast refresh, if you want to export multiple components, use a separate file for each component. Type-only exports are allowed."},schema:[B(Sa)]},defaultOptions:[{}],create(e,[t]){let r=e.getFilename(),n=t.extensions??da,s=!1;for(let m of n)if(r.endsWith(m)){s=!0;break}if(!s)return{};let o=e.sourceCode,i=new Set,p=new Map;function a(m){return ga.test(m)}function l(m){if(m.type!==ie.AST_NODE_TYPES.CallExpression)return!1;let C=m.callee;return C.type===ie.AST_NODE_TYPES.Identifier?C.name==="memo"||C.name==="forwardRef":C.type===ie.AST_NODE_TYPES.MemberExpression&&C.property.type===ie.AST_NODE_TYPES.Identifier?C.property.name==="memo"||C.property.name==="forwardRef":!1}function u(m){if(m.type===ie.AST_NODE_TYPES.JSXElement||m.type===ie.AST_NODE_TYPES.JSXFragment)return!0;if(m.type===ie.AST_NODE_TYPES.ArrayExpression){for(let C of m.elements)if(C&&(C.type===ie.AST_NODE_TYPES.JSXElement||C.type===ie.AST_NODE_TYPES.JSXFragment))return!0}return!1}function d(m){if(m.type!==ie.AST_NODE_TYPES.ArrowFunctionExpression)return!1;let C=m.body;if(C.type===ie.AST_NODE_TYPES.ArrowFunctionExpression){let h=C.body;if(u(h))return!0}return!1}function g(m){if(m.id.type!==ie.AST_NODE_TYPES.Identifier)return;let C=m.id.name,h=m.init;if(h){if(a(C)&&(h.type===ie.AST_NODE_TYPES.ArrowFunctionExpression||h.type===ie.AST_NODE_TYPES.FunctionExpression||l(h))){i.add(C);return}h.type===ie.AST_NODE_TYPES.Identifier&&p.set(C,h.name),a(C)||d(h)&&i.add(C)}}function x(m){if(m.type===ie.AST_NODE_TYPES.VariableDeclaration){for(let C of m.declarations)g(C);return}if(m.type===ie.AST_NODE_TYPES.FunctionDeclaration&&m.id){a(m.id.name)&&i.add(m.id.name);return}if(m.type===ie.AST_NODE_TYPES.ExportNamedDeclaration&&m.declaration){let C=m.declaration;if(C.type===ie.AST_NODE_TYPES.VariableDeclaration){for(let h of C.declarations)g(h);return}if(C.type===ie.AST_NODE_TYPES.FunctionDeclaration&&C.id){a(C.id.name)&&i.add(C.id.name);return}}}for(let m of o.ast.body)x(m);function y(m,C=new Set){if(i.has(m))return!0;if(C.has(m))return!1;C.add(m);let h=p.get(m);return h?y(h,C):!1}let E=[];function b(m,C,h){E.push({node:m,isType:C,isComponent:h})}for(let m of o.ast.body){if(m.type===ie.AST_NODE_TYPES.ExportNamedDeclaration){let C=m.exportKind==="type";if(m.declaration){let h=m.declaration;if(h.type===ie.AST_NODE_TYPES.TSTypeAliasDeclaration||h.type===ie.AST_NODE_TYPES.TSInterfaceDeclaration){b(h,!0,!1);continue}if(h.type===ie.AST_NODE_TYPES.VariableDeclaration){for(let w of h.declarations){if(w.id.type!==ie.AST_NODE_TYPES.Identifier)continue;let P=w.id.name,v=y(P);b(w,C,v)}continue}if(h.type===ie.AST_NODE_TYPES.FunctionDeclaration){let w=h.id?.name,P=w?y(w)||a(w):!1;b(h,C,P);continue}b(h,C,!1);continue}if(m.specifiers.length>0)for(let h of m.specifiers){if(h.local.type!==ie.AST_NODE_TYPES.Identifier)continue;let w=h.local.name,P=y(w);b(h,C,P)}continue}if(m.type===ie.AST_NODE_TYPES.ExportDefaultDeclaration){let C=m.declaration;if(C.type===ie.AST_NODE_TYPES.Identifier){let h=y(C.name)||a(C.name);b(m,!1,h);continue}if(C.type===ie.AST_NODE_TYPES.FunctionDeclaration||C.type===ie.AST_NODE_TYPES.ArrowFunctionExpression||C.type===ie.AST_NODE_TYPES.FunctionExpression||C.type===ie.AST_NODE_TYPES.CallExpression){b(m,!1,!0);continue}b(m,!1,!1);continue}}let f=!1;for(let m of E)if(!m.isType&&m.isComponent){f=!0;break}if(!f)return{};let A=[];for(let m of E)m.isType||A.push(m);let I=-1;for(let[m,C]of A.entries())if(C.isComponent){I=m;break}if(I===-1)return{};for(let[m,C]of A.entries())if(m!==I){e.report({node:C.node,messageId:"multipleExports"});break}return{}}});var Je=require("@typescript-eslint/utils"),At=require("zod/v4");function wt(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Ta(e){return e.callee.type===Je.AST_NODE_TYPES.Identifier?e.callee.name==="useState":e.callee.type===Je.AST_NODE_TYPES.MemberExpression&&e.callee.object.type===Je.AST_NODE_TYPES.Identifier&&e.callee.property.type===Je.AST_NODE_TYPES.Identifier?e.callee.object.name==="React"&&e.callee.property.name==="useState":!1}var ha=At.z.object({ignorePrefixes:At.z.array(At.z.string()).optional()});function ri(e,t){for(let r of t)if(e.startsWith(r))return e.slice(r.length);return e}function Ea(e){return`set${wt(e)}`}var Dn=q({name:"use-state-setter-naming",meta:{type:"problem",docs:{description:"Enforce consistent naming convention for useState destructuring where setter should be set{Value}"},messages:{incorrectSetterName:'useState setter should follow the pattern "set{{expectedName}}" with a "set" prefix but got "{{actualName}}"',useSuggestedName:'Use "{{expectedSetterName}}" instead'},hasSuggestions:!0,schema:[B(ha)]},defaultOptions:[{ignorePrefixes:[]}],create(e,[t]){return{VariableDeclarator(r){if(!r.init||r.init.type!==Je.AST_NODE_TYPES.CallExpression||!Ta(r.init)||r.id.type!==Je.AST_NODE_TYPES.ArrayPattern||r.id.elements.length!==2)return;let[n,s]=r.id.elements;if(!n||!s||n.type!==Je.AST_NODE_TYPES.Identifier||s.type!==Je.AST_NODE_TYPES.Identifier)return;let o=n.name,i=s.name,p=t.ignorePrefixes||[],a=ri(o,p),l=ri(i,p);if(a===""){if(!l.startsWith("set")){let d=`set${wt(o)}`;e.report({node:s,messageId:"incorrectSetterName",data:{expectedName:wt(o),actualName:i},suggest:[{messageId:"useSuggestedName",data:{expectedSetterName:d},fix:g=>g.replaceText(s,d)}]})}return}let u=Ea(a);l!==u&&e.report({node:s,messageId:"incorrectSetterName",data:{expectedName:wt(a),actualName:i},suggest:[{messageId:"useSuggestedName",data:{expectedSetterName:u},fix:d=>d.replaceText(s,u)}]})}}}});var ye=require("@typescript-eslint/utils"),Ke=require("zod/v4");var ba=Ke.z.object({name:Ke.z.string(),defaults:Ke.z.array(Ke.z.unknown())}),xa=Ke.z.object({functions:Ke.z.array(ba)});function Rt(e,t){if(e===t)return!0;if(e===null||t===null||e===void 0||t===void 0)return e===t;if(typeof e!=typeof t||typeof e!="object"||Array.isArray(e)!==Array.isArray(t))return!1;if(Array.isArray(e)&&Array.isArray(t))return e.length!==t.length?!1:e.every((s,o)=>Rt(s,t[o]));let r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(let s of r){if(!n.includes(s))return!1;let o=Object.getOwnPropertyDescriptor(e,s),i=Object.getOwnPropertyDescriptor(t,s);if(!o||!i)return!1;let p=o.value,a=i.value;if(!Rt(p,a))return!1}return!0}function Ca(e,t){let r=new Set;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return r;for(let n in e){if(!(n in t))continue;let s=Object.getOwnPropertyDescriptor(e,n),o=Object.getOwnPropertyDescriptor(t,n);s&&o&&Rt(s.value,o.value)&&r.add(n)}return r}function ii(e){if(e.type===ye.AST_NODE_TYPES.SpreadElement)return Symbol("COMPLEX_EXPRESSION");switch(e.type){case ye.AST_NODE_TYPES.Literal:return e.value;case ye.AST_NODE_TYPES.ObjectExpression:{let t={};for(let r of e.properties)r.type===ye.AST_NODE_TYPES.Property&&r.key.type===ye.AST_NODE_TYPES.Identifier&&!r.computed&&(r.value.type===ye.AST_NODE_TYPES.Literal?t[r.key.name]=r.value.value:r.value.type===ye.AST_NODE_TYPES.ObjectExpression?t[r.key.name]=ii(r.value):t[r.key.name]=Symbol("COMPLEX_EXPRESSION"));return t}case ye.AST_NODE_TYPES.ArrayExpression:return e.elements.map(t=>{if(!(!t||t.type===ye.AST_NODE_TYPES.SpreadElement))return t.type===ye.AST_NODE_TYPES.Literal?t.value:Symbol("COMPLEX_EXPRESSION")});default:return Symbol("COMPLEX_EXPRESSION")}}function Ia(e){return e.type===ye.AST_NODE_TYPES.Identifier?e.name:e.type===ye.AST_NODE_TYPES.MemberExpression&&e.property.type===ye.AST_NODE_TYPES.Identifier&&!e.computed?e.property.name:null}var jn=q({name:"no-redundant-function-params",meta:{type:"suggestion",docs:{description:"Disallow calling functions with redundant default parameters"},messages:{redundantParams:"Function call has redundant parameters matching its default values and can be removed: {{details}}"},fixable:"code",schema:[B(xa)]},defaultOptions:[{functions:[]}],create(e,[t]){let r=new Map;for(let n of t.functions)r.set(n.name,n.defaults);return{CallExpression(n){let s=Ia(n.callee);if(!s)return;let o=r.get(s);if(!o)return;let i=n.arguments;if(i.length===0)return;let p=-1,a=!1,l=new Map,u=new Set,d=new Map,g=[];for(let y=0;y<i.length;y++){if(y>=o.length){p=y;continue}let E=o[y],b=i[y];if(!b||b.type===ye.AST_NODE_TYPES.SpreadElement){p=y;continue}let f=ii(b);if(E===void 0){p=y;continue}if(Rt(f,E)){b.type===ye.AST_NODE_TYPES.ObjectExpression?(u.add(y),g.push({type:"object",position:y+1})):(d.set(y,f),g.push({type:"simple",position:y+1,value:f}));continue}if(b.type===ye.AST_NODE_TYPES.ObjectExpression&&b.properties.length===0&&typeof E=="object"&&E!==null&&Object.keys(E).length>0){u.add(y),g.push({type:"object",position:y+1});continue}let A=Ca(f,E);if(A.size>0){let I=typeof E=="object"&&E!==null?Object.keys(E).length:0;if(b.type===ye.AST_NODE_TYPES.ObjectExpression&&b.properties.length===A.size&&b.properties.length===I){u.add(y),g.push({type:"object",position:y+1});continue}else a=!0,l.set(y,A),g.push({type:"partialObject",position:y+1,redundantProperties:Array.from(A)}),p=y}else p=y}if(p<i.length-1||a||u.size>0){let y=function(){let b=[];for(let f of g)if(f.type==="simple")b.push(`Param ${f.position} with value ${JSON.stringify(f.value)}`);else if(f.type==="object")b.push(`Param ${f.position} (object)`);else{let A=f.redundantProperties||[],I=o?o[f.position-1]:void 0;if(typeof I=="object"&&I!==null){let m=I;for(let C of A)if(C in m){let h=Object.getOwnPropertyDescriptor(m,C);h&&b.push(`Param ${f.position} property "${C}" with value ${JSON.stringify(h.value)}`)}}}return{messageId:"redundantParams",data:{details:b.join(", ")}}};var x=y;let E=y();e.report({node:n,messageId:E.messageId,data:E.data,fix(b){let f=[];if(a)for(let[I,m]of l){let C=i[I];if(C&&C.type===ye.AST_NODE_TYPES.ObjectExpression){let h=[];for(let P of C.properties)P.type===ye.AST_NODE_TYPES.Property&&P.key.type===ye.AST_NODE_TYPES.Identifier&&!P.computed&&m.has(P.key.name)||h.push(P);let w=h.map(P=>e.sourceCode.getText(P));f.push(b.replaceText(C,`{ ${w.join(", ")} }`))}}let A=-1;for(let I=i.length-1;I>=0;I--)if(!u.has(I)&&I<=p){A=I;break}if(A<i.length-1)if(A===-1){let I=e.sourceCode.getTokenAfter(n.callee),m=e.sourceCode.getLastToken(n);I&&m&&f.push(b.replaceTextRange([I.range[1],m.range[0]],""))}else{let I=i[A],m=e.sourceCode.getLastToken(n);m&&I&&f.push(b.replaceTextRange([I.range[1],m.range[0]],""))}return f.length>0?f:null}})}}}}});var we=require("@typescript-eslint/utils");function Aa(e){let t=e.parent;for(;t;){if(t.type===we.AST_NODE_TYPES.AwaitExpression||t.type===we.AST_NODE_TYPES.MemberExpression&&t.object===e&&t.property.type===we.AST_NODE_TYPES.Identifier&&t.property.name==="then"||t.type===we.AST_NODE_TYPES.ArrowFunctionExpression&&t.body===e)return!0;if(t.type===we.AST_NODE_TYPES.ArrayExpression&&t.parent.type===we.AST_NODE_TYPES.CallExpression){let r=t.parent;if(r.callee.type===we.AST_NODE_TYPES.MemberExpression&&r.callee.object.type===we.AST_NODE_TYPES.Identifier&&r.callee.object.name==="Promise"&&r.callee.property.type===we.AST_NODE_TYPES.Identifier&&["all","allSettled","race"].includes(r.callee.property.name))return!0}if(t.parent)t=t.parent;else break}return!1}function wa(e){let{callee:t}=e;return t.type===we.AST_NODE_TYPES.Identifier&&t.name==="require"||t.type===we.AST_NODE_TYPES.MemberExpression&&t.object.type===we.AST_NODE_TYPES.Identifier&&t.object.name==="require"}var Ln=q({name:"no-sync-dynamic-import",meta:{type:"problem",docs:{description:"Disallow synchronous dynamic imports and require statements, only allow async dynamic imports with await"},messages:{syncDynamicImport:"Synchronous dynamic import() is not allowed. Use regular import statement or await import() for dynamic imports.",requireNotAllowed:"require() statements are not allowed. Use ES6 import statements instead."},schema:[]},defaultOptions:[],create(e){return{ImportExpression(t){Aa(t)||e.report({node:t,messageId:"syncDynamicImport"})},TSImportType(t){e.report({node:t,messageId:"syncDynamicImport"})},CallExpression(t){wa(t)&&e.report({node:t,messageId:"requireNotAllowed"})}}}});var L=require("@typescript-eslint/utils"),Ft=require("zod/v4");var Ra=Ft.z.object({mainComponentRegex:Ft.z.string().optional(),mainComponentSelector:Ft.z.string().optional()}),Fa=/^[A-Z][A-Za-z0-9]*$/,Mn=q({name:"sort-react-components-and-styles",meta:{type:"suggestion",docs:{description:"Sort React components and styles with styles placed above their first usage"},fixable:"code",schema:[B(Ra)],messages:{stylesShouldBeAboveUsage:"Style definitions should be placed above the first component that uses them",mainComponentShouldBeFirst:"Main component should be placed before other components"}},defaultOptions:[{}],create(e,[t]){let r=e.sourceCode,n=t.mainComponentRegex?new RegExp(t.mainComponentRegex):void 0,s=t.mainComponentSelector;if(!e.filename.endsWith(".tsx"))return{};let i=new Set,p=new Map,a=[],l=[],u=new Set;function d(T){let S=T.node;if(S.type===L.AST_NODE_TYPES.VariableDeclaration){for(let R of S.declarations)if(R.id.type===L.AST_NODE_TYPES.Identifier&&R.id.name===T.name&&R.init)return R.init}if(S.type===L.AST_NODE_TYPES.ExportNamedDeclaration){let R=S.declaration;if(R&&R.type===L.AST_NODE_TYPES.VariableDeclaration){for(let O of R.declarations)if(O.id.type===L.AST_NODE_TYPES.Identifier&&O.id.name===T.name&&O.init)return O.init}}return null}function g(T){let S=new Set;return Ne(T,R=>(R.type===L.AST_NODE_TYPES.Identifier&&R.name!=="styled"&&R.name!=="css"&&S.add(R.name),!1),r),S}function x(T){return Fa.test(T)}function y(T){if(T.type!==L.AST_NODE_TYPES.CallExpression)return!1;let S=T.callee;return S.type===L.AST_NODE_TYPES.Identifier?S.name==="memo"||S.name==="forwardRef":S.type===L.AST_NODE_TYPES.MemberExpression&&S.property.type===L.AST_NODE_TYPES.Identifier?S.property.name==="memo"||S.property.name==="forwardRef":!1}function E(T){if(T.type===L.AST_NODE_TYPES.JSXElement||T.type===L.AST_NODE_TYPES.JSXFragment)return!0;if(T.type===L.AST_NODE_TYPES.BlockStatement){for(let S of T.body)if(S.type===L.AST_NODE_TYPES.ReturnStatement&&S.argument)return E(S.argument)}if(T.type===L.AST_NODE_TYPES.ArrayExpression){for(let S of T.elements)if(S&&(S.type===L.AST_NODE_TYPES.JSXElement||S.type===L.AST_NODE_TYPES.JSXFragment))return!0}return!1}function b(T){if(T.type!==L.AST_NODE_TYPES.ArrowFunctionExpression)return!1;let S=T.body;if(S.type===L.AST_NODE_TYPES.ArrowFunctionExpression){let R=S.body;if(E(R))return!0}return!1}function f(T){if(T.type===L.AST_NODE_TYPES.TaggedTemplateExpression){let S=T.tag;if(S.type===L.AST_NODE_TYPES.MemberExpression&&S.object.type===L.AST_NODE_TYPES.Identifier&&S.object.name==="styled")return!0;if(S.type===L.AST_NODE_TYPES.CallExpression){let R=S.callee;if(R.type===L.AST_NODE_TYPES.Identifier&&R.name==="styled")return!0}}return!1}function A(T){if(T.type===L.AST_NODE_TYPES.TaggedTemplateExpression){let S=T.tag;if(S.type===L.AST_NODE_TYPES.Identifier&&S.name==="css")return!0}return!1}function I(T,S){if(T.id.type!==L.AST_NODE_TYPES.Identifier)return;let R=T.id.name,O=T.init;if(O){if(f(O)||A(O)){l.push({node:S,name:R});return}if((x(R)||O.type===L.AST_NODE_TYPES.ArrowFunctionExpression)&&(O.type===L.AST_NODE_TYPES.ArrowFunctionExpression||O.type===L.AST_NODE_TYPES.FunctionExpression||y(O))){if(O.type===L.AST_NODE_TYPES.ArrowFunctionExpression||O.type===L.AST_NODE_TYPES.FunctionExpression){if(E(O.body)){i.add(R);return}}else if(y(O)){i.add(R);return}}O.type===L.AST_NODE_TYPES.Identifier&&p.set(R,O.name),x(R)||b(O)&&i.add(R)}}function m(T){return T.type===L.AST_NODE_TYPES.ExportDefaultDeclaration||T.type===L.AST_NODE_TYPES.ExportNamedDeclaration}function C(T){if(T.type===L.AST_NODE_TYPES.FunctionDeclaration)return T.id?T.id.name:null;if(T.type===L.AST_NODE_TYPES.VariableDeclaration){let S=T.declarations[0];if(S&&S.id.type===L.AST_NODE_TYPES.Identifier)return S.id.name}if(T.type===L.AST_NODE_TYPES.ExportDefaultDeclaration){let S=T.declaration;if(S.type===L.AST_NODE_TYPES.FunctionDeclaration)return S.id?S.id.name:"default";if(S.type===L.AST_NODE_TYPES.Identifier)return S.name}if(T.type===L.AST_NODE_TYPES.ExportNamedDeclaration){let S=T.declaration;if(S&&S.type===L.AST_NODE_TYPES.FunctionDeclaration)return S.id?S.id.name:null;if(S&&S.type===L.AST_NODE_TYPES.VariableDeclaration){let R=S.declarations[0];if(R&&R.id.type===L.AST_NODE_TYPES.Identifier)return R.id.name}}return null}function h(T,S){return s?u.has(T):n?n.test(S):m(T)}function w(T){let S=new Set;Ne(T.node,R=>{if(R.type===L.AST_NODE_TYPES.Identifier)for(let O of l)O.name===R.name&&(S.add(O.name),(O.firstUsagePosition===void 0||R.range[0]<O.firstUsagePosition)&&(O.firstUsagePosition=R.range[0]));if(R.type===L.AST_NODE_TYPES.JSXElement){let O=R.openingElement;if(O.name.type===L.AST_NODE_TYPES.JSXIdentifier)for(let D of l)D.name===O.name.name&&(S.add(D.name),(D.firstUsagePosition===void 0||O.name.range[0]<D.firstUsagePosition)&&(D.firstUsagePosition=O.name.range[0]))}return!1},r),T.usedStyles=S}function P(T){if(T.type===L.AST_NODE_TYPES.VariableDeclaration){for(let S of T.declarations)I(S,T);return}if(T.type===L.AST_NODE_TYPES.FunctionDeclaration){x(T.id.name)&&E(T.body)&&i.add(T.id.name);return}if(T.type===L.AST_NODE_TYPES.ExportNamedDeclaration&&T.declaration){let S=T.declaration;if(S.type===L.AST_NODE_TYPES.VariableDeclaration){for(let R of S.declarations)I(R,T);return}if(S.type===L.AST_NODE_TYPES.FunctionDeclaration&&S.id){x(S.id.name)&&E(S.body)&&i.add(S.id.name);return}}if(T.type===L.AST_NODE_TYPES.ExportDefaultDeclaration){let S=T.declaration;S.type===L.AST_NODE_TYPES.Identifier&&i.add(S.name),(S.type===L.AST_NODE_TYPES.FunctionDeclaration||S.type===L.AST_NODE_TYPES.ArrowFunctionExpression||S.type===L.AST_NODE_TYPES.FunctionExpression)&&(S.type===L.AST_NODE_TYPES.FunctionDeclaration?S.id?i.add(S.id.name):i.add("default"):E(S.body)&&i.add("default"))}}function v(T,S=new Set){if(i.has(T))return!0;if(S.has(T))return!1;S.add(T);let R=p.get(T);return R?v(R,S):!1}let c={};return s&&(c[s]=T=>{let S=T;for(;S.parent&&S.parent.type!==L.AST_NODE_TYPES.Program;)S=S.parent;S.parent&&(S.type===L.AST_NODE_TYPES.VariableDeclaration||S.type===L.AST_NODE_TYPES.FunctionDeclaration||S.type===L.AST_NODE_TYPES.ExportNamedDeclaration||S.type===L.AST_NODE_TYPES.ExportDefaultDeclaration)&&u.add(S)}),c["Program:exit"]=T=>{let S=0;for(let j of T.body){if(j.type===L.AST_NODE_TYPES.ImportDeclaration){S+=1;continue}break}for(let j of T.body)P(j);for(let j of T.body){let Y=C(j);if(Y&&v(Y)){let H=h(j,Y);a.push({node:j,name:Y,isMainComponent:H,usedStyles:new Set,isExported:m(j)})}}if(!s&&n&&!a.some(j=>j.isMainComponent))for(let j of a)j.isExported&&(j.isMainComponent=!0);for(let j of a)w(j);let R=new Set;for(let j of l)R.add(j.name);let O=new Map;for(let j=0;j<T.body.length;j+=1){let Y=T.body[j];for(let H of l)H.node===Y&&O.set(H.name,j)}let D=new Map;for(let j of l){let Y=d(j),H=new Set;if(Y){let ue=g(Y);for(let ge of ue)R.has(ge)&&ge!==j.name&&H.add(ge)}D.set(j.name,H)}let Z=new Map;for(let j of l){let Y=D.get(j.name);if(!Y)continue;let H=O.get(j.name);if(H!==void 0)for(let ue of Y){let ge=Z.get(ue);(ge===void 0||H<ge)&&Z.set(ue,H)}}let K=[];for(let j of l){if(j.firstUsagePosition===void 0)continue;let Y=T.body.indexOf(j.node),H=-1;for(let Te of a){if(!Te.usedStyles.has(j.name))continue;let Ce=T.body.indexOf(Te.node);(H===-1||Ce<H)&&(H=Ce)}let ue=Z.get(j.name);if(ue!==void 0&&(H===-1||ue<H)&&(H=ue),H===-1)continue;let ge=-1;for(let Te of a){let Ce=T.body.indexOf(Te.node);Ce<H&&Ce>ge&&(ge=Ce)}let Ee=Y<H,Re=Y>ge,Fe=-1,Ye=D.get(j.name);if(Ye)for(let Te of Ye){let Ce=O.get(Te);Ce!==void 0&&Ce>Fe&&(Fe=Ce)}let $n=Y>Fe;if(!(Ee&&Re&&$n)){let Te=ge+1;if(Fe+1>Te&&(Te=Fe+1),Te<S&&(Te=S),Te>H)continue;K.push({style:j,targetPosition:Te})}}let V=null;if(a.length>1){let j=a.map(H=>({c:H,idx:T.body.indexOf(H.node)})).sort((H,ue)=>H.idx-ue.idx)[0]?.c,Y=a.find(H=>H.isMainComponent)||null;j&&Y&&j.node!==Y.node&&(V={component:Y,targetBefore:j.node})}if(K.length>0||V){let j=K[0]?.style.node||V?.component.node||T,Y=K.length>0?"stylesShouldBeAboveUsage":"mainComponentShouldBeFirst";e.report({node:j,messageId:Y,fix:F(K,V,T.body)})}},c;function F(T,S,R){return function*(O){T.sort((Z,K)=>Z.targetPosition-K.targetPosition);for(let{style:Z}of T){let K=r.getCommentsBefore(Z.node),V=Z.node.range[0],j=Z.node.range[1];K.length>0&&K[0]&&(V=K[0].range[0]),V===Z.node.range[0]&&r.text.slice(0,V).trim().length===0&&(V=0),yield O.removeRange([V,j])}let D=new Map;for(let Z of T){let K=D.get(Z.targetPosition)||[];K.push(Z),D.set(Z.targetPosition,K)}for(let[Z,K]of D){let V=R[Z];if(!V)continue;let j=r.getCommentsBefore(V),Y=j.length>0&&j[0]?j[0].range[0]:V.range[0],H=[];for(let{style:ue}of K){let ge=r.getCommentsBefore(ue.node),Ee=r.getText(ue.node);ge.length>0&&(Ee=`${ge.map(Fe=>r.getText(Fe)).join(`
|
|
47
47
|
`)}
|
|
48
48
|
${Ee}`),H.push(Ee)}yield O.insertTextBeforeRange([Y,Y],`${H.join(`
|
|
49
49
|
|
package/dist/extended-lint.mjs
CHANGED
|
@@ -43,7 +43,7 @@ ${P}`),C.push(c)}yield E.insertTextBeforeRange([m,m],`${C.join(`
|
|
|
43
43
|
|
|
44
44
|
`)}
|
|
45
45
|
|
|
46
|
-
`)}}}return{Program(y){s.push(...y.body)},TSTypeAliasDeclaration(y){if(s.some(b=>b.type===Te.ExportNamedDeclaration&&b.declaration===y?!0:b===y)){let b=o(y);b&&t.set(y.id.name,{node:y,name:y.id.name,statement:b})}},TSInterfaceDeclaration(y){if(s.some(b=>b.type===Te.ExportNamedDeclaration&&b.declaration===y?!0:b===y)){let b=o(y);b&&t.set(y.id.name,{node:y,name:y.id.name,statement:b})}},TSTypeReference(y){if(y.typeName.type===Te.Identifier){if(u(y))return;let E=i(y),b=p(y),f=a(y);d.push({typeName:y.typeName.name,node:y,inFunctionArgs:E,inFCProps:b,inGenericArgAtFunctionCall:f,usagePosition:y.range[0]})}},"Program:exit"(){let y=new Map;function E(f){if(!n.checkOnly||n.checkOnly.length===0)return!0;for(let A of n.checkOnly)if(A==="function-args"&&f.inFunctionArgs||A==="FC"&&f.inFCProps||A==="generic-args-at-fn-calls"&&f.inGenericArgAtFunctionCall)return!0;return!1}for(let f of d){let{typeName:A,node:I}=f;if(!t.has(A)||!E(f))continue;let m=o(I),C=t.get(A);if(!m||!C||m===C.statement)continue;y.has(A)||y.set(A,[]);let h=y.get(A);if(!h)return;h.includes(m)||h.push(m)}let b=[];for(let[f,A]of y)if(A.length>0){if(A.length===0)continue;let I=A[0];if(!I)continue;let m=Number.MAX_SAFE_INTEGER,C=!1;for(let w of A)w.range[0]<I.range[0]&&(I=w);for(let w of d)E(w)&&w.typeName===f&&o(w.node)===I&&w.usagePosition<m&&(m=w.usagePosition,C=w.inFunctionArgs);if(!!(n.checkOnly&&n.checkOnly.length>0)){let w=Number.MAX_SAFE_INTEGER;for(let v of d){if(v.typeName!==f)continue;let c=o(v.node);if(!c)continue;let F=s.indexOf(c);F!==-1&&F<w&&(w=F)}let P=s.indexOf(I);if(w!==Number.MAX_SAFE_INTEGER&&P!==-1&&w<P)continue}else{let w=Number.MAX_SAFE_INTEGER;for(let v of d){if(v.typeName!==f||l(v.node))continue;let c=o(v.node);if(!c)continue;let F=s.indexOf(c);F!==-1&&F<w&&(w=F)}let P=s.indexOf(I);if(w!==Number.MAX_SAFE_INTEGER&&P!==-1&&w<P)continue}b.push({typeName:f,firstUsage:I,firstUsagePosition:m,firstUsageInFunctionArgs:C})}b.length>0&&g(b)}}}});import{AST_NODE_TYPES as re}from"@typescript-eslint/utils";import*as Ze from"zod/v4";var Ca=["tsx"],Ia=/^[A-Z][A-Za-z0-9]*$/,Aa=Ze.object({extensions:Ze.array(Ze.string()).optional()}),hn=q({name:"react-single-export",meta:{type:"problem",docs:{description:"Enforces only one export per React component file to support fast refresh"},messages:{multipleExports:"React component files should have only one export to support fast refresh, if you want to export multiple components, use a separate file for each component. Type-only exports are allowed."},schema:[B(Aa)]},defaultOptions:[{}],create(e,[n]){let r=e.getFilename(),t=n.extensions??Ca,s=!1;for(let m of t)if(r.endsWith(m)){s=!0;break}if(!s)return{};let o=e.sourceCode,i=new Set,p=new Map;function a(m){return Ia.test(m)}function l(m){if(m.type!==re.CallExpression)return!1;let C=m.callee;return C.type===re.Identifier?C.name==="memo"||C.name==="forwardRef":C.type===re.MemberExpression&&C.property.type===re.Identifier?C.property.name==="memo"||C.property.name==="forwardRef":!1}function u(m){if(m.type===re.JSXElement||m.type===re.JSXFragment)return!0;if(m.type===re.ArrayExpression){for(let C of m.elements)if(C&&(C.type===re.JSXElement||C.type===re.JSXFragment))return!0}return!1}function d(m){if(m.type!==re.ArrowFunctionExpression)return!1;let C=m.body;if(C.type===re.ArrowFunctionExpression){let h=C.body;if(u(h))return!0}return!1}function g(m){if(m.id.type!==re.Identifier)return;let C=m.id.name,h=m.init;if(h){if(a(C)&&(h.type===re.ArrowFunctionExpression||h.type===re.FunctionExpression||l(h))){i.add(C);return}h.type===re.Identifier&&p.set(C,h.name),a(C)||d(h)&&i.add(C)}}function x(m){if(m.type===re.VariableDeclaration){for(let C of m.declarations)g(C);return}if(m.type===re.FunctionDeclaration&&m.id){a(m.id.name)&&i.add(m.id.name);return}if(m.type===re.ExportNamedDeclaration&&m.declaration){let C=m.declaration;if(C.type===re.VariableDeclaration){for(let h of C.declarations)g(h);return}if(C.type===re.FunctionDeclaration&&C.id){a(C.id.name)&&i.add(C.id.name);return}}}for(let m of o.ast.body)x(m);function y(m,C=new Set){if(i.has(m))return!0;if(C.has(m))return!1;C.add(m);let h=p.get(m);return h?y(h,C):!1}let E=[];function b(m,C,h){E.push({node:m,isType:C,isComponent:h})}for(let m of o.ast.body){if(m.type===re.ExportNamedDeclaration){let C=m.exportKind==="type";if(m.declaration){let h=m.declaration;if(h.type===re.TSTypeAliasDeclaration||h.type===re.TSInterfaceDeclaration){b(h,!0,!1);continue}if(h.type===re.VariableDeclaration){for(let w of h.declarations){if(w.id.type!==re.Identifier)continue;let P=w.id.name,v=y(P);b(w,C,v)}continue}if(h.type===re.FunctionDeclaration){let w=h.id?.name,P=w?y(w)||a(w):!1;b(h,C,P);continue}b(h,C,!1);continue}if(m.specifiers.length>0)for(let h of m.specifiers){if(h.local.type!==re.Identifier)continue;let w=h.local.name,P=y(w);b(h,C,P)}continue}if(m.type===re.ExportDefaultDeclaration){let C=m.declaration;if(C.type===re.Identifier){let h=y(C.name)||a(C.name);b(m,!1,h);continue}if(C.type===re.FunctionDeclaration||C.type===re.ArrowFunctionExpression||C.type===re.FunctionExpression||C.type===re.CallExpression){b(m,!1,!0);continue}b(m,!1,!1);continue}}let f=!1;for(let m of E)if(!m.isType&&m.isComponent){f=!0;break}if(!f)return{};let A=[];for(let m of E)m.isType||A.push(m);let I=-1;for(let[m,C]of A.entries())if(C.isComponent){I=m;break}if(I===-1)return{};for(let[m,C]of A.entries())if(m!==I){e.report({node:C.node,messageId:"multipleExports"});break}return{}}});import{AST_NODE_TYPES as We}from"@typescript-eslint/utils";import{z as En}from"zod/v4";function gt(e){return e.charAt(0).toUpperCase()+e.slice(1)}function wa(e){return e.callee.type===We.Identifier?e.callee.name==="useState":e.callee.type===We.MemberExpression&&e.callee.object.type===We.Identifier&&e.callee.property.type===We.Identifier?e.callee.object.name==="React"&&e.callee.property.name==="useState":!1}var Ra=En.object({ignorePrefixes:En.array(En.string()).optional()});function Gr(e,n){for(let r of n)if(e.startsWith(r))return e.slice(r.length);return e}function Fa(e){return`set${gt(e)}`}var bn=q({name:"use-state-setter-naming",meta:{type:"problem",docs:{description:"Enforce consistent naming convention for useState destructuring where setter should be set{Value}"},messages:{incorrectSetterName:'useState setter should follow the pattern "set{{expectedName}}" with a "set" prefix but got "{{actualName}}"',useSuggestedName:'Use "{{expectedSetterName}}" instead'},hasSuggestions:!0,schema:[B(Ra)]},defaultOptions:[{ignorePrefixes:[]}],create(e,[n]){return{VariableDeclarator(r){if(!r.init||r.init.type!==We.CallExpression||!wa(r.init)||r.id.type!==We.ArrayPattern||r.id.elements.length!==2)return;let[t,s]=r.id.elements;if(!t||!s||t.type!==We.Identifier||s.type!==We.Identifier)return;let o=t.name,i=s.name,p=n.ignorePrefixes||[],a=Gr(o,p),l=Gr(i,p);if(a===""){if(!l.startsWith("set")){let d=`set${gt(o)}`;e.report({node:s,messageId:"incorrectSetterName",data:{expectedName:gt(o),actualName:i},suggest:[{messageId:"useSuggestedName",data:{expectedSetterName:d},fix:g=>g.replaceText(s,d)}]})}return}let u=Fa(a);l!==u&&e.report({node:s,messageId:"incorrectSetterName",data:{expectedName:gt(a),actualName:i},suggest:[{messageId:"useSuggestedName",data:{expectedSetterName:u},fix:d=>d.replaceText(s,u)}]})}}}});import{AST_NODE_TYPES as ye}from"@typescript-eslint/utils";import{z as Ge}from"zod/v4";var ka=Ge.object({name:Ge.string(),defaults:Ge.array(Ge.unknown())}),Pa=Ge.object({functions:Ge.array(ka)});function St(e,n){if(e===n)return!0;if(e===null||n===null||e===void 0||n===void 0)return e===n;if(typeof e!=typeof n||typeof e!="object"||Array.isArray(e)!==Array.isArray(n))return!1;if(Array.isArray(e)&&Array.isArray(n))return e.length!==n.length?!1:e.every((s,o)=>St(s,n[o]));let r=Object.keys(e),t=Object.keys(n);if(r.length!==t.length)return!1;for(let s of r){if(!t.includes(s))return!1;let o=Object.getOwnPropertyDescriptor(e,s),i=Object.getOwnPropertyDescriptor(n,s);if(!o||!i)return!1;let p=o.value,a=i.value;if(!St(p,a))return!1}return!0}function va(e,n){let r=new Set;if(typeof e!="object"||e===null||typeof n!="object"||n===null)return r;for(let t in e){if(!(t in n))continue;let s=Object.getOwnPropertyDescriptor(e,t),o=Object.getOwnPropertyDescriptor(n,t);s&&o&&St(s.value,o.value)&&r.add(t)}return r}function Kr(e){if(e.type===ye.SpreadElement)return Symbol("COMPLEX_EXPRESSION");switch(e.type){case ye.Literal:return e.value;case ye.ObjectExpression:{let n={};for(let r of e.properties)r.type===ye.Property&&r.key.type===ye.Identifier&&!r.computed&&(r.value.type===ye.Literal?n[r.key.name]=r.value.value:r.value.type===ye.ObjectExpression?n[r.key.name]=Kr(r.value):n[r.key.name]=Symbol("COMPLEX_EXPRESSION"));return n}case ye.ArrayExpression:return e.elements.map(n=>{if(!(!n||n.type===ye.SpreadElement))return n.type===ye.Literal?n.value:Symbol("COMPLEX_EXPRESSION")});default:return Symbol("COMPLEX_EXPRESSION")}}function Oa(e){return e.type===ye.Identifier?e.name:e.type===ye.MemberExpression&&e.property.type===ye.Identifier&&!e.computed?e.property.name:null}var xn=q({name:"no-redundant-function-params",meta:{type:"suggestion",docs:{description:"Disallow calling functions with redundant default parameters"},messages:{redundantParams:"Function call has redundant parameters matching its default values and can be removed: {{details}}"},fixable:"code",schema:[B(Pa)]},defaultOptions:[{functions:[]}],create(e,[n]){let r=new Map;for(let t of n.functions)r.set(t.name,t.defaults);return{CallExpression(t){let s=Oa(t.callee);if(!s)return;let o=r.get(s);if(!o)return;let i=t.arguments;if(i.length===0)return;let p=-1,a=!1,l=new Map,u=new Set,d=new Map,g=[];for(let y=0;y<i.length;y++){if(y>=o.length){p=y;continue}let E=o[y],b=i[y];if(!b||b.type===ye.SpreadElement){p=y;continue}let f=Kr(b);if(E===void 0){p=y;continue}if(St(f,E)){b.type===ye.ObjectExpression?(u.add(y),g.push({type:"object",position:y+1})):(d.set(y,f),g.push({type:"simple",position:y+1,value:f}));continue}if(b.type===ye.ObjectExpression&&b.properties.length===0&&typeof E=="object"&&E!==null&&Object.keys(E).length>0){u.add(y),g.push({type:"object",position:y+1});continue}let A=va(f,E);if(A.size>0){let I=typeof E=="object"&&E!==null?Object.keys(E).length:0;if(b.type===ye.ObjectExpression&&b.properties.length===A.size&&b.properties.length===I){u.add(y),g.push({type:"object",position:y+1});continue}else a=!0,l.set(y,A),g.push({type:"partialObject",position:y+1,redundantProperties:Array.from(A)}),p=y}else p=y}if(p<i.length-1||a||u.size>0){let y=function(){let b=[];for(let f of g)if(f.type==="simple")b.push(`Param ${f.position} with value ${JSON.stringify(f.value)}`);else if(f.type==="object")b.push(`Param ${f.position} (object)`);else{let A=f.redundantProperties||[],I=o?o[f.position-1]:void 0;if(typeof I=="object"&&I!==null){let m=I;for(let C of A)if(C in m){let h=Object.getOwnPropertyDescriptor(m,C);h&&b.push(`Param ${f.position} property "${C}" with value ${JSON.stringify(h.value)}`)}}}return{messageId:"redundantParams",data:{details:b.join(", ")}}};var x=y;let E=y();e.report({node:t,messageId:E.messageId,data:E.data,fix(b){let f=[];if(a)for(let[I,m]of l){let C=i[I];if(C&&C.type===ye.ObjectExpression){let h=[];for(let P of C.properties)P.type===ye.Property&&P.key.type===ye.Identifier&&!P.computed&&m.has(P.key.name)||h.push(P);let w=h.map(P=>e.sourceCode.getText(P));f.push(b.replaceText(C,`{ ${w.join(", ")} }`))}}let A=-1;for(let I=i.length-1;I>=0;I--)if(!u.has(I)&&I<=p){A=I;break}if(A<i.length-1)if(A===-1){let I=e.sourceCode.getTokenAfter(t.callee),m=e.sourceCode.getLastToken(t);I&&m&&f.push(b.replaceTextRange([I.range[1],m.range[0]],""))}else{let I=i[A],m=e.sourceCode.getLastToken(t);m&&I&&f.push(b.replaceTextRange([I.range[1],m.range[0]],""))}return f.length>0?f:null}})}}}}});import{AST_NODE_TYPES as ke}from"@typescript-eslint/utils";function Na(e){let n=e.parent;for(;n;){if(n.type===ke.AwaitExpression||n.type===ke.MemberExpression&&n.object===e&&n.property.type===ke.Identifier&&n.property.name==="then"||n.type===ke.ArrowFunctionExpression&&n.body===e)return!0;if(n.type===ke.ArrayExpression&&n.parent.type===ke.CallExpression){let r=n.parent;if(r.callee.type===ke.MemberExpression&&r.callee.object.type===ke.Identifier&&r.callee.object.name==="Promise"&&r.callee.property.type===ke.Identifier&&["all","allSettled","race"].includes(r.callee.property.name))return!0}if(n.parent)n=n.parent;else break}return!1}function Da(e){let{callee:n}=e;return n.type===ke.Identifier&&n.name==="require"||n.type===ke.MemberExpression&&n.object.type===ke.Identifier&&n.object.name==="require"}var Cn=q({name:"no-sync-dynamic-import",meta:{type:"problem",docs:{description:"Disallow synchronous dynamic imports and require statements, only allow async dynamic imports with await"},messages:{syncDynamicImport:"Synchronous dynamic import() is not allowed. Use regular import statement or await import() for dynamic imports.",requireNotAllowed:"require() statements are not allowed. Use ES6 import statements instead."},schema:[]},defaultOptions:[],create(e){return{ImportExpression(n){Na(n)||e.report({node:n,messageId:"syncDynamicImport"})},TSImportType(n){e.report({node:n,messageId:"syncDynamicImport"})},CallExpression(n){Da(n)&&e.report({node:n,messageId:"requireNotAllowed"})}}}});import{AST_NODE_TYPES as L}from"@typescript-eslint/utils";import{z as In}from"zod/v4";var ja=In.object({mainComponentRegex:In.string().optional(),mainComponentSelector:In.string().optional()}),La=/^[A-Z][A-Za-z0-9]*$/,An=q({name:"sort-react-components-and-styles",meta:{type:"suggestion",docs:{description:"Sort React components and styles with styles placed above their first usage"},fixable:"code",schema:[B(ja)],messages:{stylesShouldBeAboveUsage:"Style definitions should be placed above the first component that uses them",mainComponentShouldBeFirst:"Main component should be placed before other components"}},defaultOptions:[{}],create(e,[n]){let r=e.sourceCode,t=n.mainComponentRegex?new RegExp(n.mainComponentRegex):void 0,s=n.mainComponentSelector;if(!e.filename.endsWith(".tsx"))return{};let i=new Set,p=new Map,a=[],l=[],u=new Set;function d(T){let S=T.node;if(S.type===L.VariableDeclaration){for(let R of S.declarations)if(R.id.type===L.Identifier&&R.id.name===T.name&&R.init)return R.init}if(S.type===L.ExportNamedDeclaration){let R=S.declaration;if(R&&R.type===L.VariableDeclaration){for(let O of R.declarations)if(O.id.type===L.Identifier&&O.id.name===T.name&&O.init)return O.init}}return null}function g(T){let S=new Set;return ve(T,R=>(R.type===L.Identifier&&R.name!=="styled"&&R.name!=="css"&&S.add(R.name),!1),r),S}function x(T){return La.test(T)}function y(T){if(T.type!==L.CallExpression)return!1;let S=T.callee;return S.type===L.Identifier?S.name==="memo"||S.name==="forwardRef":S.type===L.MemberExpression&&S.property.type===L.Identifier?S.property.name==="memo"||S.property.name==="forwardRef":!1}function E(T){if(T.type===L.JSXElement||T.type===L.JSXFragment)return!0;if(T.type===L.BlockStatement){for(let S of T.body)if(S.type===L.ReturnStatement&&S.argument)return E(S.argument)}if(T.type===L.ArrayExpression){for(let S of T.elements)if(S&&(S.type===L.JSXElement||S.type===L.JSXFragment))return!0}return!1}function b(T){if(T.type!==L.ArrowFunctionExpression)return!1;let S=T.body;if(S.type===L.ArrowFunctionExpression){let R=S.body;if(E(R))return!0}return!1}function f(T){if(T.type===L.TaggedTemplateExpression){let S=T.tag;if(S.type===L.MemberExpression&&S.object.type===L.Identifier&&S.object.name==="styled")return!0;if(S.type===L.CallExpression){let R=S.callee;if(R.type===L.Identifier&&R.name==="styled")return!0}}return!1}function A(T){if(T.type===L.TaggedTemplateExpression){let S=T.tag;if(S.type===L.Identifier&&S.name==="css")return!0}return!1}function I(T,S){if(T.id.type!==L.Identifier)return;let R=T.id.name,O=T.init;if(O){if(f(O)||A(O)){l.push({node:S,name:R});return}if((x(R)||O.type===L.ArrowFunctionExpression)&&(O.type===L.ArrowFunctionExpression||O.type===L.FunctionExpression||y(O))){if(O.type===L.ArrowFunctionExpression||O.type===L.FunctionExpression){if(E(O.body)){i.add(R);return}}else if(y(O)){i.add(R);return}}O.type===L.Identifier&&p.set(R,O.name),x(R)||b(O)&&i.add(R)}}function m(T){return T.type===L.ExportDefaultDeclaration||T.type===L.ExportNamedDeclaration}function C(T){if(T.type===L.FunctionDeclaration)return T.id?T.id.name:null;if(T.type===L.VariableDeclaration){let S=T.declarations[0];if(S&&S.id.type===L.Identifier)return S.id.name}if(T.type===L.ExportDefaultDeclaration){let S=T.declaration;if(S.type===L.FunctionDeclaration)return S.id?S.id.name:"default";if(S.type===L.Identifier)return S.name}if(T.type===L.ExportNamedDeclaration){let S=T.declaration;if(S&&S.type===L.FunctionDeclaration)return S.id?S.id.name:null;if(S&&S.type===L.VariableDeclaration){let R=S.declarations[0];if(R&&R.id.type===L.Identifier)return R.id.name}}return null}function h(T,S){return s?u.has(T):t?t.test(S):m(T)}function w(T){let S=new Set;ve(T.node,R=>{if(R.type===L.Identifier)for(let O of l)O.name===R.name&&(S.add(O.name),(O.firstUsagePosition===void 0||R.range[0]<O.firstUsagePosition)&&(O.firstUsagePosition=R.range[0]));if(R.type===L.JSXElement){let O=R.openingElement;if(O.name.type===L.JSXIdentifier)for(let D of l)D.name===O.name.name&&(S.add(D.name),(D.firstUsagePosition===void 0||O.name.range[0]<D.firstUsagePosition)&&(D.firstUsagePosition=O.name.range[0]))}return!1},r),T.usedStyles=S}function P(T){if(T.type===L.VariableDeclaration){for(let S of T.declarations)I(S,T);return}if(T.type===L.FunctionDeclaration){x(T.id.name)&&E(T.body)&&i.add(T.id.name);return}if(T.type===L.ExportNamedDeclaration&&T.declaration){let S=T.declaration;if(S.type===L.VariableDeclaration){for(let R of S.declarations)I(R,T);return}if(S.type===L.FunctionDeclaration&&S.id){x(S.id.name)&&E(S.body)&&i.add(S.id.name);return}}if(T.type===L.ExportDefaultDeclaration){let S=T.declaration;S.type===L.Identifier&&i.add(S.name),(S.type===L.FunctionDeclaration||S.type===L.ArrowFunctionExpression||S.type===L.FunctionExpression)&&(S.type===L.FunctionDeclaration?S.id?i.add(S.id.name):i.add("default"):E(S.body)&&i.add("default"))}}function v(T,S=new Set){if(i.has(T))return!0;if(S.has(T))return!1;S.add(T);let R=p.get(T);return R?v(R,S):!1}let c={};return s&&(c[s]=T=>{let S=T;for(;S.parent&&S.parent.type!==L.Program;)S=S.parent;S.parent&&(S.type===L.VariableDeclaration||S.type===L.FunctionDeclaration||S.type===L.ExportNamedDeclaration||S.type===L.ExportDefaultDeclaration)&&u.add(S)}),c["Program:exit"]=T=>{let S=0;for(let j of T.body){if(j.type===L.ImportDeclaration){S+=1;continue}break}for(let j of T.body)P(j);for(let j of T.body){let Y=C(j);if(Y&&v(Y)){let H=h(j,Y);a.push({node:j,name:Y,isMainComponent:H,usedStyles:new Set})}}for(let j of a)w(j);let R=new Set;for(let j of l)R.add(j.name);let O=new Map;for(let j=0;j<T.body.length;j+=1){let Y=T.body[j];for(let H of l)H.node===Y&&O.set(H.name,j)}let D=new Map;for(let j of l){let Y=d(j),H=new Set;if(Y){let ce=g(Y);for(let de of ce)R.has(de)&&de!==j.name&&H.add(de)}D.set(j.name,H)}let Z=new Map;for(let j of l){let Y=D.get(j.name);if(!Y)continue;let H=O.get(j.name);if(H!==void 0)for(let ce of Y){let de=Z.get(ce);(de===void 0||H<de)&&Z.set(ce,H)}}let G=[];for(let j of l){if(j.firstUsagePosition===void 0)continue;let Y=T.body.indexOf(j.node),H=-1;for(let ge of a){if(!ge.usedStyles.has(j.name))continue;let xe=T.body.indexOf(ge.node);(H===-1||xe<H)&&(H=xe)}let ce=Z.get(j.name);if(ce!==void 0&&(H===-1||ce<H)&&(H=ce),H===-1)continue;let de=-1;for(let ge of a){let xe=T.body.indexOf(ge.node);xe<H&&xe>de&&(de=xe)}let Ee=Y<H,Ie=Y>de,Ae=-1,Je=D.get(j.name);if(Je)for(let ge of Je){let xe=O.get(ge);xe!==void 0&&xe>Ae&&(Ae=xe)}let wn=Y>Ae;if(!(Ee&&Ie&&wn)){let ge=de+1;if(Ae+1>ge&&(ge=Ae+1),ge<S&&(ge=S),ge>H)continue;G.push({style:j,targetPosition:ge})}}let V=null;if(a.length>1){let j=a.map(H=>({c:H,idx:T.body.indexOf(H.node)})).sort((H,ce)=>H.idx-ce.idx)[0]?.c,Y=a.find(H=>H.isMainComponent)||null;j&&Y&&j.node!==Y.node&&(V={component:Y,targetBefore:j.node})}if(G.length>0||V){let j=G[0]?.style.node||V?.component.node||T,Y=G.length>0?"stylesShouldBeAboveUsage":"mainComponentShouldBeFirst";e.report({node:j,messageId:Y,fix:F(G,V,T.body)})}},c;function F(T,S,R){return function*(O){T.sort((Z,G)=>Z.targetPosition-G.targetPosition);for(let{style:Z}of T){let G=r.getCommentsBefore(Z.node),V=Z.node.range[0],j=Z.node.range[1];G.length>0&&G[0]&&(V=G[0].range[0]),V===Z.node.range[0]&&r.text.slice(0,V).trim().length===0&&(V=0),yield O.removeRange([V,j])}let D=new Map;for(let Z of T){let G=D.get(Z.targetPosition)||[];G.push(Z),D.set(Z.targetPosition,G)}for(let[Z,G]of D){let V=R[Z];if(!V)continue;let j=r.getCommentsBefore(V),Y=j.length>0&&j[0]?j[0].range[0]:V.range[0],H=[];for(let{style:ce}of G){let de=r.getCommentsBefore(ce.node),Ee=r.getText(ce.node);de.length>0&&(Ee=`${de.map(Ae=>r.getText(Ae)).join(`
|
|
46
|
+
`)}}}return{Program(y){s.push(...y.body)},TSTypeAliasDeclaration(y){if(s.some(b=>b.type===Te.ExportNamedDeclaration&&b.declaration===y?!0:b===y)){let b=o(y);b&&t.set(y.id.name,{node:y,name:y.id.name,statement:b})}},TSInterfaceDeclaration(y){if(s.some(b=>b.type===Te.ExportNamedDeclaration&&b.declaration===y?!0:b===y)){let b=o(y);b&&t.set(y.id.name,{node:y,name:y.id.name,statement:b})}},TSTypeReference(y){if(y.typeName.type===Te.Identifier){if(u(y))return;let E=i(y),b=p(y),f=a(y);d.push({typeName:y.typeName.name,node:y,inFunctionArgs:E,inFCProps:b,inGenericArgAtFunctionCall:f,usagePosition:y.range[0]})}},"Program:exit"(){let y=new Map;function E(f){if(!n.checkOnly||n.checkOnly.length===0)return!0;for(let A of n.checkOnly)if(A==="function-args"&&f.inFunctionArgs||A==="FC"&&f.inFCProps||A==="generic-args-at-fn-calls"&&f.inGenericArgAtFunctionCall)return!0;return!1}for(let f of d){let{typeName:A,node:I}=f;if(!t.has(A)||!E(f))continue;let m=o(I),C=t.get(A);if(!m||!C||m===C.statement)continue;y.has(A)||y.set(A,[]);let h=y.get(A);if(!h)return;h.includes(m)||h.push(m)}let b=[];for(let[f,A]of y)if(A.length>0){if(A.length===0)continue;let I=A[0];if(!I)continue;let m=Number.MAX_SAFE_INTEGER,C=!1;for(let w of A)w.range[0]<I.range[0]&&(I=w);for(let w of d)E(w)&&w.typeName===f&&o(w.node)===I&&w.usagePosition<m&&(m=w.usagePosition,C=w.inFunctionArgs);if(!!(n.checkOnly&&n.checkOnly.length>0)){let w=Number.MAX_SAFE_INTEGER;for(let v of d){if(v.typeName!==f)continue;let c=o(v.node);if(!c)continue;let F=s.indexOf(c);F!==-1&&F<w&&(w=F)}let P=s.indexOf(I);if(w!==Number.MAX_SAFE_INTEGER&&P!==-1&&w<P)continue}else{let w=Number.MAX_SAFE_INTEGER;for(let v of d){if(v.typeName!==f||l(v.node))continue;let c=o(v.node);if(!c)continue;let F=s.indexOf(c);F!==-1&&F<w&&(w=F)}let P=s.indexOf(I);if(w!==Number.MAX_SAFE_INTEGER&&P!==-1&&w<P)continue}b.push({typeName:f,firstUsage:I,firstUsagePosition:m,firstUsageInFunctionArgs:C})}b.length>0&&g(b)}}}});import{AST_NODE_TYPES as re}from"@typescript-eslint/utils";import*as Ze from"zod/v4";var Ca=["tsx"],Ia=/^[A-Z][A-Za-z0-9]*$/,Aa=Ze.object({extensions:Ze.array(Ze.string()).optional()}),hn=q({name:"react-single-export",meta:{type:"problem",docs:{description:"Enforces only one export per React component file to support fast refresh"},messages:{multipleExports:"React component files should have only one export to support fast refresh, if you want to export multiple components, use a separate file for each component. Type-only exports are allowed."},schema:[B(Aa)]},defaultOptions:[{}],create(e,[n]){let r=e.getFilename(),t=n.extensions??Ca,s=!1;for(let m of t)if(r.endsWith(m)){s=!0;break}if(!s)return{};let o=e.sourceCode,i=new Set,p=new Map;function a(m){return Ia.test(m)}function l(m){if(m.type!==re.CallExpression)return!1;let C=m.callee;return C.type===re.Identifier?C.name==="memo"||C.name==="forwardRef":C.type===re.MemberExpression&&C.property.type===re.Identifier?C.property.name==="memo"||C.property.name==="forwardRef":!1}function u(m){if(m.type===re.JSXElement||m.type===re.JSXFragment)return!0;if(m.type===re.ArrayExpression){for(let C of m.elements)if(C&&(C.type===re.JSXElement||C.type===re.JSXFragment))return!0}return!1}function d(m){if(m.type!==re.ArrowFunctionExpression)return!1;let C=m.body;if(C.type===re.ArrowFunctionExpression){let h=C.body;if(u(h))return!0}return!1}function g(m){if(m.id.type!==re.Identifier)return;let C=m.id.name,h=m.init;if(h){if(a(C)&&(h.type===re.ArrowFunctionExpression||h.type===re.FunctionExpression||l(h))){i.add(C);return}h.type===re.Identifier&&p.set(C,h.name),a(C)||d(h)&&i.add(C)}}function x(m){if(m.type===re.VariableDeclaration){for(let C of m.declarations)g(C);return}if(m.type===re.FunctionDeclaration&&m.id){a(m.id.name)&&i.add(m.id.name);return}if(m.type===re.ExportNamedDeclaration&&m.declaration){let C=m.declaration;if(C.type===re.VariableDeclaration){for(let h of C.declarations)g(h);return}if(C.type===re.FunctionDeclaration&&C.id){a(C.id.name)&&i.add(C.id.name);return}}}for(let m of o.ast.body)x(m);function y(m,C=new Set){if(i.has(m))return!0;if(C.has(m))return!1;C.add(m);let h=p.get(m);return h?y(h,C):!1}let E=[];function b(m,C,h){E.push({node:m,isType:C,isComponent:h})}for(let m of o.ast.body){if(m.type===re.ExportNamedDeclaration){let C=m.exportKind==="type";if(m.declaration){let h=m.declaration;if(h.type===re.TSTypeAliasDeclaration||h.type===re.TSInterfaceDeclaration){b(h,!0,!1);continue}if(h.type===re.VariableDeclaration){for(let w of h.declarations){if(w.id.type!==re.Identifier)continue;let P=w.id.name,v=y(P);b(w,C,v)}continue}if(h.type===re.FunctionDeclaration){let w=h.id?.name,P=w?y(w)||a(w):!1;b(h,C,P);continue}b(h,C,!1);continue}if(m.specifiers.length>0)for(let h of m.specifiers){if(h.local.type!==re.Identifier)continue;let w=h.local.name,P=y(w);b(h,C,P)}continue}if(m.type===re.ExportDefaultDeclaration){let C=m.declaration;if(C.type===re.Identifier){let h=y(C.name)||a(C.name);b(m,!1,h);continue}if(C.type===re.FunctionDeclaration||C.type===re.ArrowFunctionExpression||C.type===re.FunctionExpression||C.type===re.CallExpression){b(m,!1,!0);continue}b(m,!1,!1);continue}}let f=!1;for(let m of E)if(!m.isType&&m.isComponent){f=!0;break}if(!f)return{};let A=[];for(let m of E)m.isType||A.push(m);let I=-1;for(let[m,C]of A.entries())if(C.isComponent){I=m;break}if(I===-1)return{};for(let[m,C]of A.entries())if(m!==I){e.report({node:C.node,messageId:"multipleExports"});break}return{}}});import{AST_NODE_TYPES as We}from"@typescript-eslint/utils";import{z as En}from"zod/v4";function gt(e){return e.charAt(0).toUpperCase()+e.slice(1)}function wa(e){return e.callee.type===We.Identifier?e.callee.name==="useState":e.callee.type===We.MemberExpression&&e.callee.object.type===We.Identifier&&e.callee.property.type===We.Identifier?e.callee.object.name==="React"&&e.callee.property.name==="useState":!1}var Ra=En.object({ignorePrefixes:En.array(En.string()).optional()});function Gr(e,n){for(let r of n)if(e.startsWith(r))return e.slice(r.length);return e}function Fa(e){return`set${gt(e)}`}var bn=q({name:"use-state-setter-naming",meta:{type:"problem",docs:{description:"Enforce consistent naming convention for useState destructuring where setter should be set{Value}"},messages:{incorrectSetterName:'useState setter should follow the pattern "set{{expectedName}}" with a "set" prefix but got "{{actualName}}"',useSuggestedName:'Use "{{expectedSetterName}}" instead'},hasSuggestions:!0,schema:[B(Ra)]},defaultOptions:[{ignorePrefixes:[]}],create(e,[n]){return{VariableDeclarator(r){if(!r.init||r.init.type!==We.CallExpression||!wa(r.init)||r.id.type!==We.ArrayPattern||r.id.elements.length!==2)return;let[t,s]=r.id.elements;if(!t||!s||t.type!==We.Identifier||s.type!==We.Identifier)return;let o=t.name,i=s.name,p=n.ignorePrefixes||[],a=Gr(o,p),l=Gr(i,p);if(a===""){if(!l.startsWith("set")){let d=`set${gt(o)}`;e.report({node:s,messageId:"incorrectSetterName",data:{expectedName:gt(o),actualName:i},suggest:[{messageId:"useSuggestedName",data:{expectedSetterName:d},fix:g=>g.replaceText(s,d)}]})}return}let u=Fa(a);l!==u&&e.report({node:s,messageId:"incorrectSetterName",data:{expectedName:gt(a),actualName:i},suggest:[{messageId:"useSuggestedName",data:{expectedSetterName:u},fix:d=>d.replaceText(s,u)}]})}}}});import{AST_NODE_TYPES as ye}from"@typescript-eslint/utils";import{z as Ge}from"zod/v4";var ka=Ge.object({name:Ge.string(),defaults:Ge.array(Ge.unknown())}),Pa=Ge.object({functions:Ge.array(ka)});function St(e,n){if(e===n)return!0;if(e===null||n===null||e===void 0||n===void 0)return e===n;if(typeof e!=typeof n||typeof e!="object"||Array.isArray(e)!==Array.isArray(n))return!1;if(Array.isArray(e)&&Array.isArray(n))return e.length!==n.length?!1:e.every((s,o)=>St(s,n[o]));let r=Object.keys(e),t=Object.keys(n);if(r.length!==t.length)return!1;for(let s of r){if(!t.includes(s))return!1;let o=Object.getOwnPropertyDescriptor(e,s),i=Object.getOwnPropertyDescriptor(n,s);if(!o||!i)return!1;let p=o.value,a=i.value;if(!St(p,a))return!1}return!0}function va(e,n){let r=new Set;if(typeof e!="object"||e===null||typeof n!="object"||n===null)return r;for(let t in e){if(!(t in n))continue;let s=Object.getOwnPropertyDescriptor(e,t),o=Object.getOwnPropertyDescriptor(n,t);s&&o&&St(s.value,o.value)&&r.add(t)}return r}function Kr(e){if(e.type===ye.SpreadElement)return Symbol("COMPLEX_EXPRESSION");switch(e.type){case ye.Literal:return e.value;case ye.ObjectExpression:{let n={};for(let r of e.properties)r.type===ye.Property&&r.key.type===ye.Identifier&&!r.computed&&(r.value.type===ye.Literal?n[r.key.name]=r.value.value:r.value.type===ye.ObjectExpression?n[r.key.name]=Kr(r.value):n[r.key.name]=Symbol("COMPLEX_EXPRESSION"));return n}case ye.ArrayExpression:return e.elements.map(n=>{if(!(!n||n.type===ye.SpreadElement))return n.type===ye.Literal?n.value:Symbol("COMPLEX_EXPRESSION")});default:return Symbol("COMPLEX_EXPRESSION")}}function Oa(e){return e.type===ye.Identifier?e.name:e.type===ye.MemberExpression&&e.property.type===ye.Identifier&&!e.computed?e.property.name:null}var xn=q({name:"no-redundant-function-params",meta:{type:"suggestion",docs:{description:"Disallow calling functions with redundant default parameters"},messages:{redundantParams:"Function call has redundant parameters matching its default values and can be removed: {{details}}"},fixable:"code",schema:[B(Pa)]},defaultOptions:[{functions:[]}],create(e,[n]){let r=new Map;for(let t of n.functions)r.set(t.name,t.defaults);return{CallExpression(t){let s=Oa(t.callee);if(!s)return;let o=r.get(s);if(!o)return;let i=t.arguments;if(i.length===0)return;let p=-1,a=!1,l=new Map,u=new Set,d=new Map,g=[];for(let y=0;y<i.length;y++){if(y>=o.length){p=y;continue}let E=o[y],b=i[y];if(!b||b.type===ye.SpreadElement){p=y;continue}let f=Kr(b);if(E===void 0){p=y;continue}if(St(f,E)){b.type===ye.ObjectExpression?(u.add(y),g.push({type:"object",position:y+1})):(d.set(y,f),g.push({type:"simple",position:y+1,value:f}));continue}if(b.type===ye.ObjectExpression&&b.properties.length===0&&typeof E=="object"&&E!==null&&Object.keys(E).length>0){u.add(y),g.push({type:"object",position:y+1});continue}let A=va(f,E);if(A.size>0){let I=typeof E=="object"&&E!==null?Object.keys(E).length:0;if(b.type===ye.ObjectExpression&&b.properties.length===A.size&&b.properties.length===I){u.add(y),g.push({type:"object",position:y+1});continue}else a=!0,l.set(y,A),g.push({type:"partialObject",position:y+1,redundantProperties:Array.from(A)}),p=y}else p=y}if(p<i.length-1||a||u.size>0){let y=function(){let b=[];for(let f of g)if(f.type==="simple")b.push(`Param ${f.position} with value ${JSON.stringify(f.value)}`);else if(f.type==="object")b.push(`Param ${f.position} (object)`);else{let A=f.redundantProperties||[],I=o?o[f.position-1]:void 0;if(typeof I=="object"&&I!==null){let m=I;for(let C of A)if(C in m){let h=Object.getOwnPropertyDescriptor(m,C);h&&b.push(`Param ${f.position} property "${C}" with value ${JSON.stringify(h.value)}`)}}}return{messageId:"redundantParams",data:{details:b.join(", ")}}};var x=y;let E=y();e.report({node:t,messageId:E.messageId,data:E.data,fix(b){let f=[];if(a)for(let[I,m]of l){let C=i[I];if(C&&C.type===ye.ObjectExpression){let h=[];for(let P of C.properties)P.type===ye.Property&&P.key.type===ye.Identifier&&!P.computed&&m.has(P.key.name)||h.push(P);let w=h.map(P=>e.sourceCode.getText(P));f.push(b.replaceText(C,`{ ${w.join(", ")} }`))}}let A=-1;for(let I=i.length-1;I>=0;I--)if(!u.has(I)&&I<=p){A=I;break}if(A<i.length-1)if(A===-1){let I=e.sourceCode.getTokenAfter(t.callee),m=e.sourceCode.getLastToken(t);I&&m&&f.push(b.replaceTextRange([I.range[1],m.range[0]],""))}else{let I=i[A],m=e.sourceCode.getLastToken(t);m&&I&&f.push(b.replaceTextRange([I.range[1],m.range[0]],""))}return f.length>0?f:null}})}}}}});import{AST_NODE_TYPES as ke}from"@typescript-eslint/utils";function Na(e){let n=e.parent;for(;n;){if(n.type===ke.AwaitExpression||n.type===ke.MemberExpression&&n.object===e&&n.property.type===ke.Identifier&&n.property.name==="then"||n.type===ke.ArrowFunctionExpression&&n.body===e)return!0;if(n.type===ke.ArrayExpression&&n.parent.type===ke.CallExpression){let r=n.parent;if(r.callee.type===ke.MemberExpression&&r.callee.object.type===ke.Identifier&&r.callee.object.name==="Promise"&&r.callee.property.type===ke.Identifier&&["all","allSettled","race"].includes(r.callee.property.name))return!0}if(n.parent)n=n.parent;else break}return!1}function Da(e){let{callee:n}=e;return n.type===ke.Identifier&&n.name==="require"||n.type===ke.MemberExpression&&n.object.type===ke.Identifier&&n.object.name==="require"}var Cn=q({name:"no-sync-dynamic-import",meta:{type:"problem",docs:{description:"Disallow synchronous dynamic imports and require statements, only allow async dynamic imports with await"},messages:{syncDynamicImport:"Synchronous dynamic import() is not allowed. Use regular import statement or await import() for dynamic imports.",requireNotAllowed:"require() statements are not allowed. Use ES6 import statements instead."},schema:[]},defaultOptions:[],create(e){return{ImportExpression(n){Na(n)||e.report({node:n,messageId:"syncDynamicImport"})},TSImportType(n){e.report({node:n,messageId:"syncDynamicImport"})},CallExpression(n){Da(n)&&e.report({node:n,messageId:"requireNotAllowed"})}}}});import{AST_NODE_TYPES as L}from"@typescript-eslint/utils";import{z as In}from"zod/v4";var ja=In.object({mainComponentRegex:In.string().optional(),mainComponentSelector:In.string().optional()}),La=/^[A-Z][A-Za-z0-9]*$/,An=q({name:"sort-react-components-and-styles",meta:{type:"suggestion",docs:{description:"Sort React components and styles with styles placed above their first usage"},fixable:"code",schema:[B(ja)],messages:{stylesShouldBeAboveUsage:"Style definitions should be placed above the first component that uses them",mainComponentShouldBeFirst:"Main component should be placed before other components"}},defaultOptions:[{}],create(e,[n]){let r=e.sourceCode,t=n.mainComponentRegex?new RegExp(n.mainComponentRegex):void 0,s=n.mainComponentSelector;if(!e.filename.endsWith(".tsx"))return{};let i=new Set,p=new Map,a=[],l=[],u=new Set;function d(T){let S=T.node;if(S.type===L.VariableDeclaration){for(let R of S.declarations)if(R.id.type===L.Identifier&&R.id.name===T.name&&R.init)return R.init}if(S.type===L.ExportNamedDeclaration){let R=S.declaration;if(R&&R.type===L.VariableDeclaration){for(let O of R.declarations)if(O.id.type===L.Identifier&&O.id.name===T.name&&O.init)return O.init}}return null}function g(T){let S=new Set;return ve(T,R=>(R.type===L.Identifier&&R.name!=="styled"&&R.name!=="css"&&S.add(R.name),!1),r),S}function x(T){return La.test(T)}function y(T){if(T.type!==L.CallExpression)return!1;let S=T.callee;return S.type===L.Identifier?S.name==="memo"||S.name==="forwardRef":S.type===L.MemberExpression&&S.property.type===L.Identifier?S.property.name==="memo"||S.property.name==="forwardRef":!1}function E(T){if(T.type===L.JSXElement||T.type===L.JSXFragment)return!0;if(T.type===L.BlockStatement){for(let S of T.body)if(S.type===L.ReturnStatement&&S.argument)return E(S.argument)}if(T.type===L.ArrayExpression){for(let S of T.elements)if(S&&(S.type===L.JSXElement||S.type===L.JSXFragment))return!0}return!1}function b(T){if(T.type!==L.ArrowFunctionExpression)return!1;let S=T.body;if(S.type===L.ArrowFunctionExpression){let R=S.body;if(E(R))return!0}return!1}function f(T){if(T.type===L.TaggedTemplateExpression){let S=T.tag;if(S.type===L.MemberExpression&&S.object.type===L.Identifier&&S.object.name==="styled")return!0;if(S.type===L.CallExpression){let R=S.callee;if(R.type===L.Identifier&&R.name==="styled")return!0}}return!1}function A(T){if(T.type===L.TaggedTemplateExpression){let S=T.tag;if(S.type===L.Identifier&&S.name==="css")return!0}return!1}function I(T,S){if(T.id.type!==L.Identifier)return;let R=T.id.name,O=T.init;if(O){if(f(O)||A(O)){l.push({node:S,name:R});return}if((x(R)||O.type===L.ArrowFunctionExpression)&&(O.type===L.ArrowFunctionExpression||O.type===L.FunctionExpression||y(O))){if(O.type===L.ArrowFunctionExpression||O.type===L.FunctionExpression){if(E(O.body)){i.add(R);return}}else if(y(O)){i.add(R);return}}O.type===L.Identifier&&p.set(R,O.name),x(R)||b(O)&&i.add(R)}}function m(T){return T.type===L.ExportDefaultDeclaration||T.type===L.ExportNamedDeclaration}function C(T){if(T.type===L.FunctionDeclaration)return T.id?T.id.name:null;if(T.type===L.VariableDeclaration){let S=T.declarations[0];if(S&&S.id.type===L.Identifier)return S.id.name}if(T.type===L.ExportDefaultDeclaration){let S=T.declaration;if(S.type===L.FunctionDeclaration)return S.id?S.id.name:"default";if(S.type===L.Identifier)return S.name}if(T.type===L.ExportNamedDeclaration){let S=T.declaration;if(S&&S.type===L.FunctionDeclaration)return S.id?S.id.name:null;if(S&&S.type===L.VariableDeclaration){let R=S.declarations[0];if(R&&R.id.type===L.Identifier)return R.id.name}}return null}function h(T,S){return s?u.has(T):t?t.test(S):m(T)}function w(T){let S=new Set;ve(T.node,R=>{if(R.type===L.Identifier)for(let O of l)O.name===R.name&&(S.add(O.name),(O.firstUsagePosition===void 0||R.range[0]<O.firstUsagePosition)&&(O.firstUsagePosition=R.range[0]));if(R.type===L.JSXElement){let O=R.openingElement;if(O.name.type===L.JSXIdentifier)for(let D of l)D.name===O.name.name&&(S.add(D.name),(D.firstUsagePosition===void 0||O.name.range[0]<D.firstUsagePosition)&&(D.firstUsagePosition=O.name.range[0]))}return!1},r),T.usedStyles=S}function P(T){if(T.type===L.VariableDeclaration){for(let S of T.declarations)I(S,T);return}if(T.type===L.FunctionDeclaration){x(T.id.name)&&E(T.body)&&i.add(T.id.name);return}if(T.type===L.ExportNamedDeclaration&&T.declaration){let S=T.declaration;if(S.type===L.VariableDeclaration){for(let R of S.declarations)I(R,T);return}if(S.type===L.FunctionDeclaration&&S.id){x(S.id.name)&&E(S.body)&&i.add(S.id.name);return}}if(T.type===L.ExportDefaultDeclaration){let S=T.declaration;S.type===L.Identifier&&i.add(S.name),(S.type===L.FunctionDeclaration||S.type===L.ArrowFunctionExpression||S.type===L.FunctionExpression)&&(S.type===L.FunctionDeclaration?S.id?i.add(S.id.name):i.add("default"):E(S.body)&&i.add("default"))}}function v(T,S=new Set){if(i.has(T))return!0;if(S.has(T))return!1;S.add(T);let R=p.get(T);return R?v(R,S):!1}let c={};return s&&(c[s]=T=>{let S=T;for(;S.parent&&S.parent.type!==L.Program;)S=S.parent;S.parent&&(S.type===L.VariableDeclaration||S.type===L.FunctionDeclaration||S.type===L.ExportNamedDeclaration||S.type===L.ExportDefaultDeclaration)&&u.add(S)}),c["Program:exit"]=T=>{let S=0;for(let j of T.body){if(j.type===L.ImportDeclaration){S+=1;continue}break}for(let j of T.body)P(j);for(let j of T.body){let Y=C(j);if(Y&&v(Y)){let H=h(j,Y);a.push({node:j,name:Y,isMainComponent:H,usedStyles:new Set,isExported:m(j)})}}if(!s&&t&&!a.some(j=>j.isMainComponent))for(let j of a)j.isExported&&(j.isMainComponent=!0);for(let j of a)w(j);let R=new Set;for(let j of l)R.add(j.name);let O=new Map;for(let j=0;j<T.body.length;j+=1){let Y=T.body[j];for(let H of l)H.node===Y&&O.set(H.name,j)}let D=new Map;for(let j of l){let Y=d(j),H=new Set;if(Y){let ce=g(Y);for(let de of ce)R.has(de)&&de!==j.name&&H.add(de)}D.set(j.name,H)}let Z=new Map;for(let j of l){let Y=D.get(j.name);if(!Y)continue;let H=O.get(j.name);if(H!==void 0)for(let ce of Y){let de=Z.get(ce);(de===void 0||H<de)&&Z.set(ce,H)}}let G=[];for(let j of l){if(j.firstUsagePosition===void 0)continue;let Y=T.body.indexOf(j.node),H=-1;for(let ge of a){if(!ge.usedStyles.has(j.name))continue;let xe=T.body.indexOf(ge.node);(H===-1||xe<H)&&(H=xe)}let ce=Z.get(j.name);if(ce!==void 0&&(H===-1||ce<H)&&(H=ce),H===-1)continue;let de=-1;for(let ge of a){let xe=T.body.indexOf(ge.node);xe<H&&xe>de&&(de=xe)}let Ee=Y<H,Ie=Y>de,Ae=-1,Je=D.get(j.name);if(Je)for(let ge of Je){let xe=O.get(ge);xe!==void 0&&xe>Ae&&(Ae=xe)}let wn=Y>Ae;if(!(Ee&&Ie&&wn)){let ge=de+1;if(Ae+1>ge&&(ge=Ae+1),ge<S&&(ge=S),ge>H)continue;G.push({style:j,targetPosition:ge})}}let V=null;if(a.length>1){let j=a.map(H=>({c:H,idx:T.body.indexOf(H.node)})).sort((H,ce)=>H.idx-ce.idx)[0]?.c,Y=a.find(H=>H.isMainComponent)||null;j&&Y&&j.node!==Y.node&&(V={component:Y,targetBefore:j.node})}if(G.length>0||V){let j=G[0]?.style.node||V?.component.node||T,Y=G.length>0?"stylesShouldBeAboveUsage":"mainComponentShouldBeFirst";e.report({node:j,messageId:Y,fix:F(G,V,T.body)})}},c;function F(T,S,R){return function*(O){T.sort((Z,G)=>Z.targetPosition-G.targetPosition);for(let{style:Z}of T){let G=r.getCommentsBefore(Z.node),V=Z.node.range[0],j=Z.node.range[1];G.length>0&&G[0]&&(V=G[0].range[0]),V===Z.node.range[0]&&r.text.slice(0,V).trim().length===0&&(V=0),yield O.removeRange([V,j])}let D=new Map;for(let Z of T){let G=D.get(Z.targetPosition)||[];G.push(Z),D.set(Z.targetPosition,G)}for(let[Z,G]of D){let V=R[Z];if(!V)continue;let j=r.getCommentsBefore(V),Y=j.length>0&&j[0]?j[0].range[0]:V.range[0],H=[];for(let{style:ce}of G){let de=r.getCommentsBefore(ce.node),Ee=r.getText(ce.node);de.length>0&&(Ee=`${de.map(Ae=>r.getText(Ae)).join(`
|
|
47
47
|
`)}
|
|
48
48
|
${Ee}`),H.push(Ee)}yield O.insertTextBeforeRange([Y,Y],`${H.join(`
|
|
49
49
|
|