@eslint-sukka/eslint-plugin-sukka-full 8.12.0 → 8.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +6 -6
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -15,15 +15,15 @@ ${n}break;`)}(t,i,o,l),yield function*(e,t,r){e&&"BlockStatement"!==e.type&&(yie
|
|
|
15
15
|
${r}`),yield t.insertTextAfter(e,`
|
|
16
16
|
${r}}`))}(t,i,l))}}}({discriminant:n,ifStatements:s},e,t)),yield l}})},meta:{type:"suggestion",docs:{description:"Prefer `switch` over multiple `else-if`.",recommended:"unopinionated"},fixable:"code",schema:[{type:"object",additionalProperties:!1,properties:{minimumCases:{type:"integer",minimum:2,description:"The minimum number of `if`/`else if` cases before suggesting a `switch` statement."},emptyDefaultCase:{enum:["no-default-comment","do-nothing-comment","no-default-case"],description:"How to handle an empty `default` case."}}}],defaultOptions:[{minimumCases:3,emptyDefaultCase:"no-default-comment"}],messages:{[py]:"Use `switch` instead of multiple `else-if`."},languages:["js/js"]}},pv="require-number-to-fixed-digits-argument";function pC(e){let t=e.match(/^[ \t]*(?=\S)/gm);if(!t)return e;let r=1/0;for(let e of t)r=Math.min(r,e.length);return 0===r||r===1/0?e:e.replace(RegExp(`^[ \\t]{${r}}`,"gm"),"")}let pA=/^(?:( )+|\t+)/,pT="space";function pw(e,t){let r,n,o=new Map,a=0;for(let i of e.split(/\n/g)){if(!i)continue;let e=i.match(pA);if(null===e)a=0,r="";else{let i=e[0].length,s=e[1]?pT:"tab";if(t&&s===pT&&1===i)continue;s!==r&&(a=0),r=s;let l=1,u=0,p=i-a;if(a=i,0===p)l=0,u=1;else{let e=Math.abs(p);if(t&&s===pT&&1===e)continue;n=(s===pT?"s":"t")+String(e)}let c=o.get(n);o.set(n,void 0===c?[1,0]:[c[0]+l,c[1]+u])}}return o}function pk(e){let t;if("string"!=typeof e)throw TypeError("Expected a string");let r=pw(e,!0);0===r.size&&(r=pw(e,!1));let n=function(e){let t,r=0,n=0;for(let[o,[a,i]]of e)(a>r||a===r&&i>n)&&(r=a,n=i,t=o);return t}(r),o=0,a="";if(void 0!==n){var i,s;({type:t,amount:o}={type:"s"===n[0]?pT:"tab",amount:Number(n.slice(1))}),i=t,s=o,a=(i===pT?" ":" ").repeat(s)}return{amount:o,type:t,indent:a}}let pI="template-indent",pj=(e,t=new Set)=>e.map((e,r)=>t.has(r+1)||""===e.trim()?"":e).join("\n"),pF=[{type:"object",additionalProperties:!1,properties:{indent:{oneOf:[{type:"string",pattern:/^\s+$/.source,description:"Whitespace string to use as indentation."},{type:"integer",minimum:1,description:"Number of spaces to use as indentation."}],description:"The indentation to use inside the template literal."},tags:{type:"array",uniqueItems:!0,items:{type:"string"},description:"Tagged template names to check."},functions:{type:"array",uniqueItems:!0,items:{type:"string"},description:"Function names whose template literal arguments to check."},selectors:{type:"array",uniqueItems:!0,items:{type:"string"},description:"AST selectors for template literals to check."},comments:{type:"array",uniqueItems:!0,items:{type:"string"},description:"Comment patterns to mark template literals for checking."}}}],pB="no-await-in-promise-methods/error",pR="no-await-in-promise-methods/suggestion",p$=["all","allSettled","any","race"],pP="no-negation-in-equality-check/error",pL="no-negation-in-equality-check/suggestion",pN=new Set(["===","!==","==","!="]),pM=e=>"UnaryExpression"===e.type&&e.prefix&&"!"===e.operator;function pO(e,{methods:t,messageId:r}){e.on("CallExpression",n=>{if(!td(n,{methods:t,argumentsLength:2,optionalCall:!1}))return;let o=n.arguments[1],a=function(e,t){if("Identifier"===e.type&&"Infinity"===e.name)return"Infinity";if(tc(e,{object:"Number",property:"POSITIVE_INFINITY",computed:!1,optional:!1}))return"Number.POSITIVE_INFINITY";let r="ChainExpression"===e.type;if(r&&(e=e.expression),tc(e,{property:"length",computed:!1})&&tQ(t,e.object))return`${"Identifier"===t.type?t.name:"…"}${r?"?.":"."}length`}(o,n.callee.object);if(!a)return;let i=n.callee.property.name,s={description:a};return"splice"===i?s.argumentName="deleteCount":"toSpliced"===i&&(s.argumentName="skipCount"),{node:o,messageId:r,data:s,fix:t=>ok(t,o,e)}})}let pq="no-unnecessary-slice-end",pU="catch-error-name",pW={create:e=>{let t=e.options[0],{name:r}=t,n=t.ignore.map(e=>c.isRegExp(e)?e:RegExp(e,"u")),o=e=>e===r||n.some(t=>t.test(e))||e.endsWith(r)||e.endsWith(oo(r));e.on("Identifier",t=>{if(("CatchClause"!==t.parent.type||t.parent.param!==t)&&!(("FunctionExpression"===t.parent.type||"ArrowFunctionExpression"===t.parent.type)&&t.parent.params[0]===t&&(td(t.parent.parent,{method:"then",argumentsLength:2,optionalCall:!1})||td(t.parent.parent,{method:"catch",argumentsLength:1,optionalCall:!1}))&&t.parent.parent.arguments.at(-1)===t.parent))return;let n=t.name;if(o(n)||o(n.replaceAll(/_+$/g,"")))return;let a=ei(e.sourceCode.getScope(t),t);if(!a||"_"===n&&0===a.references.length)return;let i=tG(r,[a.scope,...a.references.map(({from:e})=>e)]),s={node:t,messageId:pU,data:{originalName:n,fixedName:i||r}};return i&&(s.fix=t=>oW(a,i,e,t)),s})},meta:{type:"suggestion",docs:{description:"Enforce a specific parameter name in catch clauses.",recommended:!0},fixable:"code",schema:[{type:"object",additionalProperties:!1,properties:{name:{type:"string",description:"The expected name for the error variable."},ignore:{type:"array",uniqueItems:!0,description:"Patterns to ignore."}}}],defaultOptions:[{name:"error",ignore:[]}],messages:{[pU]:"The catch parameter `{{originalName}}` should be named `{{fixedName}}`."},languages:["js/js"]}},p_="invalidExport",pV="doNotPassMessageToSuper",pz="doNotAssignMessageWithoutSetter",pK="missingOptionsParameter",pG="invalidOptionsParameter",pJ="passMessageToSuper",pX="passOptionsToSuper",pY=/^(?:[A-Z][\da-z]*)*Error$/,pH=e=>`
|
|
17
17
|
name = '${e}';
|
|
18
|
-
`,pZ=e=>{var t;let r=(t=e.superClass,t?.type==="Identifier"?t.name:t?.type!=="MemberExpression"||t.computed||"Identifier"!==t.property.type?void 0:t.property.name);return!!r&&pY.test(r)},pQ=e=>"ExpressionStatement"===e.type&&"CallExpression"===e.expression.type&&tg(e.expression.callee,"super"),p0=(e,t)=>"ExpressionStatement"===e.type&&"AssignmentExpression"===e.expression.type&&"="===e.expression.operator&&tg(e.expression.left,`this.${t}`),p1=(e,t)=>({node:e,message:`The \`name\` property should be set to \`${t}\`.`}),p2=(e,t)=>e?.value&&e.value.value===t,p3=(e,t)=>"MethodDefinition"===e.type&&e.kind===t&&!e.static&&!e.computed&&"Identifier"===e.key.type&&"message"===e.key.name,p8=e=>e?.type==="Identifier"?e:e?.type==="AssignmentPattern"&&"Identifier"===e.left.type?e.left:void 0,p6=e=>p8(e)?.name==="options",p9=(e,t)=>{if("ThisExpression"===e.type||"Super"===e.type)return!0;for(let r of t[e.type]??[]){let n=e[r];if(n){if(Array.isArray(n)){if(n.some(e=>e&&p9(e,t)))return!0;continue}if(p9(n,t))return!0}}return!1},p5=e=>{let t=p8(e);return t.typeAnnotation?t.optional?"options?: ErrorOptions":"options: ErrorOptions":"options"},p4=(e,t,r)=>n=>{let o=t.arguments;if(0===o.length){let o=e.getTokenAfter(t.callee,e=>"("===e.value);return n.insertTextAfter(o,`${r}, options`)}if(1===o.length){let e;return"undefined"!==r&&(!(e=o[0])||tx(e))?n.replaceText(o[0],`${r}, options`):n.insertTextAfter(o[0],", options")}},p7=(e,t)=>e?.type==="Identifier"&&e.name===t.name;function*ce(e,t){if(!pZ(t)||null===t.id)return;let{name:r}=t.id,n=oo(r).replace(/(?:error)?$/i,"Error");r!==n&&(yield{node:t.id,message:`Invalid class name, use \`${n}\`.`});let{body:o}=t.body,{sourceCode:a}=e,i=o.find(e=>"constructor"===e.kind),s=o.find(e=>"PropertyDefinition"===e.type&&!e.static&&!e.computed&&"Identifier"===e.key.type&&"name"===e.key.name);if(!i){if(p2(s,r))return;let e=a.getRange(t.body);yield{...p1(s?.value??t,r),fix:t=>s?.value?t.replaceText(s.value,`'${r}'`):s?t.replaceText(s,pH(r).trim()):t.insertTextAfterRange([e[0],e[0]+1],pH(r))};return}let l=o.some(e=>p3(e,"get")),u=o.some(e=>p3(e,"set"));yield*function*(e,t,r){let{sourceCode:n}=e,o=t.value.body;if(!o)return;let a=o.body,{hasMessageGetter:i,hasMessageSetter:s,checkOptions:l}=r,u=a.find(e=>pQ(e)),p=a.findIndex(e=>pQ(e)),c=a.findIndex(e=>p0(e,"message")),d=i||s,m=!1;if(u){let r;if(d&&!(!(r=u.expression.arguments[0])||tx(r)))m=!0,yield{node:u,messageId:pV};else if(i&&!s&&-1!==c)m=!0,yield{node:a[c],messageId:pz};else if(!s&&-1!==c){let r=a[c];m=!0,yield{node:u,message:"Pass the error message to `super()` instead of setting `this.message`.",*fix(i){let s=r.expression.right,[l,d]=t.value.params,m=p8(l),f=1===t.value.params.length&&m&&!p6(l),g=f||p6(d);if(0===u.expression.arguments.length){if(c!==p+1||p9(s,n.visitorKeys))return;let[t]=n.getRange(u);yield i.insertTextAfterRange([t,t+6],g?`${eZ(s,e)}, options`:eZ(s,e))}else{let e;if(e=u.expression.arguments[0],n.getText(e)!==n.getText(s))return;g&&1===u.expression.arguments.length&&(yield i.insertTextAfter(u.expression.arguments[0],", options"))}f&&(yield i.insertTextAfter(l,`, ${p5(l)}`));let y=0===c?n.getRange(o)[0]:n.getRange(a[c-1])[1],[,h]=n.getRange(r);yield i.removeRange([y,h])}}}}else m=!0,yield{node:o,message:"Missing call to `super()` in constructor."};let f=function(e,t,r){let{name:n,nameProperty:o}=r,a=t.find(e=>p0(e,"name"));return a?"Literal"!==a.expression.right.type||a.expression.right.value!==n?p1(a.expression.right??e,n):void 0:p2(o,n)?void 0:p1(o?.value??e,n)}(o,a,r);if(f&&(yield f),!f&&l&&!m){let r=((e,t,r,n)=>{let o=t.value.params,a=o[0],i=p8(a);if(0===o.length||!i)return;let s=r.expression;if(p6(a)){if(!p6(s.arguments[1])){let t={node:s,messageId:pX};return p7(s.arguments[0],i)||(t.fix=p4(e.sourceCode,s,"undefined")),t}return}let l=o[1],u=!n&&"message"===i.name,p=u?i.name:"undefined";if(!l)return{node:a,messageId:pK,fix:function*(r){let{sourceCode:n}=e,o=p4(n,s,p)(r);if(!o)return;let a=t.value.params[0];yield r.insertTextAfter(a,`, ${p5(a)}`),yield o}};if(!p6(l))return{node:l,messageId:pG};if(u&&!p7(s.arguments[0],i)){let t;return{node:s,messageId:pJ,fix:(t=e.sourceCode,e=>{let r,n=s.arguments;if(0===n.length){let r=t.getTokenAfter(s.callee,e=>"("===e.value);return e.insertTextAfter(r,`${p}, options`)}if(!(r=n[0])||tx(r))return e.replaceText(n[0],1===n.length?`${p}, options`:p)})}}if(!p6(s.arguments[1]))return{node:s,messageId:pX,fix:p4(e.sourceCode,s,p)}})(e,t,u,d);r&&(yield r)}}(e,i,{name:r,nameProperty:s,hasMessageGetter:l,hasMessageSetter:u,checkOptions:r===n})}let ct="no-lonely-if",cr=e=>"IfStatement"===e.type&&!e.alternate;function cn(e,t){let r={ifToken:t.getFirstToken(e),openingParenthesisToken:t.getFirstToken(e,1)},{consequent:n}=e;return r.closingParenthesisToken=t.getTokenBefore(n),"BlockStatement"===n.type&&(r.openingBraceToken=t.getFirstToken(n),r.closingBraceToken=t.getLastToken(n)),r}let co=(e,t,r)=>r.text.slice(r.getRange(e)[1],r.getRange(t)[0]),ca=e=>e.trim()?e:"",ci=(e,t)=>/\s$/u.test(e)&&/^\s/u.test(t)?e+t.trimStart():e+t,cs=(e,t)=>co(e.ifToken,e.openingParenthesisToken,t),cl=(e,t,r)=>{let n,o=co(e.openingParenthesisToken,e.closingParenthesisToken,r);return eQ(e.test,t)?o:"LogicalExpression"===(n=e.test).type&&("||"===n.operator||"??"===n.operator)||"ConditionalExpression"===n.type||"AssignmentExpression"===n.type||"YieldExpression"===n.type||"SequenceExpression"===n.type?`(${o})`:o},cu="no-magic-array-flat-depth",cp="no-negated-condition",cc="identifier",cd="non-identifier",cm="prefer-negative-index",cf=new Map([["slice",{argumentsIndexes:[0,1],supportObjects:new Set(["Array","String","ArrayBuffer",...rE])}],["subarray",{argumentsIndexes:[0,1],supportObjects:new Set(rE)}],["splice",{argumentsIndexes:[0],supportObjects:new Set(["Array"])}],["toSpliced",{argumentsIndexes:[0],supportObjects:new Set(["Array"])}],["at",{argumentsIndexes:[0],supportObjects:new Set(["Array","String",...rE])}]]),cg=e=>{let{type:t,property:r}=e;if("MemberExpression"===t&&"Identifier"===r.type)return r.name};var cy=["node:assert","assert","node:assert/strict","assert/strict","node:async_hooks","async_hooks","node:buffer","buffer","node:child_process","child_process","node:cluster","cluster","node:console","console","node:constants","constants","node:crypto","crypto","node:dgram","dgram","node:diagnostics_channel","diagnostics_channel","node:dns","dns","node:dns/promises","dns/promises","node:domain","domain","node:events","events","node:ffi","node:fs","fs","node:fs/promises","fs/promises","node:http","http","node:http2","http2","node:https","https","node:inspector","inspector","node:inspector/promises","inspector/promises","node:module","module","node:net","net","node:os","os","node:path","path","node:path/posix","path/posix","node:path/win32","path/win32","node:perf_hooks","perf_hooks","node:process","process","node:querystring","querystring","node:quic","node:readline","readline","node:readline/promises","readline/promises","node:repl","repl","node:sea","node:sqlite","node:stream","stream","node:stream/consumers","stream/consumers","node:stream/iter","stream/iter","node:stream/promises","stream/promises","node:stream/web","stream/web","node:string_decoder","string_decoder","node:test","node:test/reporters","node:timers","timers","node:timers/promises","timers/promises","node:tls","tls","node:trace_events","trace_events","node:tty","tty","node:url","url","node:util","util","node:util/types","util/types","node:v8","v8","node:vm","vm","node:wasi","wasi","node:worker_threads","worker_threads","node:zlib","zlib","node:zlib/iter","zlib/iter"];function ch(t){if("string"!=typeof t)throw TypeError("Expected a string");return(e??=new Set(cy)).has(t)}let cx="prefer-node-protocol",cb="node:",cE="consistent-date-clone/error",cD="no-accessor-recursion/error",cS=e=>"Identifier"===e.type||"PrivateIdentifier"===e.type,cv=(e,t)=>["type","name"].every(r=>e[r]===t[r]),cC=(e,t)=>"MemberExpression"===e.parent.type&&e.parent.object===e&&!e.parent.computed&&cS(e.parent.property)&&cv(e.parent.property,t.key),cA="error/calculate-dirname",cT="error/calculate-filename";function cw(e,{modules:t,functionName:r,sourceCode:n}){if(!e7(e,{optional:!1,argumentsLength:1}))return!1;let o=new Set;return function e(t,i){if("MemberExpression"===t.type)return!!("property"===i&&tc(t,{property:r,computed:!1,optional:!1}))&&e(t.object,"module");if("CallExpression"===t.type)return"module"===i&&td(t,{object:"process",method:"getBuiltinModule",argumentsLength:1,optionalMember:!1,optionalCall:!1})&&a(t.arguments[0]);if("Identifier"!==t.type||o.has(t))return!1;o.add(t);let s=ei(n.getScope(t),t);return!!s&&1===s.defs.length&&function(t,n){if("ImportBinding"===t.type){if(!a(t.parent.source))return!1;let e=t.node;return"module"===n?e?.type==="ImportDefaultSpecifier"||e?.type==="ImportNamespaceSpecifier":e?.type==="ImportSpecifier"&&e.imported.name===r}return"Variable"===t.type&&function t(n,o){let{parent:a}=n;return"VariableDeclarator"===a.type?!!a.init&&a.id===n&&"VariableDeclaration"===a.parent.type&&"const"===a.parent.kind&&e(a.init,o):"Property"===a.type&&!!("property"===o&&a.value===n&&!a.computed&&"Identifier"===a.key.type&&a.key.name===r)&&t(a.parent,"module")}(t.name,n)}(s.defs[0],i)}(e.callee,"property");function a(e){return e?.type==="Literal"&&t.has(e.value)}}function ck(e,t){return cw(e,{modules:new Set(["url","node:url"]),functionName:"fileURLToPath",sourceCode:t})}function cI(e,t){return cw(e,{modules:new Set(["path","node:path"]),functionName:"dirname",sourceCode:t})}let cj="no-unnecessary-array-flat-depth",cF="no-unnecessary-array-splice-count",cB="no-useless-error-capture-stack-trace/error",cR="prefer-class-fields/error",c$="prefer-class-fields/suggestion",cP="prefer-bigint-literals/error",cL="prefer-bigint-literals/suggestion",cN="prefer-classlist-toggle/error",cM="prefer-classlist-toggle/suggestion",cO=e=>tc(e,{property:"classList",computed:!1}),cq=(e,t,r)=>{let n={node:r??e,messageId:cN};return"IfStatement"===e.type||ti(e)||ti(e.parent)?n.fix=t:n.suggest=[{messageId:cM,fix:t}],n},cU=(e,t,r)=>{let{sourceCode:n}=t,o=eZ(e,t);return r?(!eQ(e,n)&&n8(e,"!")&&(o=`(${o})`),o=`!${o}`):(eQ(e,n)||"SequenceExpression"!==e.type||(o=`(${o})`),o)},cW=(e,t)=>td(e,{methods:t,argumentsLength:1,optionalCall:!1,optionalMember:!1})&&cO(e.callee.object),c_=(e,t)=>tQ(e.callee.object,t.callee.object)&&tQ(e.arguments[0],t.arguments[0]),cV=(e,t,r)=>t?("ChainExpression"===e.type&&(e=e.expression),cW(e,["contains"])&&c_(e,r))?e:void 0:"UnaryExpression"===e.type&&"!"===e.operator&&e.prefix?cV(e.argument,!t,r):void 0,cz="require-module-attributes",cK="error",cG="suggestion/array",cJ="suggestion/object",cX="suggestion/object-assign",cY="suggestion/set",cH="suggestion/map",cZ=(e,t,r)=>{let{sourceCode:n}=r,o=rd(e);return t.some(e=>{let t=n.getRange(e);return o.some(e=>{let[r,o]=n.getRange(e);return r>=t[0]&&o<=t[1]})})};function cQ(e,t){if(!te(e,{names:t,maximumArguments:1}))return!1;let[r]=e.arguments;return!r||"ArrayExpression"===r.type}function*c0(e,t,r){let n=!ep(t.sourceCode.getTokenBefore(e));yield oq(e,t,r,n)}function c1(e,t,r,n){let{sourceCode:o}=e,[a,i]=o.getLastTokens(r,2),s=("ArrayExpression"===r.type?r.elements:r.properties).length>0&&!eu(a);return t.insertTextBefore(i,`${s?",":""} ${n}`)}function*c2({context:e,fixer:t,newExpression:r,elementsText:n,nextExpressionStatement:o}){if(tJ(r,e)){let[o]=r.arguments;if(o)yield c1(e,t,o,n);else{let{openingParenthesisToken:o}=tJ(r,e)?tX(r,e):{};yield t.insertTextAfter(o,`[${n}]`)}}else yield t.insertTextAfter(r,`([${n}])`);yield*c0(o,e,t)}let c3=[{testValue:e=>e?.type==="ArrayExpression",getProblematicNode({context:e,variable:t,nextExpressionStatement:r}){let n=r.expression;if(td(n,{object:t.name,methods:["push","unshift"],optionalMember:!1,optionalCall:!1})&&n.arguments.length>0&&!cZ(t,n.arguments,e))return n},getProblem(e,t){let{context:r,assignType:n,getFix:o}=t,{sourceCode:a}=r,i=e.callee,s=i.property,l={node:i,messageId:cK,data:{objectType:"array"}},u="unshift"===s.name,p=o(t,{callExpression:e,isPrepend:u});return e.arguments.some(e=>eP(e,a))?l.suggest=[{messageId:cG,fix:p,data:{operation:u?"Prepend":"Append",assignType:n}}]:l.fix=p,l},getFix:({context:e,valueNode:t,nextExpressionStatement:r},{callExpression:n,isPrepend:o})=>function*(a){let i=tY(e,n,!1);yield o?a.insertTextAfter(e.sourceCode.getFirstToken(t),`${i}, `):c1(e,a,t,i),yield c0(r,e,a)}},{testValue:e=>e?.type==="ObjectExpression",getProblematicNode({context:e,variable:t,nextExpressionStatement:r}){let n=r.expression;if(!("AssignmentExpression"===n.type&&"="===n.operator&&tc(n.left,{object:t.name,optional:!1})))return;let o=n.right,a=n.left,{property:i}=a;if(!cZ(t,a.computed?[i,o]:[o],e))return n},getProblem(e,t){let{context:r,assignType:n,getFix:o}=t,{sourceCode:a}=r,{left:i,right:s}=e,{property:l}=i,u=a.getTokenAfter(i,t=>"Punctuator"===t.type&&t.value===e.operator),p={node:e,loc:{start:a.getLoc(e).start,end:a.getLoc(u).end},messageId:cK,data:{objectType:"object"}},c=o(t,{assignmentExpression:e,memberExpression:i,property:l,value:s});return i.computed&&eP(l,a)||eP(s,a)?p.suggest=[{messageId:cJ,data:{assignType:n},fix:c}]:p.fix=c,p},getFix:({context:e,valueNode:t,nextExpressionStatement:r},{memberExpression:n,property:o,value:a})=>function*(i){let s=eZ(o,e);n.computed&&(s=`[${s}]`);let l=eZ(a,e),u=`${s}: ${l},`,[p,c]=e.sourceCode.getLastTokens(t,2),d=t.properties.length>0&&!eu(p);yield i.insertTextBefore(c,`${d?",":""} ${u}`),yield c0(r,e,i)}},{testValue:e=>e?.type==="ObjectExpression",getProblematicNode({context:e,variable:t,nextExpressionStatement:r}){let n=r.expression;if(!td(n,{object:"Object",method:"assign",minimumArguments:2,optionalMember:!1,optionalCall:!1}))return;let[o,a]=n.arguments;if(!("Identifier"!==o.type||o.name!==t.name||"SpreadElement"===a.type||cZ(t,[a],e)))return n},getProblem(e,t){let{context:r,assignType:n,getFix:o}=t,{sourceCode:a}=r,[,i]=e.arguments,s={node:e.callee,messageId:cK,data:{objectType:"object"}},l=o(t,{callExpression:e,firstValue:i});return eP(i,a)?s.suggest=[{messageId:cX,data:{description:"ObjectExpression"===i.type?"Move properties to":"Spread properties in",assignType:n},fix:l}]:s.fix=l,s},getFix:({context:e,valueNode:t,nextExpressionStatement:r},{callExpression:n,firstValue:o})=>function*(a){let i;("ObjectExpression"===o.type?o.properties.length>0&&(i=function(e,t){let{sourceCode:r}=t,n=r.getFirstToken(e),[o,a]=r.getLastTokens(e,2),[,i]=r.getRange(n),[s]=r.getRange(eu(o)?o:a);return r.text.slice(i,s)}(o,e)):i=`...${eZ(o,e)}`,i&&(yield c1(e,a,t,i)),2!==n.arguments.length)?yield ok(a,o,e):yield c0(r,e,a)}},{testValue:e=>cQ(e,["Set","WeakSet"]),getProblematicNode({context:e,variable:t,nextExpressionStatement:r}){let n=r.expression;if(("ChainExpression"===n.type&&(n=n.expression),td(n,{object:t.name,method:"add",argumentsLength:1,optionalMember:!1,optionalCall:!1}))&&!cZ(t,n.arguments,e))return n},getProblem(e,t){let{context:r,assignType:n,valueNode:o,getFix:a}=t,{sourceCode:i}=r,s={node:e.callee,messageId:cK,data:{objectType:`\`${o.callee.name}\``}},l=a(t,{callExpression:e,newExpression:o});return e.arguments.some(e=>eP(e,i))?s.suggest=[{messageId:cY,data:{assignType:n},fix:l}]:s.fix=l,s},getFix:({context:e,nextExpressionStatement:t},{callExpression:r,newExpression:n})=>o=>{let a=tY(e,r,!1);return c2({context:e,fixer:o,newExpression:n,elementsText:a,nextExpressionStatement:t})}},{testValue:e=>cQ(e,["Map","WeakMap"]),getProblematicNode({context:e,variable:t,nextExpressionStatement:r}){let n=r.expression;if(td(n,{object:t.name,method:"set",argumentsLength:2,optionalCall:!1})&&!cZ(t,n.arguments,e))return n},getProblem(e,t){let{context:r,assignType:n,valueNode:o,getFix:a}=t,{sourceCode:i}=r,s={node:e.callee,messageId:cK,data:{objectType:`\`${o.callee.name}\``}},l=a(t,{callExpression:e,newExpression:o});return e.arguments.some(e=>eP(e,i))?s.suggest=[{messageId:cH,data:{assignType:n},fix:l}]:s.fix=l,s},getFix:({context:e,nextExpressionStatement:t},{callExpression:r,newExpression:n})=>o=>{let a=tY(e,r,!1);return c2({context:e,fixer:o,newExpression:n,elementsText:`[${a}]`,nextExpressionStatement:t})}}],c8="no-useless-collection-argument/error",c6="no-useless-collection-argument/suggestion",c9="prefer-response-static-json",c5=/([\p{Ll}\d])(\p{Lu})/gu,c4=/(\p{Lu})([\p{Lu}][\p{Ll}])/gu,c7=/(\d)\p{Ll}|(\p{L})\d/u,de=/[^\p{L}\d]+/giu,dt="$1\0$2";function dr(e){let t=e.trim();t=(t=t.replace(c5,dt).replace(c4,dt)).replace(de,"\0");let r=0,n=t.length;for(;"\0"===t.charAt(r);)r++;if(r===n)return[];for(;"\0"===t.charAt(n-1);)n--;return t.slice(r,n).split(/\0/g)}function dn(e){let t=dr(e);for(let e=0;e<t.length;e++){let r=t[e],n=c7.exec(r);if(n){let o=n.index+(n[1]??n[2]).length;t.splice(e,1,r.slice(0,o),r.slice(o))}}return t}function da(e,t){let[r,n,o]=dc(e,t);return r+n.map(dl(t?.locale)).join(t?.delimiter??" ")+o}function di(e,t){var r,n;let[o,a,i]=dc(e,t),s=dl(t?.locale),l=du(t?.locale),u=t?.mergeAmbiguousCharacters?(r=s,n=l,e=>`${n(e[0])}${r(e.slice(1))}`):dp(s,l);return o+a.map((e,t)=>0===t?s(e):u(e,t)).join(t?.delimiter??"")+i}function ds(e,t){let[r,n,o]=dc(e,t),a=dp(dl(t?.locale),du(t?.locale));return r+n.map(a).join("")+o}function dl(e){return!1===e?e=>e.toLowerCase():t=>t.toLocaleLowerCase(e)}function du(e){return!1===e?e=>e.toUpperCase():t=>t.toLocaleUpperCase(e)}function dp(e,t){return(r,n)=>{let o=r[0];return(n>0&&o>="0"&&o<="9"?"_"+o:t(o))+e(r.slice(1))}}function dc(e,t={}){let r=t.split??(t.separateNumbers?dn:dr),n=t.prefixCharacters??"",o=t.suffixCharacters??"",a=0,i=e.length;for(;a<e.length;){let t=e.charAt(a);if(!n.includes(t))break;a++}for(;i>a;){let t=i-1,r=e.charAt(t);if(!o.includes(r))break;i=t}return[e.slice(0,a),r(e.slice(a,i)),e.slice(i)]}let dd="filename-case",dm="directory-case",df="filename-extension",dg=e=>!/^[\w-]$/.test(e),dy=new Set(["index.js","index.mjs","index.cjs","index.ts","index.tsx","index.vue"]),dh=new Intl.ListFormat("en-US",{type:"disjunction"}),dx=/^[\da-z]+$/i,db=/^[A-Z]{3,}(?=\d*[A-Z](?:[a-z]|\d+[a-z]))/,dE=e=>e>="0"&&e<="9",dD=e=>e>="a"&&e<="z",dS=e=>e>="A"&&e<="Z",dv={camelCase:{fn:di,name:"camel case"},camelCaseWithAcronyms:{fn:function(e){return!function(e){if(!dD(e[0]))return!1;for(let t=1;t<e.length;t++){let r=e[t];if(dD(r)||dE(r))continue;if(!dS(r))return!1;let n=t;for(;dS(e[t+1]);)t++;if(t!==n){if(dD(e[t+1])){t--;continue}for(;dE(e[t+1]);)t++;if(t===e.length-1)return!0;if(!dS(e[t+1]))return!1}}return!0}(e)?di(e):e},name:"camel case with acronyms"},kebabCase:{fn:function(e,t){return da(e,{delimiter:"-",...t})},name:"kebab case"},snakeCase:{fn:function(e,t){return da(e,{delimiter:"_",...t})},name:"snake case"},pascalCase:{fn:function(e){if(dx.test(e)){let t=db.exec(e)?.[0],r=t&&e.slice(t.length);if(r&&ds(r)===r)return e}return ds(e)},name:"pascal case"}};function dC(e,t){return e.filter(({ignored:e})=>!e).every(({word:e})=>t.some(t=>t(e)===e))}function dA(e,t,{leading:r,trailing:n}){let{samples:o}=function(e,t=1/0){let r=e.reduce((e,{length:t})=>e*t,1),n=Array.from({length:Math.min(r,t)},(t,r)=>{let n=r,o=[];for(let t=e.length-1;t>=0;t--){let r=e[t],{length:a}=r,i=n%a;n=(n-i)/a,o.unshift(r[i])}return o});return{total:r,samples:n}}(e.map(({word:e,ignored:r})=>r?[e]:t.map(t=>t(e))));return[...new Set(o.map(e=>`${r}${e.join("")}${n}`))]}let dT=/^(?<leading>_+)(?<tailing>.*)$/;function dw(e){let t,{leading:r="",tailing:n=e}=(dT.exec(e)||{groups:{}}).groups,o=[];for(let e of n){let r=dg(e);t?.ignored===r?t.word+=e:(t={word:e,ignored:r},o.push(t))}return{leading:r,words:o}}function dk(e){let t;return t=e.map(e=>dv[e].name),dh.format(t)}let dI=[{description:"The rule options.",anyOf:[{properties:{case:{enum:["camelCase","camelCaseWithAcronyms","snakeCase","kebabCase","pascalCase"],description:"The filename and directory name case style."},ignore:{type:"array",uniqueItems:!0,description:"Path segment patterns to ignore."},multipleFileExtensions:{type:"boolean",description:"Whether to treat additional, dot-separated parts of a filename as file extensions."},checkDirectories:{type:"boolean",description:"Whether to check directory names."}},additionalProperties:!1},{properties:{cases:{properties:{camelCase:{type:"boolean",description:"Whether to allow camelCase filenames and directory names."},camelCaseWithAcronyms:{type:"boolean",description:"Whether to allow camelCase filenames and directory names with acronym segments."},snakeCase:{type:"boolean",description:"Whether to allow snake_case filenames and directory names."},kebabCase:{type:"boolean",description:"Whether to allow kebab-case filenames and directory names."},pascalCase:{type:"boolean",description:"Whether to allow PascalCase filenames and directory names."}},additionalProperties:!1,description:"The allowed filename and directory name case styles."},ignore:{type:"array",uniqueItems:!0,description:"Path segment patterns to ignore."},multipleFileExtensions:{type:"boolean",description:"Whether to treat additional, dot-separated parts of a filename as file extensions."},checkDirectories:{type:"boolean",description:"Whether to check directory names."}},additionalProperties:!1}]}],dj="consistent-template-literal-escape",dF="iterable-accepting",dB="for-of",dR="yield-star",d$="spread",dP="iterator-method",dL="iterable-accepting/suggestion",dN="iterator-method/suggestion",dM=["every","find","forEach","some"],dO="reduce",dq=e=>td(e,{method:"toArray",argumentsLength:0,optionalCall:!1,optionalMember:!1}),dU="prefer-simple-condition-first",dW="prefer-simple-condition-first/suggestion";function d_(e){return"Identifier"===e.type||"Literal"===e.type||"UnaryExpression"===e.type&&("-"===e.operator||"+"===e.operator)&&"Literal"===e.argument.type&&"number"==typeof e.argument.value}function dV(e){return"Identifier"===e.type||("UnaryExpression"===e.type&&"!"===e.operator?dV(e.argument):"BinaryExpression"===e.type&&("==="===e.operator||"!=="===e.operator)?d_(e.left)&&d_(e.right)&&("Identifier"===e.left.type||"Identifier"===e.right.type):"LogicalExpression"===e.type&&dV(e.left)&&dV(e.right))}let dz=new Set(["AssignmentExpression","UpdateExpression","TaggedTemplateExpression","AwaitExpression","YieldExpression","ImportExpression"]);function dK(e,t,{operator:r,property:n}){let o=eQ(e,t),a=o?eZ(e,t):t.sourceCode.getText(e);return!o&&n6(e,{operator:r,property:n})&&(a=`(${a})`),a}let dG="switch-case-break-position",dJ=new Set(["BreakStatement","ReturnStatement","ContinueStatement","ThrowStatement"]),dX="first-child",dY="first-element-child",dH="query-selector",dZ="closest",dQ="merge-query-selector",d0="suggestion-first-child",d1="suggestion-first-element-child",d2="suggestion-merge-query-selector",d3={method:"querySelector",argumentsLength:1,optionalCall:!1,optionalMember:!1},d8=(e,t)=>tc(e,{property:t,optional:!1,computed:!1}),d6=e=>"MemberExpression"===e.type&&!e.optional&&e.computed&&e8(e.property)&&Number.isSafeInteger(e.property.value)&&e.property.value>=0,d9=(e,t)=>t.getCommentsInside(e).length>0,d5=(e,t,r,n)=>{let{sourceCode:o}=n;if(d9(e,o))return;let[,a]=eH(e.object,n),[,i]=o.getRange(e);return[{messageId:r,fix:r=>[r.replaceText(e.object.property,t),r.removeRange([a,i])]}]},d4=e=>tc(e,{property:"parentElement",optional:!1,computed:!1}),d7=e=>void 0!==e3(e),me=e=>td(e,d3),mt=new Set(["FunctionDeclaration","ClassDeclaration","TSTypeAliasDeclaration","TSInterfaceDeclaration","TSEnumDeclaration"]),mr=new Set(["AccessorProperty","MethodDefinition","PropertyDefinition","TSAbstractAccessorProperty","TSAbstractMethodDefinition","TSAbstractPropertyDefinition","TSMethodSignature","TSPropertySignature"]),mn=e=>{let t="";return"Variable"===e.type?t=e.node.init.arguments[0].value:"ImportBinding"===e.type&&(t=e.parent.source.value),!t.includes("node_modules")&&(t.startsWith(".")||t.startsWith("/"))},mo="consistent-compound-words/error",ma="consistent-compound-words/rename",{isIdentifierName:mi}=tL,ms={backGround:"background",callBack:"callback",checkBox:"checkbox",clipBoard:"clipboard",codeBase:"codebase",dataBase:"database",downLoad:"download",feedBack:"feedback",foreGround:"foreground",frameWork:"framework",headLine:"headline",keyBoard:"keyboard",keyFrame:"keyframe",lifeCycle:"lifecycle",metaData:"metadata",midPoint:"midpoint",nameSpace:"namespace",overRide:"override",passWord:"password",payLoad:"payload",placeHolder:"placeholder",preView:"preview",screenShot:"screenshot",sideBar:"sidebar",subClass:"subclass",subDirectory:"subdirectory",subDomain:"subdomain",subMenu:"submenu",subProcess:"subprocess",subString:"substring",subTree:"subtree",subType:"subtype",subTitle:"subtitle",timeOut:"timeout",timeStamp:"timestamp",toolBar:"toolbar",toolKit:"toolkit",toolTip:"tooltip",touchScreen:"touchscreen",unSubscribe:"unsubscribe",underScore:"underscore",upLoad:"upload",userName:"username",viewPort:"viewport",webCam:"webcam",webHook:"webhook",webSite:"website",weekEnd:"weekend",whiteSpace:"whitespace",wildCard:"wildcard",workFlow:"workflow",workSpace:"workspace"},ml=new Set(String.raw`\^$.*+?()[]{}|`),mu=e=>{let t="";for(let r of e)t+=ml.has(r)?`\\${r}`:r;return t},mp=String.raw`(?=$|[\d_$]|\p{Uppercase_Letter})`,mc=(e,{replacementRegExp:t,replacements:r,allowList:n})=>{if(!t||e===e.toUpperCase()||n.has(e))return;let o=e.replaceAll(t,e=>((e,t)=>{let r=t.get(e)??t.get(oa(e));if(r){let t;return(t=e[0])===t.toUpperCase()?oo(r):oa(r)}})(e,r));if(o!==e)return o},md=(e,t)=>({node:e,messageId:mo,data:{name:e.name,replacement:t}}),mm={type:"array",additionalItems:!1,items:[{type:"object",additionalProperties:!1,properties:{checkProperties:{type:"boolean",description:"Whether to check property names."},checkVariables:{type:"boolean",description:"Whether to check variable names."},checkDefaultAndNamespaceImports:{anyOf:[{type:"boolean"},{enum:["internal"]}],description:"Whether to check default and namespace import names."},checkShorthandImports:{anyOf:[{type:"boolean"},{enum:["internal"]}],description:"Whether to check shorthand import names."},checkShorthandProperties:{type:"boolean",description:"Whether to check shorthand property names."},extendDefaultReplacements:{type:"boolean",description:"Whether to extend the default replacements."},replacements:{$ref:"#/definitions/replacements",description:"Custom compound word replacements."},allowList:{$ref:"#/definitions/trueObject",description:"Custom allow list of names."}}}],definitions:{replacements:{type:"object",propertyNames:{minLength:1},additionalProperties:{anyOf:[{enum:[!1]},{type:"string",minLength:1}]}},trueObject:{type:"object",propertyNames:{minLength:1},additionalProperties:{enum:[!0]}}}},mf="no-blob-to-file",mg="suggestion";function my(e,t){let r=ei(t.sourceCode.getScope(e),e);return!r||0===r.defs.length}function mh(e,t){if(e?.type!=="Identifier")return;let r=ei(t.sourceCode.getScope(e),e),n=r?.defs[0],o=n?.node;if(n?.type==="Variable"&&"const"===n.kind&&o?.type==="VariableDeclarator")return o}let mx="no-canvas-to-image",mb=e=>{for(;e?.type==="AwaitExpression";)e=e.argument;return e};function mE(e,t){if(e=mb(e),e?.type!=="Identifier")return e;let r=ei(t.getScope(e),e);if(!r||1!==r.identifiers.length||2!==r.references.length)return;let[n]=r.identifiers;if("VariableDeclarator"===n.parent.type&&n.parent.id===n&&"VariableDeclaration"===n.parent.parent.type&&"const"===n.parent.parent.kind&&!(t.getRange(n)[0]>t.getRange(e)[0]))return mb(n.parent.init)}let mD=e=>e.toLowerCase().includes("canvas"),mS="replace-one-element",mv="insert-at-negative-one",mC="suggestion-replace-one-element",mA="suggestion-insert-at-negative-one";function mT(e){return"Identifier"===e.type||"ThisExpression"===e.type||"MemberExpression"===e.type&&!e.computed&&!e.optional&&mT(e.object)}let mw=(e,t)=>t.getCommentsInside(e).length>0,mk="no-duplicate-set-values",mI="first-match",mj="id-selector",mF="length-check",mB="query-selector-all-nullish",mR="query-selector-undefined",m$=e=>td(e,{method:"querySelector",argumentsLength:1,optionalCall:!1,optionalMember:!1})&&!nT(e.callee.object),mP=e=>td(e,{method:"querySelectorAll",argumentsLength:1,optionalCall:!1,optionalMember:!1})&&!nT(e.callee.object),mL=e=>{let t,r;return t=e,r=mP,"MemberExpression"===t.type&&t.computed&&!t.optional&&r(t.object)&&e0(t.property,0)},mN=e=>{let t,r;return t=e,r=mP,td(t,{methods:["at","item"],argumentsLength:1,optionalCall:!1,optionalMember:!1})&&r(t.callee.object)&&e0(t.arguments[0],0)},mM=e=>r3(e)||("ForInStatement"===e.parent.type||"ForOfStatement"===e.parent.type)&&e.parent.left===e,mO=(e,t,r,n)=>{let[,o]=eH(t,n),[,a]=r.getRange(e);return r.getAllComments().some(e=>{let[t,n]=r.getRange(e);return t>=o&&n<=a})},mq=(e,t,r)=>{if("Identifier"!==e.type)return;let n=ei(t.getScope(e),e);if(!n||1!==n.defs.length)return;let[o]=n.defs;if("Variable"===o.type&&"const"===o.parent.kind&&o.node.id===o.name&&r(o.node.init))return o.node.init},mU=(e,t)=>{let{sourceCode:r}=t,{node:n,isNegative:o}=function(e,t){let r=!1;for(;;)if(tS(e))r=!r,e=e.parent;else if(tv(e,t))e=e.parent;else break;return{node:e,isNegative:r}}(e,t);if(!tT(n)||(mP(e)?!e:!mq(e,r,mP)))return;let a=r.getText(e);return{node:e,messageId:mF,fix:((e,t,r)=>{let[n,o]=r.getRange(e),[a,i]=r.getRange(t);return r.getAllComments().some(e=>{let[t,s]=r.getRange(e);return t>=n&&s<=o&&(s<=a||t>=i)})})(n,e,r)?void 0:e=>e.replaceText(n,`${a}.length ${o?"=== 0":"> 0"}`)}},mW=(e,t,r)=>({node:e,messageId:mI,*fix(n){yield n.replaceText(t.callee.property,"querySelector"),yield"MemberExpression"===e.type?oM(n,e,r):oO(n,e,r)}}),m_=(e,t)=>e9(e)||tx(e)&&t.isGlobalReference(e),mV=(e,t,r)=>{let{left:n,operator:o,right:a}=e;return["==","===","!=","!=="].includes(o)?(t(n)?n:mq(n,r,t))&&m_(a,r)?{node:n,value:a}:(t(a)?a:mq(a,r,t))&&m_(n,r)?{node:a,value:n}:void 0:void 0},mz="no-invalid-file-input-accept/invalid",mK="no-invalid-file-input-accept/static",mG="no-invalid-file-input-accept/normalize",mJ=new Set(["audio/*","image/*","video/*"]),mX=new Map([["application/x-rar-compressed","application/vnd.rar"],["application/x-zip-compressed","application/zip"],["image/jpg","image/jpeg"],["image/svg","image/svg+xml"],["image/x-icon","image/vnd.microsoft.icon"]]),mY=/&(?:#\d+|#x[\da-f]+|[a-z][\da-z]*);/iv,mH=e=>{for(let t of e)if(""===t.trim()||","===t||"/"===t||"*"===t||"$"===t||"{"===t||"}"===t)return!0;return!1},mZ=e=>{if(e.startsWith("."))return e.length>1&&!mH(e.slice(1))?{replacement:e.toLowerCase()}:{reason:"File extensions must start with `.` and cannot contain whitespace, commas, slashes, wildcards, or template markers."};if(!e.includes("/"))return e.length>0&&"."!==e[0]&&!mH(e)?{replacement:`.${e.toLowerCase()}`}:{reason:"File extensions must start with `.` and cannot contain whitespace, commas, slashes, wildcards, or template markers."};let t=e.toLowerCase();if(t.includes("*"))return mJ.has(t)?{replacement:t}:{reason:"Wildcard MIME types must be `audio/*`, `image/*`, or `video/*`."};try{let{essence:t}=new m.MIMEType(e);return{replacement:mX.get(t)??t}}catch{return{reason:"MIME types must use valid `type/subtype` syntax."}}},mQ=e=>{if("JSXIdentifier"===e.type)return e.name},m0=(e,t)=>e.attributes.find(e=>"JSXAttribute"===e.type&&mQ(e.name)===t),m1=(e,t)=>{let r=e.sourceCode.getScope(t),n=ew(t,r)?.value;if("string"==typeof n)return n},m2=e=>">"===e||""===e.trim(),m3=(e,t,r)=>{for(;t<r&&""===e[t].trim();)t++;return t},m8=(e,t,r)=>t>=r||">"===e[t]||"/"===e[t]&&">"===e[t+1],m6=(e,t,r)=>{let n=t;for(;t<r&&""!==e[t].trim()&&"="!==e[t]&&">"!==e[t]&&("/"!==e[t]||">"!==e[t+1]);)t++;return{name:e.slice(n,t).toLowerCase(),index:t}},m9=(e,t,r)=>{let n='"'===e[t]||"'"===e[t]?e[t]:void 0;if(n){let o=t+1;for(t=o;t<r&&e[t]!==n;)t++;return{value:e.slice(o,t),valueRange:[o,t],isQuoted:!0,index:t+1}}let o=t;for(;t<r&&!m2(e[t]);)t++;return{value:e.slice(o,t),valueRange:[o,t],isQuoted:!1,index:t}},m5=(e,t,r)=>{let n=e.sourceCode.text,o=e.sourceCode.getRange(t.openStart)[1],a=e.sourceCode.getRange(t.openEnd)[1],i=o;for(;i<a&&(i=m3(n,i,a),!m8(n,i,a));){let e=m6(n,i,a);if(i=m3(n,e.index,a),"="!==n[i]){if(e.name===r)return{missing:!0};continue}i=m3(n,++i,a);let t=m9(n,i,a);if(i=t.index,e.name===r)return t}},m4=({valueInfo:e,fix:t})=>{if(e.missing)return{node:e.node,messageId:mz,data:{reason:"The `accept` attribute must have a value."}};if(e.dynamic)return{node:e.node,messageId:mK};let r=(e=>{let t=e.split(","),r=new Set,n=[];for(let e of t){let t=e.trim();if(0===t.length)return{reason:"Empty entries are not allowed."};let o=mZ(t);if(o.reason)return o;let{replacement:a}=o;r.has(a)||(r.add(a),n.push(a))}let o=n.join(", ");return o===e?{}:{replacement:o}})(e.value),n=r.replacement&&e.fixable&&(!e.isReplacementFixable||e.isReplacementFixable(r.replacement));return(({valueNode:e,checkResult:t,fix:r})=>{if(t.reason)return{node:e,messageId:mz,data:{reason:t.reason}};if(t.replacement){let n={node:e,messageId:mG,data:{replacement:t.replacement}};return r&&(n.fix=r),n}})({valueNode:e.node,checkResult:r,fix:n?t(r.replacement):void 0})},m7="after-suspension",fe="in-nested-function",ft=/^(?:e|event|evt|[a-z][\dA-Za-z]*Event)$/u,fr=e=>{for(let t=e.parent;t;t=t.parent)if(tl(t))return t},fn="no-unnecessary-nested-ternary";function fo(e,t,r){return r.getText(e)===r.getText(t)}function fa(e,t,r,n){let o=eZ(e,t);return!eQ(e,t)&&n6(e,{operator:r,property:n})&&(o=`(${o})`),o}function fi(e,t){let r=eZ(e,t);return!eQ(e,t)&&nQ(e)&&(r=`(${r})`),r}function fs(e,t,r){let n={node:t,messageId:fn};return 0===e.sourceCode.getCommentsInside(t).length&&(n.fix=n=>n.replaceText(t,function({context:e,node:t,left:r,operator:n,right:o,consequent:a,alternate:i}){let{sourceCode:s}=e,l=[fa(r,e,n,"left"),fa(o,e,n,"right")].join(` ${n} `),u=`${l} ? ${fi(a,e)} : ${fi(i,e)}`;return nW(s.getTokenBefore(t),e,u)&&(u=`;${u}`),u}({context:e,node:t,...r}))),n}let fl="no-unused-array-method-return",fu=new Set(["at","concat","entries","every","filter","find","findIndex","findLast","findLastIndex","flat","flatMap","includes","indexOf","join","keys","lastIndexOf","map","some","slice","toReversed","toSorted","toSpliced","values","with"]),fp=/^\p{Uppercase_Letter}/v,fc=Symbol("uncertainValue"),fd=new Set(["BigInt","Boolean","Number","RegExp","String"]),fm=(e,t,r)=>"Identifier"===e.type&&e.name===t&&r.sourceCode.isGlobalReference(e),ff="prefer-array-last-methods",fg="replace",fy=new Map([["find","findLast"],["findIndex","findLastIndex"],["indexOf","lastIndexOf"],["reduce","reduceRight"]]),fh=["reverse","toReversed"],fx="prefer-math-abs",fb=new Set([">",">=","<","<="]),fE={">":"<",">=":"<=","<":">","<=":">="},fD={">":"<",">=":"<="};function fS(e){return"TSBigIntKeyword"===e.type||"TSLiteralType"===e.type&&e5(e.literal)||"TSTypeAnnotation"===e.type&&fS(e.typeAnnotation)||"TSUnionType"===e.type&&e.types.some(e=>fS(e))||"TSIntersectionType"===e.type&&e.types.some(e=>fS(e))}function fv(e){return["TSAsExpression","TSTypeAssertion","TSNonNullExpression"].includes(e.type)?fv(e.expression):e}function fC(e){let t;return e5(e)||e7(e,{name:"BigInt",argumentsLength:1,optional:!1})||"UnaryExpression"===e.type&&"-"===e.operator&&fC(e.argument)||(t=function e(t){return"TSNonNullExpression"===t.type?e(t.expression):"TSAsExpression"===t.type||"TSTypeAssertion"===t.type?t.typeAnnotation:void 0}(e))&&fS(t)}function fA(e,t){return fC(e)||function(e,t){let r=fv(e);if("Identifier"!==r.type)return!1;let n=ei(t.sourceCode.getScope(r),r);return n?.defs.some(e=>"Parameter"===e.type?e.name.typeAnnotation&&fS(e.name.typeAnnotation)||"AssignmentPattern"===e.name.parent.type&&fC(e.name.parent.right):"Variable"===e.type&&(e.node.id.typeAnnotation&&fS(e.node.id.typeAnnotation)||e.node.init&&fC(e.node.init)))??!1}(e,t)}function fT(e,t){return"UnaryExpression"===e.type&&"-"===e.operator?tQ(e.argument,t):"BinaryExpression"===e.type&&"-"===e.operator&&e0(e.left,0)?tQ(e.right,t):"BinaryExpression"===e.type&&"*"===e.operator&&(tQ(e.left,t)&&tm(e.right)||tm(e.left)&&tQ(e.right,t))}function fw(e,t){if(!("BinaryExpression"!==e.type||!fb.has(e.operator)||fA(e.left,t)||fA(e.right,t)))return">"===e.operator||">="===e.operator?{value:e.left,threshold:e.right,operator:e.operator}:{value:e.right,threshold:e.left,operator:fE[e.operator]}}function fk(e,t){if(!("BinaryExpression"!==e.type||!fb.has(e.operator)||fA(e.left,t)||fA(e.right,t)))return"<"===e.operator||"<="===e.operator?{value:e.left,negativeThreshold:e.right,operator:e.operator}:{value:e.right,negativeThreshold:e.left,operator:fE[e.operator]}}function fI(e,t){let r=eZ(e,t);return"SequenceExpression"===e.type?`(${r})`:r}function fj(e,t,r){let n={node:e,messageId:fx};return r&&!(t.sourceCode.getCommentsInside(e).length>0)&&(n.fix=r),n}function fF(e){return["Identifier","Literal","ThisExpression"].includes((e=fv(e)).type)}let fB="prefer-split-limit",fR=(e,t)=>{let r=ew(e,t.getScope(e));if(r&&Number.isSafeInteger(r.value)&&!(r.value<0))return r.value},f$=e=>{let t;return td(e,{method:"split",argumentsLength:1})&&(e1(t=e.arguments[0])&&""!==t.value||e6(t))},fP=(e,t,r,n)=>({node:e,messageId:fB,fix:e=>ow(e,t,String(r+1),n)}),fL="prefer-queue-microtask",fN={create:e=>{let{checkSetImmediate:t,checkSetTimeout:r}=e.options[0];e.on("MemberExpression",t=>{if(tc(t,{object:"process",property:"nextTick",computed:!1,optional:!1})&&nR(t.object,e)&&("CallExpression"!==t.parent.type||t.parent.callee!==t||!t.parent.optional))return{node:t.property,messageId:fL,data:{name:"process.nextTick()"},fix:((e,t)=>{let{parent:r}=e;if("CallExpression"===r.type&&r.callee===e&&1===r.arguments.length&&"SpreadElement"!==r.arguments[0].type&&!(t.sourceCode.getCommentsInside(e).length>0))return t=>t.replaceText(e,"queueMicrotask")})(t,e)}}),e.on("CallExpression",n=>{let o;return t&&"Identifier"===n.callee.type&&"setImmediate"===n.callee.name&&!n.optional&&n.arguments.length>0&&"SpreadElement"!==n.arguments[0].type&&!nI(n.arguments[0])&&nO(n)&&nR(n.callee,e)?{node:n.callee,messageId:fL,data:{name:"setImmediate()"},fix:(e=>{if(1===e.arguments.length)return t=>t.replaceText(e.callee,"queueMicrotask")})(n)}:r&&"Identifier"===n.callee.type&&"setTimeout"===n.callee.name&&!n.optional&&n.arguments.length>=2&&"Literal"===(o=n.arguments[1]).type&&0===o.value&&"SpreadElement"!==n.arguments[0].type&&!nI(n.arguments[0])&&nO(n)&&nR(n.callee,e)?{node:n.callee,messageId:fL,data:{name:"setTimeout()"},fix:((e,t)=>{if(2!==e.arguments.length)return;let r=((e,t)=>{let{sourceCode:r}=t,[,n]=e.arguments,o=r.getTokenBefore(n),a=r.getTokenAfter(n),i=a?.value===","?r.getTokenAfter(a):a,s=[r.getRange(o)[0],a?.value===","?r.getRange(a)[1]:r.getRange(n)[1]];if(!re(t,[s[0],r.getRange(i)[0]]))return s})(e,t);if(r)return function*(t){yield t.replaceText(e.callee,"queueMicrotask"),yield t.removeRange(r)}})(n,e)}:void 0})},meta:{type:"suggestion",docs:{description:"Prefer `queueMicrotask()` over `process.nextTick()`, `setImmediate()`, and `setTimeout(…, 0)`.",recommended:"unopinionated"},fixable:"code",schema:[{type:"object",additionalProperties:!1,properties:{checkSetImmediate:{type:"boolean",description:"Whether to also check `setImmediate()`."},checkSetTimeout:{type:"boolean",description:"Whether to also check `setTimeout(…, 0)`."}}}],defaultOptions:[{checkSetImmediate:!1,checkSetTimeout:!1}],messages:{[fL]:"Prefer `queueMicrotask()` over `{{name}}`."},languages:["js/js"]}},fM="prefer-string-pad-start-end",fO="suggest-padding-method",fq=new Set(["ArrayExpression","ArrowFunctionExpression","ClassExpression","FunctionExpression","ObjectExpression"]),fU=(e,t)=>{let r,n=((e,t)=>{if("Identifier"!==e.type)return;let r=ei(t.sourceCode.getScope(e),e),n=r?.defs[0]?.node;return n?.type==="FunctionDeclaration"||n?.type==="ClassDeclaration"?n:n?.type==="VariableDeclarator"?n.init:void 0})(e,t);return(r=ew(e,t.sourceCode.getScope(e)))&&"string"!=typeof r.value||fq.has(e.type)||fq.has(n?.type)||n?.type==="FunctionDeclaration"||n?.type==="ClassDeclaration"},fW=(e,t)=>t.sourceCode.getCommentsInside(e).length>0,f_=e=>"Literal"===e.type&&"number"==typeof e.value,fV=e=>"Literal"===e.type&&"string"==typeof e.value||"TemplateLiteral"===e.type&&0===e.expressions.length,fz=({targetNode:e,targetLengthNode:t,paddingNode:r})=>"Identifier"===e.type&&f_(t)&&fV(r),fK=(e,t)=>{if(!td(e,{method:"repeat",argumentsLength:1,optionalCall:!1,optionalMember:!1}))return;let r=e.callee.object,n=((e,t)=>{let r=ew(e,t.sourceCode.getScope(e));if("string"==typeof r?.value)return r.value})(r,t);if(n?.length===1)return{paddingNode:r,paddingString:n,widthNode:e.arguments[0]}},fG=(e,t)=>{let r,n=fK(e,t);if(!n)return;let{widthNode:o}=n;if("BinaryExpression"===o.type&&"-"===o.operator&&(r=o.right,r?.type==="MemberExpression"&&!1===r.computed&&"Identifier"===r.property.type&&"length"===r.property.name))return{...n,targetLengthNode:o.left,targetNode:o.right.object}},fJ=({method:e,targetNode:t,targetLengthNode:r,paddingNode:n,paddingString:o},a)=>{let i=eZ(t,a),s=eZ(r,a),l=(({paddingNode:e,paddingString:t},r)=>" "===t?"":`, ${eZ(e,r)}`)({paddingNode:n,paddingString:o},a);return`${i}.${e}(${s}${l})`},fX=({node:e,method:t,replacement:r,context:n,canFix:o})=>{let a={node:e,messageId:fM,data:{method:t}};return o&&!fW(e,n)&&(a.fix=function(t){let o=nW(n.sourceCode.getTokenBefore(e),n,r)?";":"";return t.replaceText(e,`${o}${r}`)}),a},fY=({node:e,method:t,replacement:r,context:n,canSuggest:o})=>{let a={node:e,messageId:fM,data:{method:t}};return o&&!fW(e,n)&&(a.suggest=[{messageId:fO,data:{method:t},fix:t=>t.replaceText(e,r)}]),a},fH="require-css-escape",fZ=["closest","matches","querySelector","querySelectorAll"],fQ=e=>e.value.cooked,f0=(e,t)=>{let r,n="";for(let r of e.quasis.slice(0,t+1)){let e=fQ(r);if(void 0===e)return!1;n+=e}if(!((r=n).lastIndexOf("[")>r.lastIndexOf("]")))return!1;for(let r of e.quasis.slice(t+1)){let e=fQ(r);if(void 0===e)break;if(e.includes("]"))return!0}return!1},f1=e=>td(e,{object:"CSS",method:"escape",argumentsLength:1,optionalCall:!1,optionalMember:!1}),f2=e=>t=>"SequenceExpression"===e.type?[t.insertTextBefore(e,"CSS.escape(("),t.insertTextAfter(e,"))")]:[t.insertTextBefore(e,"CSS.escape("),t.insertTextAfter(e,")")],f3={create:e=>{let{checkAllSelectors:t}=e.options[0];e.on("CallExpression",function*(e){if(!td(e,{methods:fZ,minimumArguments:1})||nT(e.callee.object))return;let[r]=e.arguments;if("TemplateLiteral"===r.type&&0!==r.expressions.length)for(let[e,n]of r.expressions.entries())!f1(n)&&(t||f0(r,e))&&(yield{node:n,messageId:fH,fix:f2(n)})})},meta:{type:"suggestion",docs:{description:"Require `CSS.escape()` for interpolated values in CSS selectors.",recommended:"unopinionated"},fixable:"code",schema:[{type:"object",additionalProperties:!1,properties:{checkAllSelectors:{type:"boolean",description:"Check all selector interpolations instead of only attribute selector interpolations."}}}],defaultOptions:[{checkAllSelectors:!1}],messages:{[fH]:"Use `CSS.escape()` for interpolated values in CSS selectors."},languages:["js/js"]}},f8="require-passive-events",f6=new Set(["touchstart","touchmove","touchenter","touchend","touchleave","wheel","mousewheel"]),f9=e=>e.computed||"Identifier"!==e.property.type?e1(e.property)?e.property.value:void 0:e.property.name,f5=e=>{var t,r;return"MemberExpression"===e.parent.type&&e.parent.object===e&&"MemberExpression"===(t=e.parent).type&&"preventDefault"===f9(t)&&("CallExpression"===(r=t).parent.type&&r.parent.callee===r?r.parent:"ChainExpression"===r.parent.type&&"CallExpression"===r.parent.parent.type&&r.parent.parent.callee===r.parent?r.parent.parent:void 0)},f4=e=>{if("MemberExpression"!==e.parent.type||e.parent.object!==e)return!1;let t=f9(e.parent);return t&&"preventDefault"!==t&&!r3((e=>{for(;"MemberExpression"===e.parent.type&&e.parent.object===e;)e=e.parent;return e})(e.parent))},f7="this",ge="class",gt="class-unavailable",gr="super",gn="super-class",go="super-class-unavailable",ga="suggestion",gi=new Set(["PropertyDefinition","AccessorProperty","StaticBlock","ClassBody"]),gs=new Set(["TSAsExpression","TSInstantiationExpression","TSNonNullExpression","TSSatisfiesExpression","TSTypeAssertion"]),gl=e=>"MethodDefinition"===e.parent.type&&e.parent.value===e,gu=e=>"FunctionDeclaration"===e.type||"FunctionExpression"===e.type,gp=e=>{let t=e;for(let{parent:r}=e;r;t=r,r=r.parent)if("ArrowFunctionExpression"!==r.type){if(gu(r)&&!gl(r))return;if("MethodDefinition"===r.type)return r.static&&r.value===t?r:void 0;if(gi.has(r.type))return}},gc=e=>{if(e.id)return e.id;let{parent:t}=e;if("ClassExpression"===e.type&&"VariableDeclarator"===t.type&&t.init===e&&"Identifier"===t.id.type)return t.id},gd=(e,t,r)=>ei(e.getScope(t),t)===ei(e.getScope(r),r),gm=(e,t,r)=>ei(e.getScope(t),r.name)===ei(e.getScope(r),r),gf=(e,t)=>"AssignmentExpression"===e.type&&e.left===t||"UpdateExpression"===e.type&&e.argument===t||"UnaryExpression"===e.type&&"delete"===e.operator&&e.argument===t||("ForInStatement"===e.type||"ForOfStatement"===e.type)&&e.left===t,gg=e=>{let t;return(t=e.parent,gs.has(t.type)&&t.expression===e)?e.parent:void 0},gy=e=>{let{parent:t}=e;if("MemberExpression"===t.type&&t.object===e||"ChainExpression"===t.type&&t.expression===e)return t;let r=gg(e);return r||("Property"===t.type&&t.value===e&&"ObjectPattern"===t.parent.type?t.parent:"ObjectPattern"===t.type&&t.properties.includes(e)||"ArrayPattern"===t.type&&t.elements.includes(e)||"AssignmentPattern"===t.type&&t.left===e||"RestElement"===t.type&&t.argument===e?t:void 0)},gh=e=>{let t=e;for(;t.parent;){if(gf(t.parent,t))return!0;let e=gy(t);if(!e)break;t=e}return!1},gx=e=>"MemberExpression"===e.parent.type&&e.parent.object===e,gb=e=>{let t=e;for(;t.parent;){let e=gg(t);if(!e)break;t=e}return t},gE=e=>{let t=gb(e);return"CallExpression"===t.parent.type&&t.parent.callee===t||"NewExpression"===t.parent.type&&t.parent.callee===t||"TaggedTemplateExpression"===t.parent.type&&t.parent.tag===t},gD=e=>{let t=gb(e);return gx(t)&&"PrivateIdentifier"===t.parent.property.type},gS=e=>{let t=gb(e);return"BinaryExpression"===t.parent.type&&"in"===t.parent.operator&&"PrivateIdentifier"===t.parent.left.type&&t.parent.right===t},gv=e=>e.superClass?.type==="Identifier"?e.superClass:void 0,gC=({node:e,messageId:t,source:r,replacement:n,name:o})=>({node:e,messageId:t,data:{name:o},suggest:[{messageId:ga,data:{source:r,replacement:n},fix:t=>t.replaceText("ChainExpression"===e.parent.type?e.parent:e,n)}]}),gA=(e,t,r)=>({node:e,messageId:t,data:{name:r}}),gT={create:e=>{let{sourceCode:t}=e,{preferThis:r,preferSuper:n}=e.options[0];e.on("ThisExpression",e=>{if(r||gh(e)||gE(e)||gD(e)||gS(e))return;let n=gp(e);if(!n)return;let o=gc(n.parent.parent);return o&&gm(t,e,o)?gC({node:e,messageId:ge,source:"this",replacement:o.name,name:o.name}):gA(e,gt)}),e.on("Super",e=>{if(n||gh(e))return;let r=gp(e);if(!r)return;let o=gv(r.parent.parent);return o&&gm(t,e,o)?gC({node:e,messageId:gn,source:"super",replacement:o.name,name:o.name}):gA(e,go)}),e.on("Identifier",o=>{if(!function(e,t=[]){if("Identifier"!==e.type)return!1;let r=Array.isArray(t)?t:[t];return(!(r.length>0)||!!r.includes(e.name))&&!function(e){let{parent:t}=e;switch(t.type){case"MemberExpression":return!t.computed&&t.property===e;case"FunctionDeclaration":case"FunctionExpression":return t.params.includes(e)||t.id===e;case"ArrowFunctionExpression":return t.params.includes(e);case"ClassDeclaration":case"ClassExpression":case"VariableDeclarator":case"TSDeclareFunction":case"TSEnumMember":case"TSTypeAliasDeclaration":return t.id===e;case"PropertyDefinition":case"MethodDefinition":return!t.computed&&t.key===e;case"Property":return!t.computed&&t.key===e&&("ObjectExpression"===t.parent.type||"ObjectPattern"===t.parent.type)&&t.parent.properties.includes(t)||t.value===e&&"ObjectPattern"===t.parent.type&&t.parent.properties.includes(t);case"ArrayPattern":return t.elements.includes(e);case"LabeledStatement":case"ContinueStatement":case"BreakStatement":return t.label===e;case"ImportDefaultSpecifier":case"ImportNamespaceSpecifier":return t.local===e;case"ExportAllDeclaration":return t.exported===e;case"ImportSpecifier":return t.local===e||t.imported===e;case"ExportSpecifier":return t.local===e||t.exported===e;case"TSIndexSignature":return t.parameters.includes(e);case"TSTypeParameter":return t.name===e;case"TSMappedType":case"TSPropertySignature":return t.key===e}return!1}(e)}(o)||(e=>{let t=e;for(;"TSQualifiedName"===t.parent.type;)t=t.parent;return"TSTypeReference"===t.parent.type&&t.parent.typeName===t||"TSTypeQuery"===t.parent.type&&t.parent.exprName===t})(o)||gh(o)||gE(o)||gD(o)||gS(o))return;let a=gp(o);if(!a)return;let i=a.parent.parent;if(r){let e=gc(i);if(e&&o.name===e.name&&gd(t,o,e))return gC({node:o,messageId:f7,source:o.name,replacement:"this",name:o.name})}if(!n||!(gx(o)&&!o.parent.optional&&!gh(o.parent))||eQ(o,e))return;let s=gv(i);if(s&&o.name===s.name&&gd(t,o,s))return gC({node:o,messageId:gr,source:o.name,replacement:"super",name:o.name})})},meta:{type:"suggestion",docs:{description:"Enforce consistent class references in static methods.",recommended:!0},hasSuggestions:!0,schema:[{type:"object",properties:{preferThis:{type:"boolean",description:"Prefer `this` over the current class name in static methods."},preferSuper:{type:"boolean",description:"Prefer `super` over the superclass name in static methods."}},additionalProperties:!1}],defaultOptions:[{preferThis:!0,preferSuper:!0}],messages:{[f7]:"Use `this` instead of `{{name}}` in static methods.",[ge]:"Use `{{name}}` instead of `this` in static methods.",[gt]:"Use the class name instead of `this` in static methods.",[gr]:"Use `super` instead of `{{name}}` in static methods.",[gn]:"Use `{{name}}` instead of `super` in static methods.",[go]:"Use the superclass name instead of `super` in static methods.",[ga]:"Replace `{{source}}` with `{{replacement}}`."},languages:["js/js"]}},gw="consistent-optional-chaining/remove-optional",gk="consistent-optional-chaining/use-optional",gI="consistent-optional-chaining/suggest-remove-optional",gj="consistent-optional-chaining/suggest-use-optional",gF=new Set(["Identifier","ThisExpression","Super"]);function gB(e){let t;for(;e!==t;)t=e,"ChainExpression"===(e=ry(e)).type&&(e=e.expression);return e}function gR(e){return"MemberExpression"===(e=gB(e)).type?e:void 0}function g$(e){return e=gB(e),!!gF.has(e.type)||"MemberExpression"===e.type&&g$(e.object)}function gP(e,t){let r=ri(e,t);return!re(t,r)}function gL({memberExpression:e,context:t,fixer:r,replacement:n}){let o=ri(e,t);return r.replaceTextRange(o,n)}function gN(e,t,r){return gL({memberExpression:e,context:t,fixer:r,replacement:e.computed?"[":"."})}let gM="always",gO="never",gq="missing-delay",gU="redundant-delay",gW=new Set(["setTimeout","setInterval"]),g_=new Set(["window","globalThis","global","self"]),gV=e=>e0(e,0)||"UnaryExpression"===e.type&&("+"===e.operator||"-"===e.operator)&&gV(e.argument),gz="negative-index",gK="length-index",gG=["entries","keys","values"],gJ=["drop","filter","flatMap","map","take"],gX=["concat","from","zip","zipKeyed"],gY=e=>{for(;rg(e)||"ChainExpression"===e.type||"ParenthesizedExpression"===e.type;)e=e.expression;return e},gH="no-duplicate-loops",gZ=["filter","map"],gQ="no-declarations-before-early-exit",g0=e=>"VariableDeclaration"===e.type&&("let"===e.kind||"const"===e.kind),g1=e=>"use"===e||/^use[\dA-Z]/.test(e),g2=e=>!e||"Literal"===e.type||"TemplateLiteral"===e.type&&0===e.expressions.length,g3=(e,t,r)=>{let n="before"===r?e.getTokenBefore(t,{includeComments:!0}):e.getTokenAfter(t,{includeComments:!0});return n&&eg(n)},g8=(e,t)=>{let[r,n]=e.getRange(t);return new Set(tO(e.getScope(t)).filter(({identifier:t})=>{let[o,a]=e.getRange(t);return o>=r&&a<=n}).map(({identifier:e})=>e.name))};function*g6(e,t,r){let n;for(let[o,a]of t.entries())if(g0(a)&&!a.declare){n??=t.map(e=>{var t,n;return(t=e,n=r,"IfStatement"!==t.type||n(t.consequent)===(!!t.alternate&&n(t.alternate)))?void 0:e});for(let r=o+1;r<t.length;r++){let t=n[r];if(t){for(let n of a.declarations){let i=function({sourceCode:e,declaration:t,declarator:r,guardStatement:n,declarationIndex:o,guardIndex:a}){var i;let s;if("Identifier"!==r.id.type||(e=>{if(e?.type!=="CallExpression")return!1;let{callee:t}=e;return"Identifier"===t.type?g1(t.name):"MemberExpression"===t.type&&!t.computed&&"Identifier"===t.object.type&&/^[A-Z]/.test(t.object.name)&&"Identifier"===t.property.type&&g1(t.property.name)})(r.init)||r.init&&tk(r.init,e.visitorKeys)||a>o+1&&!g2(r.init)||r.init&&(i=r.init,s=g8(e,n),[...g8(e,i)].some(e=>s.has(e)))&&(eP(r.init,e)||eP(n.test,e)))return;let[l]=e.getDeclaredVariables(r),u=l.references.filter(e=>!e.init&&!function(e){let t=e;for(;"TSQualifiedName"===t.parent.type;)t=t.parent;return"TSTypeQuery"===t.parent.type}(e.identifier));if(0===u.length)return;let[,p]=e.getRange(n);if(u.some(t=>e.getRange(t.identifier)[0]<p))return;let c={node:r.id,messageId:gQ};return(({sourceCode:e,declaration:t,guardStatement:r,declarationIndex:n,guardIndex:o})=>o===n+1&&1===t.declarations.length&&g2(t.declarations[0].init)&&0===e.getCommentsInside(t).length&&!g3(e,t,"before")&&!g3(e,r,"after")&&!e.getTokensBetween(t,r,{includeComments:!0}).some(e=>eg(e)))({sourceCode:e,declaration:t,guardStatement:n,declarationIndex:o,guardIndex:a})&&(c.fix=function(e,t,r){let n=e.getText(t),o=e.getText(r),[a,i]=e.getRange(t),[s,l]=e.getRange(r),u=e.text.slice(i,s);return e=>e.replaceTextRange([a,l],`${o}${u}${n}`)}(e,t,n)),c}({sourceCode:e,declaration:a,declarator:n,guardStatement:t,declarationIndex:o,guardIndex:r});i&&(yield i)}break}}}}let g9="no-optional-chaining-on-undeclared-variable",g5=e=>"Type"===e.type||"ImportBinding"===e.type&&n_(e.node);function g4(e){let t;for(;e!==t;)t=e,("ChainExpression"===(e=ry(e)).type||"TSInstantiationExpression"===e.type)&&(e=e.expression);return e}let g7="no-object-methods-with-collections/error",ye="no-object-methods-with-collections/suggestion",yt=new Set(["Map","ReadonlyMap"]),yr=new Set(["Set","ReadonlySet"]),yn=new Set([...yt,...yr]),yo=new Set(["entries","keys","values"]),ya=e=>new Set([e]),yi=e=>yn.has(e)?e:void 0,ys=new Set(["ClassDeclaration","TSEnumDeclaration","TSInterfaceDeclaration","TSTypeAliasDeclaration"]),yl=e=>{if(e&&ys.has(e.type))return e.id?.name},yu=(e,t)=>{let r=(e=>{for(;e.parent;)e=e.parent;return"Program"===e.type?e:void 0})(t);if(!r)return!1;for(let t of r.body){if("ImportDeclaration"===t.type){if(t.specifiers.some(t=>t.local.name===e))return!0;continue}if("ExportNamedDeclaration"===t.type||"ExportDefaultDeclaration"===t.type){if(yl(t.declaration)===e)return!0;continue}if(yl(t)===e)return!0}return!1},yp=e=>{let t=new Set;for(let r of e){if(!r)return;for(let e of r)t.add(e)}return t},yc=(e,t)=>{let r=ei(t.sourceCode.getScope(e),e);return!r||"global"===r.scope.type&&0===r.defs.length},yd=(e,t)=>{if(rD.has(e.intrinsicName))return;if(e.isUnion())return yp(e.types.map(e=>yd(e,t)));let r=rv(e);if(!(r?.declarations?.length>0&&r.declarations.every(e=>t.isSourceFileDefaultLibrary(e.getSourceFile()))))return;let n=r.getName(),o=n&&yi(n);return o&&ya(o)},ym=(e,t)=>{switch(e?.type){case"TSTypeAnnotation":case"TSParenthesizedType":return ym(e.typeAnnotation);case"TSTypeOperator":return"readonly"===e.operator?ym(e.typeAnnotation):void 0;case"TSTypeReference":{if("Identifier"!==e.typeName.type||yu(e.typeName.name,e))return;let t=yi(e.typeName.name);return t&&ya(t)}case"TSUnionType":return yp(e.types.map(e=>ym(e)))}},yf=(e,t,r=new Set)=>((e,t)=>{let{parserServices:r}=t.sourceCode;if(r?.program)try{let{program:t}=r,n=yd(r.getTypeAtLocation(e),t);if(n&&!((e,t)=>{for(let r of e)if(yu(r,t))return!0;return!1})(n,e))return n}catch{}})(e,t)??((e,t,r)=>{if(te(e,{names:["Map","Set"]})&&yc(e.callee,t))return ya(e.callee.name);switch(e.type){case"Identifier":return((e,t,r)=>{let n=ei(t.sourceCode.getScope(e),e);if(!n||r.has(n)||1!==n.defs.length)return;r.add(n);let[o]=n.defs,a=ym(o.name?.typeAnnotation);return a||("Variable"===o.type&&"const"===o.parent.kind&&o.node.init?yf(o.node.init,t,r):void 0)})(e,t,r);case"TSAsExpression":case"TSSatisfiesExpression":case"TSTypeAssertion":return ym(e.typeAnnotation)??yf(e.expression,t,r);case"TSNonNullExpression":case"ParenthesizedExpression":return yf(e.expression,t,r)}})(e,t,r),yg="no-subtraction-comparison/error",yy="no-subtraction-comparison/suggestion",yh={">":"<",">=":"<=","<":">","<=":">=","===":"===","!==":"!==","==":"==","!=":"!="},yx=new Set(Object.keys(yh)),yb=new Set([">","<"]),yE=e=>"BinaryExpression"===e.type&&"-"===e.operator,yD=(e,t)=>{let r=ew(e,t)?.value;return"number"==typeof r&&Number.isFinite(r)},yS="no-unnecessary-global-this",yv=new Set(["TSAsExpression","TSInstantiationExpression","TSNonNullExpression","TSSatisfiesExpression","TSTypeAssertion"]),yC=e=>{for(;yv.has(e.parent.type)&&e.parent.expression===e;)e=e.parent;return e};function yA(e){return"CallExpression"===(e=yC(e)).parent.type&&e.parent.callee===e}let yT="computed-key",yw="nested-array",yk="deep-object",yI="property-assignment";function yj(e){let{parent:t}=e;if(t){if(rg(t)&&t.expression===e||"AssignmentPattern"===t.type&&t.left===e||"RestElement"===t.type&&t.argument===e)return yj(t);if("Property"===t.type&&t.value===e&&"ObjectPattern"===t.parent.type)return t.parent;if("ObjectPattern"===t.type||"ArrayPattern"===t.type)return t}}function yF(e){let t=0;for(;e;)"ObjectPattern"===e.type&&t++,e=yj(e);return t}let yB="no-useless-else",yR=new Set(["Program","BlockStatement","StaticBlock","SwitchCase"]),y$=new Set(["[","(","/","`","+","-"]),yP=(e,t)=>{let r=e.text.lastIndexOf("\n",t-1)+1;return/^[\t ]*/.exec(e.text.slice(r,t))[0]},yL=e=>y$.has(e.value[0]),yN="no-useless-recursion",yM=new Set(["using","await using"]),yO=e=>e?.type==="VariableDeclaration"&&yM.has(e.kind),yq=e=>"ForStatement"===e.type?yO(e.init):"ForOfStatement"===e.type&&yO(e.left),yU="prefer-add-event-listener-options",yW="prefer-direct-iteration",y_="Array",yV="FormData",yz="URLSearchParams",yK=new Set([y_,"Map","Set",yV,yz,...rE]),yG=new Map([["ReadonlyArray",y_],["ReadonlyMap","Map"],["ReadonlySet","Set"]]),yJ=new Map([[y_,["values"]],["Map",["entries"]],["Set",["values","keys"]],[yV,["entries"]],[yz,["entries"]],...rE.map(e=>[e,["values"]])]),yX=["Map","WeakMap","Set","WeakSet"],yY=["all","allSettled","any","race"],yH=new Set(["ArrayExpression","CallExpression","NewExpression"]),yZ=e=>new Set([e]),yQ=(e,t)=>td(e,{objects:rE,methods:t,optionalCall:!1,optionalMember:!1}),y0=e=>yK.has(e)?e:yG.get(e),y1=e=>{let t=new Set;for(let r of e){if(!r)return;for(let e of r)t.add(e)}return t},y2=(e,t,r)=>{if("any"===e.intrinsicName||"unknown"===e.intrinsicName)return;if(e.isUnion())return y1(e.types.map(e=>y2(e,t,r)));if(t.isArrayType(e)||t.isTupleType(e))return yZ(y_);let n=rv(e);if(!rC(n,r))return;let o=n.getName(),a=o&&y0(o);return a&&yZ(a)},y3=e=>{switch(e?.type){case"TSTypeAnnotation":case"TSParenthesizedType":return y3(e.typeAnnotation);case"TSArrayType":case"TSTupleType":return yZ(y_);case"TSTypeOperator":return"readonly"===e.operator?y3(e.typeAnnotation):void 0;case"TSTypeReference":{if("Identifier"!==e.typeName.type)return;let t=y0(e.typeName.name);return t&&yZ(t)}case"TSUnionType":return y1(e.types.map(e=>y3(e)))}},y8=(e,t,r=new Set)=>((e,t,r)=>{if("ArrayExpression"===e.type||te(e,{name:"Array"}))return yZ(y_);if(te(e,{names:rE})||te(e,{names:["Map","Set",yV,yz]}))return yZ(e.callee.name);if(e7(e,{name:"Array"})||td(e,{object:"Array",methods:["from","of"],optionalCall:!1,optionalMember:!1}))return yZ(y_);if(yQ(e,["from","of"]))return yZ(e.callee.object.name);switch(e.type){case"Identifier":return((e,t,r)=>{let n=ei(t.sourceCode.getScope(e),e);if(!n||r.has(n)||1!==n.defs.length)return;r.add(n);let[o]=n.defs,a=y3(o.name?.typeAnnotation);return a||("Variable"===o.type&&"const"===o.parent.kind&&o.node.init?y8(o.node.init,t,r):void 0)})(e,t,r);case"TSAsExpression":case"TSSatisfiesExpression":case"TSTypeAssertion":return y3(e.typeAnnotation)??y8(e.expression,t,r);case"TSNonNullExpression":case"ParenthesizedExpression":return y8(e.expression,t,r)}})(e,t,r)??((e,t)=>{let{parserServices:r}=t.sourceCode;if(r?.program)try{let{program:t}=r;return y2(r.getTypeAtLocation(e),t.getTypeChecker(),t)}catch{}})(e,t),y6="prefer-number-is-safe-integer/error",y9="prefer-number-is-safe-integer/suggestion",y5="prefer-number-is-safe-integer/integer-check-error",y4="prefer-number-is-safe-integer/integer-check-suggestion",y7=["_","lodash","underscore"],he=["floor","trunc"],ht=(e,t)=>{let r=ei(t.getScope(e),"Number");return!r||"global"===r.scope.type&&0===r.defs.length},hr=e=>{if("BinaryExpression"===e.type&&"%"===e.operator&&e0(e.right,1))return e.left},hn=(e,t)=>{if(td(e,{object:"Math",methods:he,argumentsLength:1,optionalCall:!1,optionalMember:!1,computed:!1})&&t.isGlobalReference(e.callee.object))return e.arguments[0]},{isIdentifierName:ho}=tL,ha="prefer-object-define-properties";function hi(e){if(e?.type!=="ExpressionStatement")return;let{expression:t}=e;if(td(t,{object:"Object",method:"defineProperty",argumentsLength:3,optionalCall:!1,optionalMember:!1,computed:!1}))return t}let hs="prefer-object-destructuring-defaults",hl="prefer-object-destructuring-defaults/suggestion",hu=new Set(Object.getOwnPropertyNames(Object.prototype)),hp={considerGetters:!0,considerImplicitTypeConversion:!0},hc=e=>"Property"===e.type&&"init"===e.kind&&!e.computed&&!e.method,hd=(e,t,r)=>tO(r.sourceCode.getScope(e)).some(n=>t.has(n.identifier.name)&&((e,t,r)=>{let[n,o]=r.getRange(e),[a,i]=r.getRange(t);return n>=a&&o<=i})(n.identifier,e,r.sourceCode)),hm=(e,t,r)=>{let{sourceCode:n}=r,o=n.getText(e.node.value),a=eZ(t.value,r);return e.node.shorthand?`${o} = ${a}`:`${n.getText(e.node.key)}: ${o} = ${a}`},hf="prefer-single-object-destructuring",hg=(e,t)=>{let r,n;if(!("VariableDeclaration"===t.type&&("const"===(r=t.kind)||"let"===r)&&!t.declare&&1===t.declarations.length))return;let[o]=t.declarations;if("ObjectPattern"===o.id.type&&!o.id.typeAnnotation&&(n=o.id).properties.length>0&&n.properties.every(e=>"Property"===e.type&&!e.computed&&"Identifier"===e.value.type)&&o.init?.type==="Identifier"&&((e,t)=>{let r=ei(e.getScope(t),t);if(!r||1!==r.defs.length)return!1;let[n]=r.defs;return"Variable"===n.type&&"VariableDeclarator"===n.node.type&&"VariableDeclaration"===n.parent.type&&!n.parent.declare&&"const"===n.parent.kind})(e,o.init))return{node:t,declarator:o,source:o.init.name}},hy=(e,t,r)=>{let n,o,a=hg(e,t),i=hg(e,r);if(!(a&&i&&a.node.kind===i.node.kind&&a.source===i.source&&0===e.getCommentsInside(a.node).length&&0===e.getCommentsInside(i.node).length&&(n=a.node,o=i.node,!e.getTokensBetween(n,o,{includeComments:!0}).some(e=>eg(e)))))return;let s=t=>t.properties.map(t=>e.getText(t)).join(", "),l=`${a.node.kind} {${s(a.declarator.id)}, ${s(i.declarator.id)}} = ${a.source};`;return{node:i.node,messageId:hf,data:{source:a.source},fix:t=>t.replaceTextRange([e.getRange(a.node)[0],e.getRange(i.node)[1]],l)}};function*hh(e,t){for(let[r,n]of t.entries()){if(0===r)continue;let o=hy(e,t[r-1],n);o&&(yield o)}}let hx="prefer-smaller-scope",hb=new Set(["ArrowFunctionExpression","ClassDeclaration","ClassExpression","FunctionDeclaration","FunctionExpression","StaticBlock","WithStatement"]);function hE(e,t){let r=e.parent;for(;r&&r!==t;){if(hb.has(r.type))return!1;r=r.parent}return r===t}function hD(e,t,r){let n="before"===r?e.getTokenBefore(t,{includeComments:!0}):e.getTokenAfter(t,{includeComments:!0});return!!(n&&eg(n))}function hS(e,t){let r=e.getTokenBefore(t),n=e.getTokenAfter(t);return r?.value==="("&&n?.value===")"}let hv="prefer-single-array-predicate/error",hC="prefer-single-array-predicate/suggestion",hA=new Map([["||","some"],["&&","every"]]),hT=new Set(["AssignmentExpression","ArrowFunctionExpression","ConditionalExpression","SequenceExpression","TSAsExpression","TSNonNullExpression","TSSatisfiesExpression","TSTypeAssertion","YieldExpression"]),hw="prefer-url-href",hk="non-url",hI="unknown",hj=new Set(["ClassName","ImportBinding","Type"]),hF=new Set(["any","error","unknown"]),hB=new Set(["node:url","url"]),hR=e=>hj.has(e.type),h$=(e,t,r,n)=>{for(;t;){let o=t.set.get(e);if(o?.defs.some(e=>nV(e,r,n)))return o;t=t.upper}},hP=e=>e.every(e=>"url"===e)?"url":!e.includes(hI)&&e.includes(hk)?hk:hI,hL=e=>{let t;if("ImportBinding"!==e.type)return!1;let{node:r,parent:n}=e;return t=n.source,hB.has(t.value)&&"ImportSpecifier"===r.type&&"Identifier"===r.imported.type&&"URL"===r.imported.name},hN=e=>"ImportBinding"===e.type&&("type"===e.parent.importKind||n_(e.node)),hM=e=>"Type"===e.type||hN(e),hO=e=>hL(e)&&!hN(e),hq=(e,t)=>{let r;return"NewExpression"===e.type&&(((e,t)=>{if("Identifier"!==e.type||"URL"!==e.name||((e,t,r,n)=>{for(;t;){let o=t.set.get(e);if(o?.defs.some(e=>!hM(e)&&nV(e,r,n)))return!0;t=t.upper}return!1})("URL",t.sourceCode.getScope(e),e,t))return!1;if(nR(e,t))return!0;let r=ei(t.sourceCode.getScope(e),e);return r?.defs.length>0&&r.defs.every(e=>hM(e))})(r=e.callee,t)||((e,t)=>{if("Identifier"!==e.type)return!1;let r=ei(t.sourceCode.getScope(e),e);return r?.defs.some(e=>hO(e))??!1})(r,t))},hU=(e,t)=>t.sourceCode.getScope(e.name??e.node),hW=(e,t,r,n=new Set)=>{switch(e?.type){case"TSTypeAnnotation":case"TSParenthesizedType":return hW(e.typeAnnotation,t,r,n);case"TSTypeReference":return((e,t,r,n)=>{if("Identifier"!==e.typeName.type)return hI;let o=e.typeName.name,a=h$(o,r,e.typeName,t),[i]=a?.defs??[];if(!i)return"URL"!==o||((e,t)=>{for(;t;){let r=t.set.get(e);if(r?.defs.some(e=>hR(e)))return!0;t=t.upper}return!1})(o,r)?hI:"url";if(n.has(o))return hI;if(hL(i))return"url";n.add(o);let s=hI;return"Type"===i.type&&"TSTypeAliasDeclaration"===i.node.type?s=hW(i.node.typeAnnotation,t,hU(i,t),n):"Type"===i.type&&"TSTypeParameter"===i.node.type?s=hI:"ClassName"===i.type&&(s=hk),n.delete(o),s})(e,t,r,n);case"TSUnionType":return hP(e.types.map(e=>hW(e,t,r,n)));case"TSIntersectionType":return hP(e.types.map(e=>hW(e,t,r,n)));case"TSImportType":let o;return(o=e.source,hB.has(o.value)&&e.qualifier?.type==="Identifier"&&"URL"===e.qualifier.name)?"url":hk;default:return e?hk:hI}},h_=(e,t)=>{let{checker:r,context:n,node:o,program:a}=t;if(hF.has(e.intrinsicName)||e.isTypeParameter?.())return hI;let i=r.getBaseConstraintOfType(e);if(i&&i!==e)return h_(i,t);if(e.isUnion()||e.isIntersection())return hP(e.types.map(e=>h_(e,t)));let s=((e,t,r)=>{if(!/^[\w$]+$/.test(e))return hI;let n=h$(e,r.sourceCode.getScope(t),t,r),o=n?.defs.filter(e=>"Type"===e.type||"ClassName"===e.type||hL(e))??[];return 0===o.length?hI:o.every(e=>hL(e))?"url":hk})(r.typeToString(e),o,n);if(s!==hI)return s;let l=rv(e);return rC(l,a)&&"URL"===l.getName()?"url":hk},hV=(e,t)=>{let{parserServices:r}=t.sourceCode;if(!r?.program)return hI;try{let{program:n}=r;return h_(r.getTypeAtLocation(e),{checker:n.getTypeChecker(),context:t,node:e,program:n})}catch{return hI}};function hz(e,t,r=new Set){if(!e)return hI;let n=t.sourceCode.getScope(e);switch(e.type){case"Identifier":{let n=((e,t,r)=>{let n=ei(t.sourceCode.getScope(e),e);if(!n||r.has(n)||1!==n.defs.length)return hI;let[o]=n.defs;if(!nV(o,e,t))return hI;r.add(n);let a="Variable"===o.type&&"const"===o.parent.kind&&o.node.init?hz(o.node.init,t,r):hI,i=hW(o.name?.typeAnnotation,t,hU(o,t)),s=hI;return a!==hI?s=a:i!==hI&&(s=i),r.delete(n),s})(e,t,r);if(n!==hI)return n;break}case"TSAsExpression":case"TSSatisfiesExpression":case"TSTypeAssertion":{let o=hW(e.typeAnnotation,t,n);return o===hI?hz(e.expression,t,r):o}case"TSNonNullExpression":case"ParenthesizedExpression":return hz(e.expression,t,r);case"SequenceExpression":return hz(e.expressions.at(-1),t,r);case"ConditionalExpression":return hP([hz(e.consequent,t,r),hz(e.alternate,t,r)])}if(hq(e,t))return"url";if("NewExpression"===e.type){if(((e,t)=>{if("Identifier"!==e.type)return!1;let r=ei(t.sourceCode.getScope(e),e);return r?.defs.some(e=>!hM(e)&&!hO(e))??!1})(e.callee,t))return hk;let r=hV(e,t);return r===hI?hk:r}let o=((e,t)=>{if("CallExpression"!==e.type||"Identifier"!==e.callee.type)return hI;let r=ei(t.sourceCode.getScope(e.callee),e.callee);if(r?.defs.length!==1)return hI;let[n]=r.defs;return hW(n.node.returnType,t,hU(n,t))})(e,t);return o!==hI?o:hV(e,t)}let hK=(e,t)=>{switch(e.type){case"TSAsExpression":case"TSSatisfiesExpression":case"TSTypeAssertion":case"ParenthesizedExpression":case"TSNonNullExpression":return hK(e.expression,t);case"SequenceExpression":return hK(e.expressions.at(-1),t);case"ConditionalExpression":return hK(e.consequent,t)&&hK(e.alternate,t);case"NewExpression":return hq(e,t);default:return!1}},hG=(e,t)=>0===t.sourceCode.getCommentsInside(e).length,hJ="require-proxy-trap-boolean-return",hX=new Set(["defineProperty","deleteProperty","has","isExtensible","preventExtensions","set","setPrototypeOf"]),hY=new Set(["ArrowFunctionExpression","FunctionDeclaration","FunctionExpression"]),hH=new Set(["ArrayExpression","ArrowFunctionExpression","ClassExpression","FunctionExpression","NewExpression","ObjectExpression","TemplateLiteral","UpdateExpression"]),hZ=new Set(["%","&","*","**","+","-","/","<<",">>",">>>","^","|"]),hQ=(e,t)=>({node:e,messageId:hJ,data:{name:t}}),h0=e=>{if(e)return hQ(e.node,e.data.name)},h1=(e,t,r)=>{if("AssignmentExpression"===e.type)return"="===e.operator?h0(h1(e.right,t,r)):hQ(e,t);if("ConditionalExpression"===e.type)return h1(e.consequent,t,r)??h1(e.alternate,t,r);if("LogicalExpression"===e.type)return h0(h1(e.left,t,r)??h1(e.right,t,r));if("SequenceExpression"===e.type)return h0(h1(e.expressions.at(-1),t,r));let n=((e,t)=>{let r=ew(e,t.getScope(e));if(null!==r&&"boolean"!=typeof r.value)return!!r.value})(e,r);if(void 0===n&&!(hH.has(e.type)||"UnaryExpression"===e.type&&"!"!==e.operator&&"delete"!==e.operator||"BinaryExpression"===e.type&&hZ.has(e.operator)))return;let o=((e,t,r)=>{if(!(r.getCommentsInside(e).length>0)&&("Literal"===e.type&&!e.regex||"TemplateLiteral"===e.type&&0===e.expressions.length||"Identifier"===e.type&&"undefined"===e.name))return String(t)})(e,n,r);return{...hQ(e,t),...o&&{fix:t=>t.replaceText(e,o)}}},h2=(e,t)=>{if("Property"!==e.type||"init"!==e.kind)return;let r=eI(e,t.getScope(e));if(hX.has(r)&&hY.has(e.value.type))return{name:r,functionNode:e.value}},h3=({functionNode:e,name:t},r,n)=>{if(e.async||e.generator)return hQ(e,t);if("BlockStatement"!==e.body.type)return h1(e.body,t,r);let o=[...function* e(t){if(t&&"string"==typeof t.type){if("ReturnStatement"===t.type)return void(yield t);if(!("BlockStatement"!==t.type&&hY.has(t.type))){for(let[r,n]of Object.entries(t))if("parent"!==r){if(Array.isArray(n)){for(let t of n)yield*e(t);continue}yield*e(n)}}}}(e.body)],a=n.get(e)??!1;if(0===o.length){if(a)return;return hQ(e,t)}for(let e of o){if(!e.argument)return hQ(e,t);let n=h1(e.argument,t,r);if(n)return n}if(!a)return hQ(e,t)},h8=f.builtinRules.get("logical-assignment-operators"),h6="ifNullish",h9="convertIf",h5={...h8.meta.messages,[h6]:"'if' statement can be replaced with a logical operator assignment with operator ||= or ??=."},h4=e=>e.fix??e.suggest?.[0]?.fix,h7={create:e=>{let{sourceCode:t}=e,r=Object.create(e,{report:{value(r){e.report(function(e,t){let r;if("if"!==e.messageId||e.data?.operator!=="||="||"function"!=typeof h4(e))return e;let n={...(r={...e},delete r.fix,delete r.suggest,r),messageId:h6};if(t.getCommentsInside(e.node).length>0)return n;let o=h4(e);return{...n,suggest:[{messageId:h9,data:{operator:"||="},fix:o},{messageId:h9,data:{operator:"??="},fix:e=>o(new Proxy(e,{get(e,t){if("insertTextBefore"!==t){let r=Reflect.get(e,t,e);return"function"==typeof r?r.bind(e):r}return(t,r)=>e.insertTextBefore(t,"||"===r?"??":r)}}))}]}}(r,t))}}});for(let[t,n]of Object.entries(h8.create(r)))e.on(t,n)},meta:{type:h8.meta.type,docs:{description:h8.meta.docs.description,recommended:!0},fixable:h8.meta.fixable,hasSuggestions:h8.meta.hasSuggestions,schema:h8.meta.schema,defaultOptions:[h8.meta.defaultOptions?.[0]],messages:h5,languages:["js/js"]}},xe="no-useless-coercion",xt=new Map([["Boolean",{type:"boolean",isType:ny}],["String",{type:"string",isType:nC}],["BigInt",{type:"bigint",isType:function(e,t){return!!e&&(!!("TSSatisfiesExpression"===e.type&&nx(e.typeAnnotation)||nb(e,t))||"bigint"==typeof ew(e,t.sourceCode.getScope(e))?.value)}}],["Number",{type:"number",isType:(e,t)=>nr(e,t.sourceCode.getScope(e))}]]),xr=e=>"Literal"===e.type&&""===e.value,xn="no-useless-boolean-cast",xo=["every","filter","find","findIndex","findLast","findLastIndex","some"],xa="no-useless-continue",xi="no-useless-override",xs=e=>e.isUnion()?e.types.every(e=>xs(e)):"void"===e.intrinsicName||"undefined"===e.intrinsicName,xl=(e,t)=>{let{parserServices:r}=t.sourceCode;if(r?.program)try{return{type:r.getTypeAtLocation(e),checker:r.program.getTypeChecker()}}catch{}},xu="prefer-has-check",xp=new Set(["Map","ReadonlyMap","WeakMap"]),xc=new Set(["Map","WeakMap"]),xd=new Set(["FormData","Headers","URLSearchParams"]),xm=new Set(["Array","ReadonlyArray"]),xf=new Set([...xc,...xd]),xg=new Set(["ClassName","ImportBinding","TSEnumName","Type"]),xy=new Set(["any","bigint","boolean","false","number","string","unknown","undefined","null","void"]),xh=new Set(["TSTypeAnnotation","TSParenthesizedType"]),xx=new Set(["TSAnyKeyword","TSNeverKeyword","TSUndefinedKeyword","TSUnknownKeyword","TSVoidKeyword"]),xb=new Set(["TSBigIntKeyword","TSBooleanKeyword","TSNumberKeyword","TSStringKeyword"]),xE=new Set(["TSArrayType","TSConstructorType","TSFunctionType","TSObjectKeyword","TSSymbolKeyword","TSTupleType"]),xD=new Set(["ArrayExpression","ArrowFunctionExpression","ClassExpression","FunctionExpression","NewExpression","ObjectExpression"]),xS=new Set(["ParenthesizedExpression","TSAsExpression","TSSatisfiesExpression","TSTypeAssertion","TSNonNullExpression"]),xv=e=>{for(;xS.has(e.type);)e=e.expression;return e},xC=e=>{if("Identifier"===e.type)return e.name;if("TSQualifiedName"===e.type){let t=xC(e.left);return t?`${t}.${e.right.name}`:void 0}},xA=e=>e.typeArguments?.params??e.typeParameters?.params??[],xT=(e,t)=>{for(;t;){let r=t.set.get(e)?.defs.find(e=>xg.has(e.type));if(r)return r;t=t.upper}},xw=e=>{if(e?.type==="Type"&&"TSTypeAliasDeclaration"===e.node.type&&0===xA(e.node).length)return e.node.typeAnnotation},xk=(e,t)=>{if(t.sourceCode.isGlobalReference(e))return!0;let r=ei(t.sourceCode.getScope(e),e);return!r||0===r.defs.length},xI=(e,t)=>tx(e)&&xk(e,t)||"UnaryExpression"===e.type&&"void"===e.operator&&"Literal"===e.argument.type&&0===e.argument.value,xj=(e,t)=>xp.has(e)?{kind:"map",typeName:e,valueType:t}:xd.has(e)?{kind:"null-sentinel",typeName:e}:void 0,xF=(e,t,r=new Set)=>{switch(e?.type){case"TSTypeAnnotation":case"TSParenthesizedType":return xF(e.typeAnnotation,t,r);case"TSTypeOperator":return"readonly"===e.operator?xF(e.typeAnnotation,t,r):void 0;case"TSTypeReference":{let n=xC(e.typeName);if(!n)return;if((xp.has(n)||xd.has(n))&&!xT(n,t))return xj(n,xA(e).at(-1));let o=((e,t,r)=>{if(!r.has(e))return r.add(e),xw(xT(e,t))})(n,t,r);return o?xF(o,t,r):void 0}}},xB=(e,t)=>{let r=t.sourceCode.getScope(e);return xF(e.typeAnnotation,r)},xR=(e,t,r=new Set)=>{let n=xB(e,t);if(n)return n;if(te(e=xv(e))&&"Identifier"===e.callee.type&&xf.has(e.callee.name)&&xk(e.callee,t))return xj(e.callee.name);if("Identifier"!==e.type)return;let o=ei(t.sourceCode.getScope(e),e);if(!o||r.has(o)||1!==o.defs.length)return;r.add(o);let[a]=o.defs,i=xF(a.name?.typeAnnotation,t.sourceCode.getScope(a.name));return i||("Variable"===a.type&&"const"===a.parent.kind&&a.node.id===a.name&&a.node.init?xR(a.node.init,t,r):void 0)},x$=(e,t)=>{for(let r of[e,e.target]){if(!r)continue;let e=rv(r);if(rC(e,t))return e.getName()}},xP=(e,t,r)=>{if(rD.has(e.intrinsicName)||rS.has(e.intrinsicName))return;if(e.isUnion()){let n=e.types.map(e=>xP(e,t,r));if(1===new Set(n.map(e=>e?.typeName)).size){let[e]=n;if(e?.kind!=="map")return e;let r=n.map(e=>e?.valueType);return{...e,valueType:r.every(Boolean)?t.getUnionType(r):void 0}}if(n.every(e=>e?.kind==="map")){let e=n.map(e=>e.valueType);return{kind:"map",typeName:"Map",valueType:e.every(Boolean)?t.getUnionType(e):void 0}}return n.every(e=>e?.kind==="null-sentinel")?{kind:"null-sentinel",typeName:"null-sentinel"}:void 0}if(e.isIntersection())return e.types.map(e=>xP(e,t,r)).find(e=>e?.kind==="map");let n=x$(e,r);return xj(n,xp.has(n)?t.getTypeArguments(e).at(-1):void 0)},xL=(e,t)=>{let{parserServices:r}=t.sourceCode;if(r?.program)try{let{program:t}=r;return xP(r.getTypeAtLocation(e),t.getTypeChecker(),t)}catch{}},xN=(e,t)=>xL(e,t)??xR(e,t),xM=(e,t)=>"truthy"===t?!!e:"not-undefined"===t?void 0!==e:null!=e,xO=(e,t,r,n=new Set)=>{if(!e||xx.has(e.type))return!1;if(xh.has(e.type))return xO(e.typeAnnotation,t,r,n);if("TSTypeOperator"===e.type)return"readonly"===e.operator&&xO(e.typeAnnotation,t,r,n);if("TSUnionType"===e.type||"TSIntersectionType"===e.type)return e.types.every(e=>xO(e,t,r,n));if("TSNullKeyword"===e.type)return"not-undefined"===r;if(xb.has(e.type))return"truthy"!==r;if(xE.has(e.type))return!0;if("TSTypeLiteral"===e.type)return"truthy"!==r;if("TSLiteralType"===e.type){var o;let t="Literal"===(o=e.literal).type?o.value:"TemplateLiteral"===o.type&&0===o.expressions.length?o.quasis[0].value.cooked:"UnaryExpression"===o.type&&("-"===o.operator||"+"===o.operator)&&"Literal"===o.argument.type&&("number"==typeof o.argument.value||"bigint"==typeof o.argument.value)?"-"===o.operator?-o.argument.value:o.argument.value:void 0;return void 0!==t&&xM(t,r)}return"TSTypeReference"===e.type&&((e,t,r,n)=>{let o,a,i=xC(e.typeName);if(!i||n.has(i))return!1;n.add(i);let s=(a=xw(o=xT(i,t.sourceCode.getScope(e.typeName))))?{type:"alias",node:a}:o?.type==="ClassName"||o?.type==="Type"&&"TSInterfaceDeclaration"===o.node.type?{type:"object"}:void 0,l=!1;return s?.type==="alias"?l=xO(s.node,t,r,n):s?.type==="object"&&(l="truthy"!==r),n.delete(i),l})(e,t,r,n)},xq=(e,t)=>e.isTypeParameter?.()?e.getConstraint()??t.getBaseConstraintOfType(e):e,xU=(e,t,r)=>{if(rD.has(e.intrinsicName))return!1;let n=xq(e,t);return n&&n!==e?xU(n,t,r):!e.isTypeParameter?.()&&(e.isUnion()||e.isIntersection()?e.types.every(e=>xU(e,t,r)):!r.has(e.intrinsicName))},xW=(e,t,r)=>{if(rD.has(e.intrinsicName)||rS.has(e.intrinsicName))return!1;let n=xq(e,t);if(n&&n!==e)return xW(n,t,r);if(e.isUnion()||e.isIntersection())return e.types.every(e=>xW(e,t,r));if(xy.has(e.intrinsicName))return!1;if("true"===e.intrinsicName||"symbol"===e.intrinsicName)return!0;if(e.isStringLiteral?.())return e.value.length>0;if(e.isNumberLiteral?.())return 0!==e.value;if(e.isBigIntLiteral?.())return e.value.negative||"0"!==e.value.base10Value;let o=t.typeToString(e);return/^-?\d+n$/u.test(o)?!/^-?0n$/u.test(o):"object"===t.typeToString(e)||xm.has(x$(e,r))||e.getCallSignatures().length>0||e.getConstructSignatures().length>0},x_=(e,t,r)=>{if(!te(e)||"Identifier"!==e.callee.type||!xc.has(e.callee.name)||!xk(e.callee,t))return;if(0===e.arguments.length)return!0;if(1!==e.arguments.length)return;let[n]=e.arguments;if("ArrayExpression"===n.type)return n.elements.every(e=>{var n;let o;return e?.type==="ArrayExpression"&&e.elements.length>=2&&e.elements[1]&&"SpreadElement"!==e.elements[1].type&&(n=e.elements[1],(o=ew(n,t.sourceCode.getScope(n)))?xM(o.value,r):!tx(n)&&xD.has(n.type))})},xV=(e,t,r)=>{let n=x_(xv(e),t,r);if(void 0!==n)return n;let o=xL(e,t)?.valueType;if(o){let{program:e}=t.sourceCode.parserServices,n=e.getTypeChecker();if("truthy"===r?xW(o,n,e):"not-undefined"===r?xU(o,n,new Set(["undefined","void"])):xU(o,n,new Set(["undefined","void","null"])))return!0}return function e(t,r,n,o={}){let a,i=o.visitedVariables??new Set,s=o.checkConstructorValues??!0,l=xB(t,r);if(l?.kind==="map")return!!l.valueType&&xO(l.valueType,r,n);let u=((e,t,r,n)=>{if(!te(e)||"Identifier"!==e.callee.type||!xc.has(e.callee.name)||!xk(e.callee,t))return;if(n){let n=x_(e,t,r);if(void 0!==n)return n}let o=xA(e).at(-1);return!!o&&xO(o,t,r)})(t=xv(t),r,n,s);if(void 0!==u)return u;let p=((e,t,r)=>{if("Identifier"!==e.type)return;let n=ei(t.sourceCode.getScope(e),e);if(!(!n||r.has(n))&&1===n.defs.length)return n})(t,r,i);if(!p)return!1;i.add(p);let[c]=p.defs,d=(a=xF(c.name?.typeAnnotation,r.sourceCode.getScope(c.name)),a?.kind==="map"?!!a.valueType&&xO(a.valueType,r,n):"Variable"===c.type&&"const"===c.parent.kind&&c.node.id===c.name&&!!c.node.init&&e(c.node.init,r,n,{visitedVariables:i,checkConstructorValues:!1}));return i.delete(p),d}(e,t,r)},xz=e=>"Literal"===e.type&&null===e.value,xK="prefer-minimal-ternary",xG=new Set(["ChainExpression","LogicalExpression","NewExpression","SequenceExpression","TaggedTemplateExpression"]),xJ=new Set(["Identifier","Literal","Super","ThisExpression"]);function xX(e){return xG.has(e.type)}function xY(e,t,r){return r.getText(e)===r.getText(t)}function xH(e){return xJ.has(e.type)}function xZ(e,t){let r=eI(e,t.sourceCode.getScope(e));return null===r?void 0:r}function xQ(e,t,r){let{sourceCode:n}=r;if("MemberExpression"!==e.type||"MemberExpression"!==t.type||rh(e)||rh(t)||"Super"===e.object.type||"Super"===t.object.type)return!1;let o=xZ(e,r),a=xZ(t,r);return void 0!==o&&o===a&&!xY(e.object,t.object,n)}function x0(e){return"in"===e.operator&&"PrivateIdentifier"===e.left.type}let x1={create:e=>{let{checkComputedMemberAccess:t}=e.options[0];e.on("ConditionalExpression",r=>{var n,o,a,i,s,l,u;if(n=r.consequent,o=r.alternate,a=e,i=t,!(n.type!==o.type||xX(n)||xX(o))&&(function(e,t,r,n){var o,a,i,s;let{sourceCode:l}=r;return!("CallExpression"!==e.type||"CallExpression"!==t.type||rh(e)||rh(t)||e.arguments.some(e=>"SpreadElement"===e.type)||t.arguments.some(e=>"SpreadElement"===e.type))&&(!!(xY(e.callee,t.callee,l)&&xH(e.callee)&&function(e,t,r){if(e.length!==t.length)return!1;let n=0;for(let[o,a]of e.entries()){let e=t[o];if(!xY(a,e,r)){if("ConditionalExpression"===a.type||"ConditionalExpression"===e.type)return!1;n++}}return 1===n}(e.arguments,t.arguments,l))||(o=e.arguments,a=t.arguments,o.length===a.length&&o.every((e,t)=>xY(e,a[t],l))&&(i=e.callee,s=t.callee,"Identifier"===i.type&&"Identifier"===s.type&&i.name!==s.name||n&&function(e,t,r){let{sourceCode:n}=r;if("MemberExpression"!==e.type||"MemberExpression"!==t.type||rh(e)||rh(t)||!xH(e.object)||!xY(e.object,t.object,n))return!1;let o=xZ(e,r),a=xZ(t,r);return void 0!==o&&void 0!==a&&o!==a}(i,s,r)||xQ(i,s,r))))}(n,o,a,i)||function(e,t,r){if("BinaryExpression"!==e.type||"BinaryExpression"!==t.type||e.operator!==t.operator||x0(e)||x0(t))return!1;let n=xY(e.left,t.left,r.sourceCode),o=xY(e.right,t.right,r.sourceCode);return n!==o&&(o||xH(e.left))}(n,o,a)||xQ(s=n,l=o,u=a)||function(e,t,r){let{sourceCode:n}=r;return!("MemberExpression"!==e.type||"MemberExpression"!==t.type||!e.computed||!t.computed||rh(e)||rh(t))&&!!xH(e.object)&&!!xY(e.object,t.object,n)&&void 0===xZ(e,r)&&void 0===xZ(t,r)&&!xY(e.property,t.property,n)}(s,l,u)))return{node:r,messageId:xK}})},meta:{type:"suggestion",docs:{description:"Prefer moving ternaries into the minimal varying part of an expression.",recommended:"unopinionated"},schema:[{type:"object",additionalProperties:!1,properties:{checkComputedMemberAccess:{type:"boolean",description:"Also report method-call ternaries that differ only by the method name, whose minimization requires computed member access."}}}],defaultOptions:[{checkComputedMemberAccess:!1}],messages:{[xK]:"Move the ternary into the varying part of the expression."},languages:["js/js"]}},x2="logical",x3="ternary",x8="consistent-conditional-object-spread",x6=new Set(["==","==="]),x9=new Set(["!=","!=="]),x5=e=>"SpreadElement"===e.parent.type&&e.parent.argument===e&&"ObjectExpression"===e.parent.parent.type&&e.parent.parent.properties.includes(e.parent);function x4(e,t,r){if(tQ(e,t))return!0;if(e.type!==t.type)return!1;switch(e.type){case"AwaitExpression":return x4(e.argument,t.argument,r);case"LogicalExpression":return e.operator===t.operator&&x4(e.left,t.left,r)&&x4(e.right,t.right,r);case"UnaryExpression":return e.operator===t.operator&&e.prefix===t.prefix&&x4(e.argument,t.argument,r);case"UpdateExpression":return!1}return r.getText(e)===r.getText(t)}function x7(e){return e9(e)?"null":tx(e)?"undefined":void 0}function be(e){if("BinaryExpression"!==e.type||!x6.has(e.operator)&&!x9.has(e.operator))return;let t=x7(e.left),r=x7(e.right);if(!!t!=!!r)return{reference:t?e.right:e.left,kind:2===e.operator.length?"nullish":t??r,isTrueWhenNullish:x6.has(e.operator)}}let bt=(e,t)=>"null"===e.kind&&"undefined"===t.kind||"undefined"===e.kind&&"null"===t.kind;function br(e,t){let r=be(e);if(r?.kind==="nullish")return r;if("LogicalExpression"!==e.type)return;let n=be(e.left),o=be(e.right);if(n&&o&&x4(n.reference,o.reference,t)){if("||"===e.operator&&n.isTrueWhenNullish&&o.isTrueWhenNullish&&bt(n,o))return{reference:n.reference,isTrueWhenNullish:!0};if("&&"===e.operator&&!n.isTrueWhenNullish&&!o.isTrueWhenNullish&&bt(n,o))return{reference:n.reference,isTrueWhenNullish:!1}}}function bn(e,t,r){let n=eZ(e,r);return!eQ(e,r)&&n6(e,{operator:"&&",property:t})&&(n=`(${n})`),n}function bo(e,t){let r=eZ(e,t);return!eQ(e,t)&&nQ(e)&&(r=`(${r})`),r}let ba="default-export-style/inline",bi="default-export-style/separate",bs="default-export-style/suggestion-inline",bl="default-export-style/suggestion-separate",bu="inline",bp="separate",bc="ignore",bd="class",bm="function",bf=()=>({enum:[bu,bp,bc]}),bg=(e,t)=>e?.type==="ExportDefaultDeclaration"&&"Identifier"===e.declaration.type&&e.declaration.name===t,by=e=>e.id?.name,bh=e=>{switch(e.type){case"ClassDeclaration":return bd;case"FunctionDeclaration":return bm}},bx=e=>e===bd?"classes":"functions",bb=(e,t)=>{let[,r]=e.sourceCode.getRange(t),n=e.sourceCode.getLoc(t).end.line;return t6(e).some(t=>e.sourceCode.getRange(t)[0]>=r&&e.sourceCode.getLoc(t).start.line===n)},bE=(e,t)=>ei(e,t)?.references.some(e=>!e.init&&e.isWrite())??!1,bD=e=>!!e&&!!(e.type.startsWith("TS")||e.typeAnnotation||e.typeParameters||e.returnType||e.implements?.length>0||e.superTypeArguments||e.accessibility||e.readonly||e.override||e.definite||e.optional&&"MemberExpression"!==e.type&&"CallExpression"!==e.type||e.abstract||e.declare||e.decorators?.length>0),bS=(e,t)=>{if(bD(e))return!0;for(let r of t[e.type]??[]){let n=e[r];if(Array.isArray(n)){if(n.some(e=>e?.type&&bS(e,t)))return!0;continue}if(n?.type&&bS(n,t))return!0}return!1},bv=(e,t)=>e.params.every(e=>!rm(e,t.sourceCode.visitorKeys)),bC=(e,t,r)=>ei(e,t)?.references.some(e=>!e.init&&e.identifier!==r)??!1,bA=(e,t)=>{let r=by(e);if(r){let t=bh(e);return t&&{kind:t,name:r,declaration:e}}let n=((e,t)=>{if("VariableDeclaration"!==e.type||"const"!==e.kind||1!==e.declarations.length)return;let[r]=e.declarations;if(!("Identifier"!==r.id.type||bD(r.id)||r.init?.type!=="ArrowFunctionExpression"||bS(r.init,t.sourceCode.visitorKeys)))return r})(e,t);if(n)return{kind:bm,name:n.id.name,declaration:e,functionNode:n.init}},bT=(e,t)=>e.params.map(e=>t.getText(e)).join(", "),bw=({context:e,declaration:t,exportDeclaration:r,name:n,scope:o,rangeStartNode:a=t})=>{if(!(e.sourceCode.getCommentsInside(r).length>e.sourceCode.getCommentsInside(t).length||bC(o,t.id,"Identifier"===r.declaration.type?r.declaration:void 0))&&"FunctionDeclaration"===t.type&&!t.generator&&!bS(t,e.sourceCode.visitorKeys)&&0===e.sourceCode.getCommentsInside(t).length&&bv(t,e)&&!rm(t.body,e.sourceCode.visitorKeys))return[{messageId:bl,fix:o=>o.replaceTextRange([e.sourceCode.getRange(a)[0],e.sourceCode.getRange(r)[1]],`const ${n} = ${t.async?"async ":""}(${bT(t,e.sourceCode)}) => ${e.sourceCode.getText(t.body)};
|
|
19
|
-
export default ${n};`)}]},
|
|
20
|
-
export default ${n.id.name};`)}}}},bj={create:e=>{let t=e.options[0];e.on("Program",r=>{for(let[n,o]of r.body.entries()){if("ExportDefaultDeclaration"===o.type){let{declaration:r}=o,n=bh(r),a=by(r);if(!n||!a)continue;let i=bI({context:e,exportDeclaration:o,expectedStyle:t[bx(n)],kind:n});if(i)return i;continue}let a=r.body[n+1],i=bA(o,e);if(!i||!bg(a,i.name))continue;let s=bk({context:e,exportDeclaration:a,expectedStyle:t[bx(i.kind)],scope:e.sourceCode.getScope(a),...i});if(s)return s}})},meta:{type:"suggestion",docs:{description:"Enforce consistent default export declarations.",recommended:!0},fixable:"code",hasSuggestions:!0,schema:[{type:"object",properties:{functions:bf(),classes:bf()},additionalProperties:!1}],defaultOptions:[{functions:bu,classes:bu}],messages:{[ba]:"Prefer declaring this default-exported {{kind}} inline.",[bi]:"Prefer declaring this default-exported {{kind}} as a separate {{style}}.",[bs]:"Use an inline default {{kind}} declaration.",[bl]:"Use a separate const arrow function default export."},languages:["js/js"]}};function bF(e){for(;;){let t=ry(e);if(t!==e){e=t;continue}if(e?.type!=="ParenthesizedExpression")return e;e=e.expression}}function bB(e,t){return ei(t.sourceCode.getScope(e),e)}let bR="no-array-concat-in-loop",b$="no-array-front-mutation",bP=["stream.unshift","this.unshift","this.stream.unshift","process.stdin.unshift","process.stdout.unshift","process.stderr.unshift"],bL="no-array-sort-for-min-max/error",bN="no-array-sort-for-min-max/suggestion",bM=e=>e8(e)&&0===e.value,bO=(e,t)=>{if(!td(e,{methods:["sort","toSorted"],argumentsLength:1,optionalCall:!1,optionalMember:!1})||rG(e.callee.object,t)||rh(e.callee.object))return;let[r]=e.arguments,n=(e=>{if(!tl(e)||e.async||e.generator||2!==e.params.length||e.params.some(e=>"Identifier"!==e.type))return;let t=ry((e=>{if("BlockStatement"!==e.body.type)return e.body;if(1!==e.body.body.length)return;let[t]=e.body.body;if("ReturnStatement"===t.type)return t.argument})(e));if(t?.type!=="BinaryExpression"||"-"!==t.operator)return;let[r,n]=e.params;if(r.name!==n.name){if(tQ(t.left,r)&&tQ(t.right,n))return"ascending";if(tQ(t.left,n)&&tQ(t.right,r))return"descending"}})(r);if(n)return{direction:n,node:e.callee.object}},bq=(e,t,r,n)=>{var o,a,i;let s=(o=t.direction,"first"===r?"ascending"===o?"min":"max":"ascending"===o?"max":"min"),l={node:e,messageId:bL,data:{method:s,extreme:"min"===s?"minimum":"maximum"}};if("Super"!==t.node.type&&0===n.sourceCode.getCommentsInside(e).length){let r,o=(a=t.node,i=n.sourceCode,r=nN(a)?i.getText(a):`(${i.getText(a)})`,`Math.${s}(...${r})`);l.suggest=[{messageId:bN,data:{replacement:o},fix:t=>t.replaceText(e,o)}]}return l},bU="no-boolean-sort-comparator",bW="no-boolean-sort-comparator/suggestion",b_=new Set(["sort","toSorted"]),bV=new Set([">",">=","<","<="]),bz=(e,t,r,n)=>(e=ry(e),t=ry(t),"Identifier"===e.type&&"Identifier"===t.type)?e.name===r.name&&t.name===n.name||e.name===n.name&&t.name===r.name:"MemberExpression"===e.type&&"MemberExpression"===t.type&&e.computed===t.computed&&(e.computed?!!tQ(e.property,t.property):e.property.name===t.property.name)&&bz(e.object,t.object,r,n),bK=(e,t)=>{for(;rg(e);){if(e.typeAnnotation&&nd(e.typeAnnotation,t,t.sourceCode.getScope(e)))return!0;e=e.expression}return!1},bG="no-chained-comparison/error",bJ="no-chained-comparison/suggestion",bX=new Set(["<",">","<=",">="]),bY=new Set(["===","!==","==","!="]),bH=new Set([...bX,...bY]),bZ=e=>"BinaryExpression"===e.type&&bH.has(e.operator),bQ="no-constant-zero-expression/error",b0="no-constant-zero-expression/suggestion",b1="no-duplicate-logical-operands",b2="no-duplicate-logical-operands/suggestion",b3=new Set(["Identifier","ThisExpression","Literal"]),b8=new Set(["Identifier","ThisExpression"]),b6=e=>{if(lx(e=ry(e)))return!1;switch(e.type){case"Identifier":case"Super":case"ThisExpression":return!0;case"MemberExpression":var t;return b6(e.object)&&(!e.computed||(t=ry(t=e.property),b3.has(t.type)));default:return!1}},b9="no-impossible-length-comparison",b5={"<":">","<=":">=",">":"<",">=":"<=","===":"===","!==":"!==","==":"==","!=":"!="},b4="no-invalid-character-comparison",b7=new Set(["==","===","!=","!=="]),Ee=(e,t)=>!!(td(e,{method:"charAt",maximumArguments:1,optionalCall:!1,optionalMember:!1})&&nC(e.callee.object,t)||td(e,{method:"at",maximumArguments:1,optionalCall:!1,optionalMember:!1})&&nC(e.callee.object,t))||"MemberExpression"===e.type&&e.computed&&!e.optional&&(e=>{if(e8(e))return!0;if(!e1(e))return!1;let t=Number(e.value);return Number.isSafeInteger(t)&&t>=0&&String(t)===e.value})(e.property)&&nC(e.object,t),Et="no-loop-iterable-mutation",Er=["copyWithin","fill","pop","push","reverse","shift","sort","splice","unshift"],En=["add","clear","delete"],Eo=["clear","delete","set"],Ea={array:new Set(Er),set:new Set(En),map:new Set(Eo),unknown:new Set([...Er,...En,...Eo])},Ei=new Set(["entries","keys","values"]),Es=new Set(["ArrowFunctionExpression","ClassDeclaration","ClassExpression","FunctionDeclaration","FunctionExpression"]);function El(e,t){return rK(e,t)?"array":rY(e,t)?"set":rH(e,t)?"map":void 0}function Eu(e){return"VariableDeclaration"===e.left.type?e.left.declarations[0].id:e.left}function Ep(e){return"Identifier"===(e=ry(e)).type?e:void 0}function Ec(e){if("ArrayPattern"!==(e=ry(e)).type)return;let[t]=e.elements;return t&&Ep(t)}function Ed(e,t){if(lx(e=ry(e)))return;if(lh(e))return{collectionKind:El(e,t),reference:e,method:"direct"};if("CallExpression"!==e.type||"MemberExpression"!==e.callee.type||e.arguments.length>0)return;let r=eI(e.callee,t.sourceCode.getScope(e.callee));if(!(!Ei.has(r)||lx(e.callee.object))&&lh(e.callee.object))return{collectionKind:El(e.callee.object,t),reference:e.callee.object,method:r}}function Em(e,t){let r=Eu(e);return"keys"===t.method?Ep(r):"entries"===t.method||"direct"===t.method&&"set"!==t.collectionKind?Ec(r):void 0}function Ef(e,t){let r,n;if("VariableDeclaration"!==e.left.type||"const"!==e.left.kind)return{collectionKind:t.collectionKind,iterable:t.reference,loopBody:e.body};let o=(r=Eu(e),"entries"===t.method?Ec(r):"direct"!==t.method||"map"!==t.collectionKind?Ep(r):void 0),a=Em(e,t),i=(n=Eu(e),"set"===t.collectionKind&&("direct"===t.method||"values"===t.method)?Ep(n):"direct"===t.method&&"map"!==t.collectionKind?Ep(n)??Ec(n):Em(e,t));return{addArgumentIdentifier:o,collectionKind:t.collectionKind,deleteArgumentIdentifier:i,iterable:t.reference,loopBody:e.body,setKeyIdentifier:a}}function*Eg(e){"Identifier"===(e=ry(e)).type?yield e:"MemberExpression"===e.type&&(yield*Eg(e.object),e.computed&&(yield*Eg(e.property)))}function Ey(e,t,r){if(!ly(e,t))return!1;let n=[...Eg(e)],o=[...Eg(t)];return n.length!==o.length||0===n.length?n.length===o.length:n.every((e,t)=>{var n;let a,i;return n=o[t],a=ei(r.sourceCode.getScope(e),e),i=ei(r.sourceCode.getScope(n),n),a||i?a===i:e.name===n.name})}function Eh(e,t,r){let[n]=e.arguments;return!!(t&&n&&Ey(n,t,r))}function Ex(e,t,r,n){return"add"===r&&Eh(e,t.addArgumentIdentifier,n)||"set"===r&&Eh(e,t.setKeyIdentifier,n)}let Eb="no-selector-as-dom-name",EE=["add","remove","contains","toggle","replace"],ED=/^[#.]-?[A-Z_a-z][\w-]*$/u,ES=new Set([".","#"]),Ev=e=>ES.has(e?.[0]),EC=e=>e3(e)??("TemplateLiteral"===e.type&&e.quasis[0].value.cooked),EA=(e,t,r,n)=>({node:e,messageId:Eb,fix:((e,t,r,n)=>{let o=((e,t)=>{let[r]=t.getRange(e);return[r+1,r+2]})(e,n);if(t.startsWith(r)&&n.text[o[0]]===r){if("TemplateLiteral"===e.type&&e.expressions.length>0){if(1!==e.expressions.length||e.quasis[0].value.cooked!==r||""!==e.quasis[1].value.cooked)return;return e=>e.removeRange(o)}if(ED.test(t))return e=>e.removeRange(o)}})(e,t,r,n)}),ET=(e,t)=>e.map(e=>({node:e,expectedPrefix:t})),Ew="no-useless-compound-assignment/error",Ek="no-useless-compound-assignment/remove",EI="no-useless-compound-assignment/replace",Ej=new Map([["+=",0],["-=",0],["*=",1],["/=",1],["**=",1]]),EF="no-useless-delete-check",EB="removeCheck",ER={considerGetters:!0},E$=new Set(["Map","Set","WeakMap","WeakSet"]),EP=new Set(["ArrayExpression","ArrowFunctionExpression","ClassExpression","FunctionExpression","ObjectExpression"]),EL=new Set(["ClassName","FunctionName"]),EN=new Set(["TSConstructorType","TSFunctionType","TSObjectKeyword"]),EM=e=>null!==e&&("object"==typeof e||"function"==typeof e),EO=e=>!!EN.has(e?.type)||e?.type==="TSUnionType"&&e.types.every(e=>EO(e)),Eq=(e,t)=>{if("Identifier"!==e.type)return!1;let r=ei(t.sourceCode.getScope(e),e);return r?.defs.some(e=>EL.has(e.type))??!1},EU=(e,t)=>{let r=ew(e,t.sourceCode.getScope(e));return r&&"symbol"!=typeof r.value&&!EM(r.value)?String(r.value):void 0},EW=(e,t)=>{let r=ew(e,t.sourceCode.getScope(e));if(r)return EM(r.value);let n=ra(ry(e),t);if(n){let e=ry(n),r=ew(e,t.sourceCode.getScope(e));if(r)return EM(r.value);if(EP.has(e.type))return!0}return!Eq(ry(e),t)&&EO(((e,t)=>{if("Identifier"!==(e=ry(e)).type)return;let r=ei(t.sourceCode.getScope(e),e);return r?.defs[0]?.name?.typeAnnotation?.typeAnnotation??e.typeAnnotation?.typeAnnotation})(e,t))},E_=(e,t)=>!eP(e,t.sourceCode,ER),EV=(e,t)=>td(e,{method:t,argumentsLength:1,computed:!1,optionalCall:!1,optionalMember:!1,allowSpreadElement:!1}),Ez=(e,t,r)=>n=>{if(re(r,r.sourceCode.getRange(e)))return;let o=r.sourceCode.getText(t.parent);return o.trimEnd().endsWith(";")||(o+=";"),nW(r.sourceCode.getTokenBefore(e),r,o)&&(o=`;${o}`),n.replaceText(e,o)},EK="no-useless-logical-operand",EG=new Map([["&&",!0],["||",!1]]),EJ=new Map([["&&",!1],["||",!0]]),EX=new Set(["FunctionExpression","ClassExpression","ObjectExpression"]),EY="prefer-boolean-return",EH=new Set(["==","!=","===","!==","<","<=",">",">=","in","instanceof"]);function EZ(e){if(e){if("BlockStatement"===e.type){let t=e.body.filter(({type:e})=>"EmptyStatement"!==e);if(1===t.length)return EZ(t[0])}return e}}let EQ=e=>{if(e?.type==="ReturnStatement"&&e.argument?.type==="Literal"&&"boolean"==typeof e.argument.value)return e.argument.value};function E0(e,t){switch(e.type){case"Literal":return"boolean"==typeof e.value;case"UnaryExpression":return["!","delete"].includes(e.operator);case"BinaryExpression":return EH.has(e.operator);case"LogicalExpression":return E0(e.left,t)&&E0(e.right,t);case"CallExpression":return tC(e,t)||"CallExpression"===e.type&&!e.optional&&"MemberExpression"===e.callee.type&&!e.callee.optional&&!e.callee.computed&&"Identifier"===e.callee.object.type&&"Array"===e.callee.object.name&&t.sourceCode.isGlobalReference(e.callee.object)&&"Identifier"===e.callee.property.type&&"isArray"===e.callee.property.name;default:return!1}}let E1="prefer-continue",E2=new Set(["ClassDeclaration","FunctionDeclaration","TSEnumDeclaration","TSInterfaceDeclaration","TSModuleDeclaration","TSTypeAliasDeclaration"]),E3=new Set(["const","let"]),E8=(e,t)=>{let r=e.text.lastIndexOf("\n",t-1)+1;return/^[\t ]*/.exec(e.text.slice(r,t))[0]},E6=(e,[t,r],n)=>{let[o,a]=n.getRange(e);return o>=t&&a<=r},E9=e=>"VariableDeclaration"===e.type&&"var"!==e.kind&&!E3.has(e.kind)||E2.has(e.type),E5=(e,t)=>{let r=t.getTokenAfter(t.getFirstToken(e)),n=t.getTokenBefore(e.consequent);return[t.getRange(r)[1],t.getRange(n)[0]]},E4=(e,t)=>{if(e7(e,{name:"eval",optional:!1}))return!0;for(let r of t.visitorKeys[e.type]??[]){let n=e[r];if(Array.isArray(n)){for(let e of n)if(e&&E4(e,t))return!0;continue}if(n&&E4(n,t))return!0}return!1},E7={create:e=>{let{maximumStatements:t}=e.options[0];e.on(tu,r=>{if("BlockStatement"!==r.body.type||1!==r.body.body.length)return;let[n]=r.body.body;if("IfStatement"!==n.type||n.alternate||("EmptyStatement"===n.consequent.type?0:"BlockStatement"===n.consequent.type?n.consequent.body.length:1)<=t)return;let o=((e,t)=>{if(((e,t)=>{let r,n,{sourceCode:o}=t;return((e,t)=>{let{sourceCode:r}=t,{consequent:n}=e;return!(E9(n)||"BlockStatement"===n.type&&n.body.some(e=>E9(e)))&&((e,t)=>{var r;let n=(r=e.consequent,"BlockStatement"!==r.type?[]:r.body.flatMap(e=>"VariableDeclaration"===e.type&&E3.has(e.kind)?t.getDeclaredVariables(e):[]));if(0===n.length)return!0;let o=new Set(n.map(e=>e.name));return!E4(e.test,t)&&!((e,t,r)=>{let[n,o]=t.getRange(e),a=e=>e.references.some(e=>{let[a,i]=t.getRange(e.identifier);return a>=n&&i<=o&&r.has(e.identifier.name)&&!(e.resolved&&e.resolved.identifiers.some(e=>E6(e,[n,o],t)))})||e.childScopes.some(e=>a(e));return a(t.getScope(e))})(e.test,t,o)})(e,r)&&!ro(n,t)})(e,t)&&(r=E5(e,o),n=o.getRange(e.consequent),!o.getCommentsInside(e).some(e=>!E6(e,r,o)&&!E6(e,n,o)))&&!("BlockStatement"!==e.consequent.type&&o.getText(e.consequent).includes("\n"))&&0===o.getCommentsAfter(e).length})(e,t))return r=>r.replaceText(e,((e,t)=>{let{sourceCode:r}=t,n=E8(r,r.getRange(e)[0]),o=((e,t)=>{let r,n,{sourceCode:o}=t;if(r=E5(e,o),n=o.getRange(e.test),o.getCommentsInside(e).some(e=>E6(e,r,o)&&!E6(e,n,o))){let t=o.text.slice(...E5(e,o)).trimStart();return`!(${t})`}return((e,t)=>{let{sourceCode:r}=t;if("UnaryExpression"===e.type&&"!"===e.operator&&e.prefix){let n=r.getFirstToken(e),o=r.getRange(n),a=r.getRange(e),i=r.getRange(e.argument);return r.getCommentsInside(e).some(e=>r.getRange(e)[0]>=o[1]&&r.getRange(e)[1]<=i[0])?r.text.slice(o[1],a[1]).trim():eZ(e.argument,t)}let n=r.getText(e);return n8(e,"!")?`!(${n})`:`!${n}`})(e.test,t)})(e,t),a=((e,t)=>{let{consequent:r}=e;return"BlockStatement"===r.type?((e,t,r)=>{let n=r.getFirstToken(e),o=r.getLastToken(e),a=r.text.slice(r.getRange(n)[1],r.getRange(o)[0]);if(!a.includes("\n")){let e=a.trim();return e?`${E8(r,r.getRange(t)[0])}${e}`:""}let i=a.split("\n");if(i[0]?.trim()===""&&i.shift(),i.at(-1)?.trim()===""&&i.pop(),0===i.length)return"";let s=r.getTokenAfter(n,{includeComments:!0}),l=E8(r,r.getRange(t)[0]),u=s&&s!==o?E8(r,r.getRange(s)[0]):`${l} `;return i.map(e=>""===e.trim()?"":e.startsWith(u)?`${l}${e.slice(u.length)}`:`${l}${e.trimStart()}`).join("\n")})(r,e,t):`${E8(t,t.getRange(e)[0])}${t.getText(r).trim()}`})(e,r);return`if (${o}) {
|
|
18
|
+
`,pZ=e=>{var t;let r=(t=e.superClass,t?.type==="Identifier"?t.name:t?.type!=="MemberExpression"||t.computed||"Identifier"!==t.property.type?void 0:t.property.name);return!!r&&pY.test(r)},pQ=e=>"ExpressionStatement"===e.type&&"CallExpression"===e.expression.type&&tg(e.expression.callee,"super"),p0=(e,t)=>"ExpressionStatement"===e.type&&"AssignmentExpression"===e.expression.type&&"="===e.expression.operator&&tg(e.expression.left,`this.${t}`),p1=(e,t)=>({node:e,message:`The \`name\` property should be set to \`${t}\`.`}),p2=(e,t)=>e?.value&&e.value.value===t,p3=(e,t)=>"MethodDefinition"===e.type&&e.kind===t&&!e.static&&!e.computed&&"Identifier"===e.key.type&&"message"===e.key.name,p8=e=>e?.type==="Identifier"?e:e?.type==="AssignmentPattern"&&"Identifier"===e.left.type?e.left:void 0,p6=e=>p8(e)?.name==="options",p9=(e,t)=>{if("ThisExpression"===e.type||"Super"===e.type)return!0;for(let r of t[e.type]??[]){let n=e[r];if(n){if(Array.isArray(n)){if(n.some(e=>e&&p9(e,t)))return!0;continue}if(p9(n,t))return!0}}return!1},p5=e=>{let t=p8(e);return t.typeAnnotation?t.optional?"options?: ErrorOptions":"options: ErrorOptions":"options"},p4=(e,t,r)=>n=>{let o=t.arguments;if(0===o.length){let o=e.getTokenAfter(t.callee,e=>"("===e.value);return n.insertTextAfter(o,`${r}, options`)}if(1===o.length){let e;return"undefined"!==r&&(!(e=o[0])||tx(e))?n.replaceText(o[0],`${r}, options`):n.insertTextAfter(o[0],", options")}},p7=(e,t)=>e?.type==="Identifier"&&e.name===t.name;function*ce(e,t){if(!pZ(t)||null===t.id)return;let{name:r}=t.id,n=oo(r).replace(/(?:error)?$/i,"Error");r!==n&&(yield{node:t.id,message:`Invalid class name, use \`${n}\`.`});let{body:o}=t.body,{sourceCode:a}=e,i=o.find(e=>"constructor"===e.kind),s=o.find(e=>"PropertyDefinition"===e.type&&!e.static&&!e.computed&&"Identifier"===e.key.type&&"name"===e.key.name);if(!i){if(p2(s,r))return;let e=a.getRange(t.body);yield{...p1(s?.value??t,r),fix:t=>s?.value?t.replaceText(s.value,`'${r}'`):s?t.replaceText(s,pH(r).trim()):t.insertTextAfterRange([e[0],e[0]+1],pH(r))};return}let l=o.some(e=>p3(e,"get")),u=o.some(e=>p3(e,"set"));yield*function*(e,t,r){let{sourceCode:n}=e,o=t.value.body;if(!o)return;let a=o.body,{hasMessageGetter:i,hasMessageSetter:s,checkOptions:l}=r,u=a.find(e=>pQ(e)),p=a.findIndex(e=>pQ(e)),c=a.findIndex(e=>p0(e,"message")),d=i||s,m=!1;if(u){let r;if(d&&!(!(r=u.expression.arguments[0])||tx(r)))m=!0,yield{node:u,messageId:pV};else if(i&&!s&&-1!==c)m=!0,yield{node:a[c],messageId:pz};else if(!s&&-1!==c){let r=a[c];m=!0,yield{node:u,message:"Pass the error message to `super()` instead of setting `this.message`.",*fix(i){let s=r.expression.right,[l,d]=t.value.params,m=p8(l),f=1===t.value.params.length&&m&&!p6(l),g=f||p6(d);if(0===u.expression.arguments.length){if(c!==p+1||p9(s,n.visitorKeys))return;let[t]=n.getRange(u);yield i.insertTextAfterRange([t,t+6],g?`${eZ(s,e)}, options`:eZ(s,e))}else{let e;if(e=u.expression.arguments[0],n.getText(e)!==n.getText(s))return;g&&1===u.expression.arguments.length&&(yield i.insertTextAfter(u.expression.arguments[0],", options"))}f&&(yield i.insertTextAfter(l,`, ${p5(l)}`));let y=0===c?n.getRange(o)[0]:n.getRange(a[c-1])[1],[,h]=n.getRange(r);yield i.removeRange([y,h])}}}}else m=!0,yield{node:o,message:"Missing call to `super()` in constructor."};let f=function(e,t,r){let{name:n,nameProperty:o}=r,a=t.find(e=>p0(e,"name"));return a?"Literal"!==a.expression.right.type||a.expression.right.value!==n?p1(a.expression.right??e,n):void 0:p2(o,n)?void 0:p1(o?.value??e,n)}(o,a,r);if(f&&(yield f),!f&&l&&!m){let r=((e,t,r,n)=>{let o=t.value.params,a=o[0],i=p8(a);if(0===o.length||!i)return;let s=r.expression;if(p6(a)){if(!p6(s.arguments[1])){let t={node:s,messageId:pX};return p7(s.arguments[0],i)||(t.fix=p4(e.sourceCode,s,"undefined")),t}return}let l=o[1],u=!n&&"message"===i.name,p=u?i.name:"undefined";if(!l)return{node:a,messageId:pK,fix:function*(r){let{sourceCode:n}=e,o=p4(n,s,p)(r);if(!o)return;let a=t.value.params[0];yield r.insertTextAfter(a,`, ${p5(a)}`),yield o}};if(!p6(l))return{node:l,messageId:pG};if(u&&!p7(s.arguments[0],i)){let t;return{node:s,messageId:pJ,fix:(t=e.sourceCode,e=>{let r,n=s.arguments;if(0===n.length){let r=t.getTokenAfter(s.callee,e=>"("===e.value);return e.insertTextAfter(r,`${p}, options`)}if(!(r=n[0])||tx(r))return e.replaceText(n[0],1===n.length?`${p}, options`:p)})}}if(!p6(s.arguments[1]))return{node:s,messageId:pX,fix:p4(e.sourceCode,s,p)}})(e,t,u,d);r&&(yield r)}}(e,i,{name:r,nameProperty:s,hasMessageGetter:l,hasMessageSetter:u,checkOptions:r===n})}let ct="no-lonely-if",cr=e=>"IfStatement"===e.type&&!e.alternate;function cn(e,t){let r={ifToken:t.getFirstToken(e),openingParenthesisToken:t.getFirstToken(e,1)},{consequent:n}=e;return r.closingParenthesisToken=t.getTokenBefore(n),"BlockStatement"===n.type&&(r.openingBraceToken=t.getFirstToken(n),r.closingBraceToken=t.getLastToken(n)),r}let co=(e,t,r)=>r.text.slice(r.getRange(e)[1],r.getRange(t)[0]),ca=e=>e.trim()?e:"",ci=(e,t)=>/\s$/u.test(e)&&/^\s/u.test(t)?e+t.trimStart():e+t,cs=(e,t)=>co(e.ifToken,e.openingParenthesisToken,t),cl=(e,t,r)=>{let n,o=co(e.openingParenthesisToken,e.closingParenthesisToken,r);return eQ(e.test,t)?o:"LogicalExpression"===(n=e.test).type&&("||"===n.operator||"??"===n.operator)||"ConditionalExpression"===n.type||"AssignmentExpression"===n.type||"YieldExpression"===n.type||"SequenceExpression"===n.type?`(${o})`:o},cu="no-magic-array-flat-depth",cp="no-negated-condition",cc="identifier",cd="non-identifier",cm="prefer-negative-index",cf=new Map([["slice",{argumentsIndexes:[0,1],supportObjects:new Set(["Array","String","ArrayBuffer",...rE])}],["subarray",{argumentsIndexes:[0,1],supportObjects:new Set(rE)}],["splice",{argumentsIndexes:[0],supportObjects:new Set(["Array"])}],["toSpliced",{argumentsIndexes:[0],supportObjects:new Set(["Array"])}],["at",{argumentsIndexes:[0],supportObjects:new Set(["Array","String",...rE])}]]),cg=e=>{let{type:t,property:r}=e;if("MemberExpression"===t&&"Identifier"===r.type)return r.name};var cy=["node:assert","assert","node:assert/strict","assert/strict","node:async_hooks","async_hooks","node:buffer","buffer","node:child_process","child_process","node:cluster","cluster","node:console","console","node:constants","constants","node:crypto","crypto","node:dgram","dgram","node:diagnostics_channel","diagnostics_channel","node:dns","dns","node:dns/promises","dns/promises","node:domain","domain","node:events","events","node:ffi","node:fs","fs","node:fs/promises","fs/promises","node:http","http","node:http2","http2","node:https","https","node:inspector","inspector","node:inspector/promises","inspector/promises","node:module","module","node:net","net","node:os","os","node:path","path","node:path/posix","path/posix","node:path/win32","path/win32","node:perf_hooks","perf_hooks","node:process","process","node:querystring","querystring","node:quic","node:readline","readline","node:readline/promises","readline/promises","node:repl","repl","node:sea","node:sqlite","node:stream","stream","node:stream/consumers","stream/consumers","node:stream/iter","stream/iter","node:stream/promises","stream/promises","node:stream/web","stream/web","node:string_decoder","string_decoder","node:test","node:test/reporters","node:timers","timers","node:timers/promises","timers/promises","node:tls","tls","node:trace_events","trace_events","node:tty","tty","node:url","url","node:util","util","node:util/types","util/types","node:v8","v8","node:vm","vm","node:wasi","wasi","node:worker_threads","worker_threads","node:zlib","zlib","node:zlib/iter","zlib/iter"];function ch(t){if("string"!=typeof t)throw TypeError("Expected a string");return(e??=new Set(cy)).has(t)}let cx="prefer-node-protocol",cb="node:",cE="consistent-date-clone/error",cD="no-accessor-recursion/error",cS=e=>"Identifier"===e.type||"PrivateIdentifier"===e.type,cv=(e,t)=>["type","name"].every(r=>e[r]===t[r]),cC=(e,t)=>"MemberExpression"===e.parent.type&&e.parent.object===e&&!e.parent.computed&&cS(e.parent.property)&&cv(e.parent.property,t.key),cA="error/calculate-dirname",cT="error/calculate-filename";function cw(e,{modules:t,functionName:r,sourceCode:n}){if(!e7(e,{optional:!1,argumentsLength:1}))return!1;let o=new Set;return function e(t,i){if("MemberExpression"===t.type)return!!("property"===i&&tc(t,{property:r,computed:!1,optional:!1}))&&e(t.object,"module");if("CallExpression"===t.type)return"module"===i&&td(t,{object:"process",method:"getBuiltinModule",argumentsLength:1,optionalMember:!1,optionalCall:!1})&&a(t.arguments[0]);if("Identifier"!==t.type||o.has(t))return!1;o.add(t);let s=ei(n.getScope(t),t);return!!s&&1===s.defs.length&&function(t,n){if("ImportBinding"===t.type){if(!a(t.parent.source))return!1;let e=t.node;return"module"===n?e?.type==="ImportDefaultSpecifier"||e?.type==="ImportNamespaceSpecifier":e?.type==="ImportSpecifier"&&e.imported.name===r}return"Variable"===t.type&&function t(n,o){let{parent:a}=n;return"VariableDeclarator"===a.type?!!a.init&&a.id===n&&"VariableDeclaration"===a.parent.type&&"const"===a.parent.kind&&e(a.init,o):"Property"===a.type&&!!("property"===o&&a.value===n&&!a.computed&&"Identifier"===a.key.type&&a.key.name===r)&&t(a.parent,"module")}(t.name,n)}(s.defs[0],i)}(e.callee,"property");function a(e){return e?.type==="Literal"&&t.has(e.value)}}function ck(e,t){return cw(e,{modules:new Set(["url","node:url"]),functionName:"fileURLToPath",sourceCode:t})}function cI(e,t){return cw(e,{modules:new Set(["path","node:path"]),functionName:"dirname",sourceCode:t})}let cj="no-unnecessary-array-flat-depth",cF="no-unnecessary-array-splice-count",cB="no-useless-error-capture-stack-trace/error",cR="prefer-class-fields/error",c$="prefer-class-fields/suggestion",cP="prefer-bigint-literals/error",cL="prefer-bigint-literals/suggestion",cN="prefer-classlist-toggle/error",cM="prefer-classlist-toggle/suggestion",cO=e=>tc(e,{property:"classList",computed:!1}),cq=(e,t,r)=>{let n={node:r??e,messageId:cN};return"IfStatement"===e.type||ti(e)||ti(e.parent)?n.fix=t:n.suggest=[{messageId:cM,fix:t}],n},cU=(e,t,r)=>{let{sourceCode:n}=t,o=eZ(e,t);return r?(!eQ(e,n)&&n8(e,"!")&&(o=`(${o})`),o=`!${o}`):(eQ(e,n)||"SequenceExpression"!==e.type||(o=`(${o})`),o)},cW=(e,t)=>td(e,{methods:t,argumentsLength:1,optionalCall:!1,optionalMember:!1})&&cO(e.callee.object),c_=(e,t)=>tQ(e.callee.object,t.callee.object)&&tQ(e.arguments[0],t.arguments[0]),cV=(e,t,r)=>t?("ChainExpression"===e.type&&(e=e.expression),cW(e,["contains"])&&c_(e,r))?e:void 0:"UnaryExpression"===e.type&&"!"===e.operator&&e.prefix?cV(e.argument,!t,r):void 0,cz="require-module-attributes",cK="error",cG="suggestion/array",cJ="suggestion/object",cX="suggestion/object-assign",cY="suggestion/set",cH="suggestion/map",cZ=(e,t,r)=>{let{sourceCode:n}=r,o=rd(e);return t.some(e=>{let t=n.getRange(e);return o.some(e=>{let[r,o]=n.getRange(e);return r>=t[0]&&o<=t[1]})})};function cQ(e,t){if(!te(e,{names:t,maximumArguments:1}))return!1;let[r]=e.arguments;return!r||"ArrayExpression"===r.type}function*c0(e,t,r){let n=!ep(t.sourceCode.getTokenBefore(e));yield oq(e,t,r,n)}function c1(e,t,r,n){let{sourceCode:o}=e,[a,i]=o.getLastTokens(r,2),s=("ArrayExpression"===r.type?r.elements:r.properties).length>0&&!eu(a);return t.insertTextBefore(i,`${s?",":""} ${n}`)}function*c2({context:e,fixer:t,newExpression:r,elementsText:n,nextExpressionStatement:o}){if(tJ(r,e)){let[o]=r.arguments;if(o)yield c1(e,t,o,n);else{let{openingParenthesisToken:o}=tJ(r,e)?tX(r,e):{};yield t.insertTextAfter(o,`[${n}]`)}}else yield t.insertTextAfter(r,`([${n}])`);yield*c0(o,e,t)}let c3=[{testValue:e=>e?.type==="ArrayExpression",getProblematicNode({context:e,variable:t,nextExpressionStatement:r}){let n=r.expression;if(td(n,{object:t.name,methods:["push","unshift"],optionalMember:!1,optionalCall:!1})&&n.arguments.length>0&&!cZ(t,n.arguments,e))return n},getProblem(e,t){let{context:r,assignType:n,getFix:o}=t,{sourceCode:a}=r,i=e.callee,s=i.property,l={node:i,messageId:cK,data:{objectType:"array"}},u="unshift"===s.name,p=o(t,{callExpression:e,isPrepend:u});return e.arguments.some(e=>eP(e,a))?l.suggest=[{messageId:cG,fix:p,data:{operation:u?"Prepend":"Append",assignType:n}}]:l.fix=p,l},getFix:({context:e,valueNode:t,nextExpressionStatement:r},{callExpression:n,isPrepend:o})=>function*(a){let i=tY(e,n,!1);yield o?a.insertTextAfter(e.sourceCode.getFirstToken(t),`${i}, `):c1(e,a,t,i),yield c0(r,e,a)}},{testValue:e=>e?.type==="ObjectExpression",getProblematicNode({context:e,variable:t,nextExpressionStatement:r}){let n=r.expression;if(!("AssignmentExpression"===n.type&&"="===n.operator&&tc(n.left,{object:t.name,optional:!1})))return;let o=n.right,a=n.left,{property:i}=a;if(!cZ(t,a.computed?[i,o]:[o],e))return n},getProblem(e,t){let{context:r,assignType:n,getFix:o}=t,{sourceCode:a}=r,{left:i,right:s}=e,{property:l}=i,u=a.getTokenAfter(i,t=>"Punctuator"===t.type&&t.value===e.operator),p={node:e,loc:{start:a.getLoc(e).start,end:a.getLoc(u).end},messageId:cK,data:{objectType:"object"}},c=o(t,{assignmentExpression:e,memberExpression:i,property:l,value:s});return i.computed&&eP(l,a)||eP(s,a)?p.suggest=[{messageId:cJ,data:{assignType:n},fix:c}]:p.fix=c,p},getFix:({context:e,valueNode:t,nextExpressionStatement:r},{memberExpression:n,property:o,value:a})=>function*(i){let s=eZ(o,e);n.computed&&(s=`[${s}]`);let l=eZ(a,e),u=`${s}: ${l},`,[p,c]=e.sourceCode.getLastTokens(t,2),d=t.properties.length>0&&!eu(p);yield i.insertTextBefore(c,`${d?",":""} ${u}`),yield c0(r,e,i)}},{testValue:e=>e?.type==="ObjectExpression",getProblematicNode({context:e,variable:t,nextExpressionStatement:r}){let n=r.expression;if(!td(n,{object:"Object",method:"assign",minimumArguments:2,optionalMember:!1,optionalCall:!1}))return;let[o,a]=n.arguments;if(!("Identifier"!==o.type||o.name!==t.name||"SpreadElement"===a.type||cZ(t,[a],e)))return n},getProblem(e,t){let{context:r,assignType:n,getFix:o}=t,{sourceCode:a}=r,[,i]=e.arguments,s={node:e.callee,messageId:cK,data:{objectType:"object"}},l=o(t,{callExpression:e,firstValue:i});return eP(i,a)?s.suggest=[{messageId:cX,data:{description:"ObjectExpression"===i.type?"Move properties to":"Spread properties in",assignType:n},fix:l}]:s.fix=l,s},getFix:({context:e,valueNode:t,nextExpressionStatement:r},{callExpression:n,firstValue:o})=>function*(a){let i;("ObjectExpression"===o.type?o.properties.length>0&&(i=function(e,t){let{sourceCode:r}=t,n=r.getFirstToken(e),[o,a]=r.getLastTokens(e,2),[,i]=r.getRange(n),[s]=r.getRange(eu(o)?o:a);return r.text.slice(i,s)}(o,e)):i=`...${eZ(o,e)}`,i&&(yield c1(e,a,t,i)),2!==n.arguments.length)?yield ok(a,o,e):yield c0(r,e,a)}},{testValue:e=>cQ(e,["Set","WeakSet"]),getProblematicNode({context:e,variable:t,nextExpressionStatement:r}){let n=r.expression;if(("ChainExpression"===n.type&&(n=n.expression),td(n,{object:t.name,method:"add",argumentsLength:1,optionalMember:!1,optionalCall:!1}))&&!cZ(t,n.arguments,e))return n},getProblem(e,t){let{context:r,assignType:n,valueNode:o,getFix:a}=t,{sourceCode:i}=r,s={node:e.callee,messageId:cK,data:{objectType:`\`${o.callee.name}\``}},l=a(t,{callExpression:e,newExpression:o});return e.arguments.some(e=>eP(e,i))?s.suggest=[{messageId:cY,data:{assignType:n},fix:l}]:s.fix=l,s},getFix:({context:e,nextExpressionStatement:t},{callExpression:r,newExpression:n})=>o=>{let a=tY(e,r,!1);return c2({context:e,fixer:o,newExpression:n,elementsText:a,nextExpressionStatement:t})}},{testValue:e=>cQ(e,["Map","WeakMap"]),getProblematicNode({context:e,variable:t,nextExpressionStatement:r}){let n=r.expression;if(td(n,{object:t.name,method:"set",argumentsLength:2,optionalCall:!1})&&!cZ(t,n.arguments,e))return n},getProblem(e,t){let{context:r,assignType:n,valueNode:o,getFix:a}=t,{sourceCode:i}=r,s={node:e.callee,messageId:cK,data:{objectType:`\`${o.callee.name}\``}},l=a(t,{callExpression:e,newExpression:o});return e.arguments.some(e=>eP(e,i))?s.suggest=[{messageId:cH,data:{assignType:n},fix:l}]:s.fix=l,s},getFix:({context:e,nextExpressionStatement:t},{callExpression:r,newExpression:n})=>o=>{let a=tY(e,r,!1);return c2({context:e,fixer:o,newExpression:n,elementsText:`[${a}]`,nextExpressionStatement:t})}}],c8="no-useless-collection-argument/error",c6="no-useless-collection-argument/suggestion",c9="prefer-response-static-json",c5=/([\p{Ll}\d])(\p{Lu})/gu,c4=/(\p{Lu})([\p{Lu}][\p{Ll}])/gu,c7=/(\d)\p{Ll}|(\p{L})\d/u,de=/[^\p{L}\d]+/giu,dt="$1\0$2";function dr(e){let t=e.trim();t=(t=t.replace(c5,dt).replace(c4,dt)).replace(de,"\0");let r=0,n=t.length;for(;"\0"===t.charAt(r);)r++;if(r===n)return[];for(;"\0"===t.charAt(n-1);)n--;return t.slice(r,n).split(/\0/g)}function dn(e){let t=dr(e);for(let e=0;e<t.length;e++){let r=t[e],n=c7.exec(r);if(n){let o=n.index+(n[1]??n[2]).length;t.splice(e,1,r.slice(0,o),r.slice(o))}}return t}function da(e,t){let[r,n,o]=dc(e,t);return r+n.map(dl(t?.locale)).join(t?.delimiter??" ")+o}function di(e,t){var r,n;let[o,a,i]=dc(e,t),s=dl(t?.locale),l=du(t?.locale),u=t?.mergeAmbiguousCharacters?(r=s,n=l,e=>`${n(e[0])}${r(e.slice(1))}`):dp(s,l);return o+a.map((e,t)=>0===t?s(e):u(e,t)).join(t?.delimiter??"")+i}function ds(e,t){let[r,n,o]=dc(e,t),a=dp(dl(t?.locale),du(t?.locale));return r+n.map(a).join("")+o}function dl(e){return!1===e?e=>e.toLowerCase():t=>t.toLocaleLowerCase(e)}function du(e){return!1===e?e=>e.toUpperCase():t=>t.toLocaleUpperCase(e)}function dp(e,t){return(r,n)=>{let o=r[0];return(n>0&&o>="0"&&o<="9"?"_"+o:t(o))+e(r.slice(1))}}function dc(e,t={}){let r=t.split??(t.separateNumbers?dn:dr),n=t.prefixCharacters??"",o=t.suffixCharacters??"",a=0,i=e.length;for(;a<e.length;){let t=e.charAt(a);if(!n.includes(t))break;a++}for(;i>a;){let t=i-1,r=e.charAt(t);if(!o.includes(r))break;i=t}return[e.slice(0,a),r(e.slice(a,i)),e.slice(i)]}let dd="filename-case",dm="directory-case",df="filename-extension",dg=e=>!/^[\w-]$/.test(e),dy=new Set(["index.js","index.mjs","index.cjs","index.ts","index.tsx","index.vue"]),dh=new Intl.ListFormat("en-US",{type:"disjunction"}),dx=/^[\da-z]+$/i,db=/^[A-Z]{3,}(?=\d*[A-Z](?:[a-z]|\d+[a-z]))/,dE=e=>e>="0"&&e<="9",dD=e=>e>="a"&&e<="z",dS=e=>e>="A"&&e<="Z",dv={camelCase:{fn:di,name:"camel case"},camelCaseWithAcronyms:{fn:function(e){return!function(e){if(!dD(e[0]))return!1;for(let t=1;t<e.length;t++){let r=e[t];if(dD(r)||dE(r))continue;if(!dS(r))return!1;let n=t;for(;dS(e[t+1]);)t++;if(t!==n){if(dD(e[t+1])){t--;continue}for(;dE(e[t+1]);)t++;if(t===e.length-1)return!0;if(!dS(e[t+1]))return!1}}return!0}(e)?di(e):e},name:"camel case with acronyms"},kebabCase:{fn:function(e,t){return da(e,{delimiter:"-",...t})},name:"kebab case"},snakeCase:{fn:function(e,t){return da(e,{delimiter:"_",...t})},name:"snake case"},pascalCase:{fn:function(e){if(dx.test(e)){let t=db.exec(e)?.[0],r=t&&e.slice(t.length);if(r&&ds(r)===r)return e}return ds(e)},name:"pascal case"}};function dC(e,t){return e.filter(({ignored:e})=>!e).every(({word:e})=>t.some(t=>t(e)===e))}function dA(e,t,{leading:r,trailing:n}){let{samples:o}=function(e,t=1/0){let r=e.reduce((e,{length:t})=>e*t,1),n=Array.from({length:Math.min(r,t)},(t,r)=>{let n=r,o=[];for(let t=e.length-1;t>=0;t--){let r=e[t],{length:a}=r,i=n%a;n=(n-i)/a,o.unshift(r[i])}return o});return{total:r,samples:n}}(e.map(({word:e,ignored:r})=>r?[e]:t.map(t=>t(e))));return[...new Set(o.map(e=>`${r}${e.join("")}${n}`))]}let dT=/^(?<leading>_+)(?<tailing>.*)$/;function dw(e){let t,{leading:r="",tailing:n=e}=(dT.exec(e)||{groups:{}}).groups,o=[];for(let e of n){let r=dg(e);t?.ignored===r?t.word+=e:(t={word:e,ignored:r},o.push(t))}return{leading:r,words:o}}function dk(e){let t;return t=e.map(e=>dv[e].name),dh.format(t)}let dI=[{description:"The rule options.",anyOf:[{properties:{case:{enum:["camelCase","camelCaseWithAcronyms","snakeCase","kebabCase","pascalCase"],description:"The filename and directory name case style."},ignore:{type:"array",uniqueItems:!0,description:"Path segment patterns to ignore."},multipleFileExtensions:{type:"boolean",description:"Whether to treat additional, dot-separated parts of a filename as file extensions."},checkDirectories:{type:"boolean",description:"Whether to check directory names."}},additionalProperties:!1},{properties:{cases:{properties:{camelCase:{type:"boolean",description:"Whether to allow camelCase filenames and directory names."},camelCaseWithAcronyms:{type:"boolean",description:"Whether to allow camelCase filenames and directory names with acronym segments."},snakeCase:{type:"boolean",description:"Whether to allow snake_case filenames and directory names."},kebabCase:{type:"boolean",description:"Whether to allow kebab-case filenames and directory names."},pascalCase:{type:"boolean",description:"Whether to allow PascalCase filenames and directory names."}},additionalProperties:!1,description:"The allowed filename and directory name case styles."},ignore:{type:"array",uniqueItems:!0,description:"Path segment patterns to ignore."},multipleFileExtensions:{type:"boolean",description:"Whether to treat additional, dot-separated parts of a filename as file extensions."},checkDirectories:{type:"boolean",description:"Whether to check directory names."}},additionalProperties:!1}]}],dj="consistent-template-literal-escape",dF="iterable-accepting",dB="for-of",dR="yield-star",d$="spread",dP="iterator-method",dL="iterable-accepting/suggestion",dN="iterator-method/suggestion",dM=["every","find","forEach","some"],dO="reduce",dq=e=>td(e,{method:"toArray",argumentsLength:0,optionalCall:!1,optionalMember:!1}),dU="prefer-simple-condition-first",dW="prefer-simple-condition-first/suggestion";function d_(e){return"Identifier"===e.type||"Literal"===e.type||"UnaryExpression"===e.type&&("-"===e.operator||"+"===e.operator)&&"Literal"===e.argument.type&&"number"==typeof e.argument.value}function dV(e){return"Identifier"===e.type||("UnaryExpression"===e.type&&"!"===e.operator?dV(e.argument):"BinaryExpression"===e.type&&("==="===e.operator||"!=="===e.operator)?d_(e.left)&&d_(e.right)&&("Identifier"===e.left.type||"Identifier"===e.right.type):"LogicalExpression"===e.type&&dV(e.left)&&dV(e.right))}let dz=new Set(["AssignmentExpression","UpdateExpression","TaggedTemplateExpression","AwaitExpression","YieldExpression","ImportExpression"]);function dK(e,t,{operator:r,property:n}){let o=eQ(e,t),a=o?eZ(e,t):t.sourceCode.getText(e);return!o&&n6(e,{operator:r,property:n})&&(a=`(${a})`),a}let dG="switch-case-break-position",dJ=new Set(["BreakStatement","ReturnStatement","ContinueStatement","ThrowStatement"]),dX="first-child",dY="first-element-child",dH="query-selector",dZ="closest",dQ="merge-query-selector",d0="suggestion-first-child",d1="suggestion-first-element-child",d2="suggestion-merge-query-selector",d3={method:"querySelector",argumentsLength:1,optionalCall:!1,optionalMember:!1},d8=(e,t)=>tc(e,{property:t,optional:!1,computed:!1}),d6=e=>"MemberExpression"===e.type&&!e.optional&&e.computed&&e8(e.property)&&Number.isSafeInteger(e.property.value)&&e.property.value>=0,d9=(e,t)=>t.getCommentsInside(e).length>0,d5=(e,t,r,n)=>{let{sourceCode:o}=n;if(d9(e,o))return;let[,a]=eH(e.object,n),[,i]=o.getRange(e);return[{messageId:r,fix:r=>[r.replaceText(e.object.property,t),r.removeRange([a,i])]}]},d4=e=>tc(e,{property:"parentElement",optional:!1,computed:!1}),d7=e=>void 0!==e3(e),me=e=>td(e,d3),mt=new Set(["FunctionDeclaration","ClassDeclaration","TSTypeAliasDeclaration","TSInterfaceDeclaration","TSEnumDeclaration"]),mr=new Set(["AccessorProperty","MethodDefinition","PropertyDefinition","TSAbstractAccessorProperty","TSAbstractMethodDefinition","TSAbstractPropertyDefinition","TSMethodSignature","TSPropertySignature"]),mn=e=>{let t="";return"Variable"===e.type?t=e.node.init.arguments[0].value:"ImportBinding"===e.type&&(t=e.parent.source.value),!t.includes("node_modules")&&(t.startsWith(".")||t.startsWith("/"))},mo="consistent-compound-words/error",ma="consistent-compound-words/rename",{isIdentifierName:mi}=tL,ms={backGround:"background",callBack:"callback",checkBox:"checkbox",clipBoard:"clipboard",codeBase:"codebase",dataBase:"database",downLoad:"download",feedBack:"feedback",foreGround:"foreground",frameWork:"framework",headLine:"headline",keyBoard:"keyboard",keyFrame:"keyframe",lifeCycle:"lifecycle",metaData:"metadata",midPoint:"midpoint",nameSpace:"namespace",overRide:"override",passWord:"password",payLoad:"payload",placeHolder:"placeholder",preView:"preview",screenShot:"screenshot",sideBar:"sidebar",subClass:"subclass",subDirectory:"subdirectory",subDomain:"subdomain",subMenu:"submenu",subProcess:"subprocess",subString:"substring",subTree:"subtree",subType:"subtype",subTitle:"subtitle",timeOut:"timeout",timeStamp:"timestamp",toolBar:"toolbar",toolKit:"toolkit",toolTip:"tooltip",touchScreen:"touchscreen",unSubscribe:"unsubscribe",underScore:"underscore",upLoad:"upload",userName:"username",viewPort:"viewport",webCam:"webcam",webHook:"webhook",webSite:"website",weekEnd:"weekend",whiteSpace:"whitespace",wildCard:"wildcard",workFlow:"workflow",workSpace:"workspace"},ml=new Set(String.raw`\^$.*+?()[]{}|`),mu=e=>{let t="";for(let r of e)t+=ml.has(r)?`\\${r}`:r;return t},mp=String.raw`(?=$|[\d_$]|\p{Uppercase_Letter})`,mc=(e,{replacementRegExp:t,replacements:r,allowList:n})=>{if(!t||e===e.toUpperCase()||n.has(e))return;let o=e.replaceAll(t,e=>((e,t)=>{let r=t.get(e)??t.get(oa(e));if(r){let t;return(t=e[0])===t.toUpperCase()?oo(r):oa(r)}})(e,r));if(o!==e)return o},md=(e,t)=>({node:e,messageId:mo,data:{name:e.name,replacement:t}}),mm={type:"array",additionalItems:!1,items:[{type:"object",additionalProperties:!1,properties:{checkProperties:{type:"boolean",description:"Whether to check property names."},checkVariables:{type:"boolean",description:"Whether to check variable names."},checkDefaultAndNamespaceImports:{anyOf:[{type:"boolean"},{enum:["internal"]}],description:"Whether to check default and namespace import names."},checkShorthandImports:{anyOf:[{type:"boolean"},{enum:["internal"]}],description:"Whether to check shorthand import names."},checkShorthandProperties:{type:"boolean",description:"Whether to check shorthand property names."},extendDefaultReplacements:{type:"boolean",description:"Whether to extend the default replacements."},replacements:{$ref:"#/definitions/replacements",description:"Custom compound word replacements."},allowList:{$ref:"#/definitions/trueObject",description:"Custom allow list of names."}}}],definitions:{replacements:{type:"object",propertyNames:{minLength:1},additionalProperties:{anyOf:[{enum:[!1]},{type:"string",minLength:1}]}},trueObject:{type:"object",propertyNames:{minLength:1},additionalProperties:{enum:[!0]}}}},mf="no-blob-to-file",mg="suggestion";function my(e,t){let r=ei(t.sourceCode.getScope(e),e);return!r||0===r.defs.length}function mh(e,t){if(e?.type!=="Identifier")return;let r=ei(t.sourceCode.getScope(e),e),n=r?.defs[0],o=n?.node;if(n?.type==="Variable"&&"const"===n.kind&&o?.type==="VariableDeclarator")return o}let mx="no-canvas-to-image",mb=e=>{for(;e?.type==="AwaitExpression";)e=e.argument;return e};function mE(e,t){if(e=mb(e),e?.type!=="Identifier")return e;let r=ei(t.getScope(e),e);if(!r||1!==r.identifiers.length||2!==r.references.length)return;let[n]=r.identifiers;if("VariableDeclarator"===n.parent.type&&n.parent.id===n&&"VariableDeclaration"===n.parent.parent.type&&"const"===n.parent.parent.kind&&!(t.getRange(n)[0]>t.getRange(e)[0]))return mb(n.parent.init)}let mD=e=>e.toLowerCase().includes("canvas"),mS="replace-one-element",mv="insert-at-negative-one",mC="suggestion-replace-one-element",mA="suggestion-insert-at-negative-one";function mT(e){return"Identifier"===e.type||"ThisExpression"===e.type||"MemberExpression"===e.type&&!e.computed&&!e.optional&&mT(e.object)}let mw=(e,t)=>t.getCommentsInside(e).length>0,mk="no-duplicate-set-values",mI="first-match",mj="id-selector",mF="length-check",mB="query-selector-all-nullish",mR="query-selector-undefined",m$=e=>td(e,{method:"querySelector",argumentsLength:1,optionalCall:!1,optionalMember:!1})&&!nT(e.callee.object),mP=e=>td(e,{method:"querySelectorAll",argumentsLength:1,optionalCall:!1,optionalMember:!1})&&!nT(e.callee.object),mL=e=>{let t,r;return t=e,r=mP,"MemberExpression"===t.type&&t.computed&&!t.optional&&r(t.object)&&e0(t.property,0)},mN=e=>{let t,r;return t=e,r=mP,td(t,{methods:["at","item"],argumentsLength:1,optionalCall:!1,optionalMember:!1})&&r(t.callee.object)&&e0(t.arguments[0],0)},mM=e=>r3(e)||("ForInStatement"===e.parent.type||"ForOfStatement"===e.parent.type)&&e.parent.left===e,mO=(e,t,r,n)=>{let[,o]=eH(t,n),[,a]=r.getRange(e);return r.getAllComments().some(e=>{let[t,n]=r.getRange(e);return t>=o&&n<=a})},mq=(e,t,r)=>{if("Identifier"!==e.type)return;let n=ei(t.getScope(e),e);if(!n||1!==n.defs.length)return;let[o]=n.defs;if("Variable"===o.type&&"const"===o.parent.kind&&o.node.id===o.name&&r(o.node.init))return o.node.init},mU=(e,t)=>{let{sourceCode:r}=t,{node:n,isNegative:o}=function(e,t){let r=!1;for(;;)if(tS(e))r=!r,e=e.parent;else if(tv(e,t))e=e.parent;else break;return{node:e,isNegative:r}}(e,t);if(!tT(n)||(mP(e)?!e:!mq(e,r,mP)))return;let a=r.getText(e);return{node:e,messageId:mF,fix:((e,t,r)=>{let[n,o]=r.getRange(e),[a,i]=r.getRange(t);return r.getAllComments().some(e=>{let[t,s]=r.getRange(e);return t>=n&&s<=o&&(s<=a||t>=i)})})(n,e,r)?void 0:e=>e.replaceText(n,`${a}.length ${o?"=== 0":"> 0"}`)}},mW=(e,t,r)=>({node:e,messageId:mI,*fix(n){yield n.replaceText(t.callee.property,"querySelector"),yield"MemberExpression"===e.type?oM(n,e,r):oO(n,e,r)}}),m_=(e,t)=>e9(e)||tx(e)&&t.isGlobalReference(e),mV=(e,t,r)=>{let{left:n,operator:o,right:a}=e;return["==","===","!=","!=="].includes(o)?(t(n)?n:mq(n,r,t))&&m_(a,r)?{node:n,value:a}:(t(a)?a:mq(a,r,t))&&m_(n,r)?{node:a,value:n}:void 0:void 0},mz="no-invalid-file-input-accept/invalid",mK="no-invalid-file-input-accept/static",mG="no-invalid-file-input-accept/normalize",mJ=new Set(["audio/*","image/*","video/*"]),mX=new Map([["application/x-rar-compressed","application/vnd.rar"],["application/x-zip-compressed","application/zip"],["image/jpg","image/jpeg"],["image/svg","image/svg+xml"],["image/x-icon","image/vnd.microsoft.icon"]]),mY=/&(?:#\d+|#x[\da-f]+|[a-z][\da-z]*);/iv,mH=e=>{for(let t of e)if(""===t.trim()||","===t||"/"===t||"*"===t||"$"===t||"{"===t||"}"===t)return!0;return!1},mZ=e=>{if(e.startsWith("."))return e.length>1&&!mH(e.slice(1))?{replacement:e.toLowerCase()}:{reason:"File extensions must start with `.` and cannot contain whitespace, commas, slashes, wildcards, or template markers."};if(!e.includes("/"))return e.length>0&&"."!==e[0]&&!mH(e)?{replacement:`.${e.toLowerCase()}`}:{reason:"File extensions must start with `.` and cannot contain whitespace, commas, slashes, wildcards, or template markers."};let t=e.toLowerCase();if(t.includes("*"))return mJ.has(t)?{replacement:t}:{reason:"Wildcard MIME types must be `audio/*`, `image/*`, or `video/*`."};try{let{essence:t}=new m.MIMEType(e);return{replacement:mX.get(t)??t}}catch{return{reason:"MIME types must use valid `type/subtype` syntax."}}},mQ=e=>{if("JSXIdentifier"===e.type)return e.name},m0=(e,t)=>e.attributes.find(e=>"JSXAttribute"===e.type&&mQ(e.name)===t),m1=(e,t)=>{let r=e.sourceCode.getScope(t),n=ew(t,r)?.value;if("string"==typeof n)return n},m2=e=>">"===e||""===e.trim(),m3=(e,t,r)=>{for(;t<r&&""===e[t].trim();)t++;return t},m8=(e,t,r)=>t>=r||">"===e[t]||"/"===e[t]&&">"===e[t+1],m6=(e,t,r)=>{let n=t;for(;t<r&&""!==e[t].trim()&&"="!==e[t]&&">"!==e[t]&&("/"!==e[t]||">"!==e[t+1]);)t++;return{name:e.slice(n,t).toLowerCase(),index:t}},m9=(e,t,r)=>{let n='"'===e[t]||"'"===e[t]?e[t]:void 0;if(n){let o=t+1;for(t=o;t<r&&e[t]!==n;)t++;return{value:e.slice(o,t),valueRange:[o,t],isQuoted:!0,index:t+1}}let o=t;for(;t<r&&!m2(e[t]);)t++;return{value:e.slice(o,t),valueRange:[o,t],isQuoted:!1,index:t}},m5=(e,t,r)=>{let n=e.sourceCode.text,o=e.sourceCode.getRange(t.openStart)[1],a=e.sourceCode.getRange(t.openEnd)[1],i=o;for(;i<a&&(i=m3(n,i,a),!m8(n,i,a));){let e=m6(n,i,a);if(i=m3(n,e.index,a),"="!==n[i]){if(e.name===r)return{missing:!0};continue}i=m3(n,++i,a);let t=m9(n,i,a);if(i=t.index,e.name===r)return t}},m4=({valueInfo:e,fix:t})=>{if(e.missing)return{node:e.node,messageId:mz,data:{reason:"The `accept` attribute must have a value."}};if(e.dynamic)return{node:e.node,messageId:mK};let r=(e=>{let t=e.split(","),r=new Set,n=[];for(let e of t){let t=e.trim();if(0===t.length)return{reason:"Empty entries are not allowed."};let o=mZ(t);if(o.reason)return o;let{replacement:a}=o;r.has(a)||(r.add(a),n.push(a))}let o=n.join(", ");return o===e?{}:{replacement:o}})(e.value),n=r.replacement&&e.fixable&&(!e.isReplacementFixable||e.isReplacementFixable(r.replacement));return(({valueNode:e,checkResult:t,fix:r})=>{if(t.reason)return{node:e,messageId:mz,data:{reason:t.reason}};if(t.replacement){let n={node:e,messageId:mG,data:{replacement:t.replacement}};return r&&(n.fix=r),n}})({valueNode:e.node,checkResult:r,fix:n?t(r.replacement):void 0})},m7="after-suspension",fe="in-nested-function",ft=/^(?:e|event|evt|[a-z][\dA-Za-z]*Event)$/u,fr=e=>{for(let t=e.parent;t;t=t.parent)if(tl(t))return t},fn="no-unnecessary-nested-ternary";function fo(e,t,r){return r.getText(e)===r.getText(t)}function fa(e,t,r,n){let o=eZ(e,t);return!eQ(e,t)&&n6(e,{operator:r,property:n})&&(o=`(${o})`),o}function fi(e,t){let r=eZ(e,t);return!eQ(e,t)&&nQ(e)&&(r=`(${r})`),r}function fs(e,t,r){let n={node:t,messageId:fn};return 0===e.sourceCode.getCommentsInside(t).length&&(n.fix=n=>n.replaceText(t,function({context:e,node:t,left:r,operator:n,right:o,consequent:a,alternate:i}){let{sourceCode:s}=e,l=[fa(r,e,n,"left"),fa(o,e,n,"right")].join(` ${n} `),u=`${l} ? ${fi(a,e)} : ${fi(i,e)}`;return nW(s.getTokenBefore(t),e,u)&&(u=`;${u}`),u}({context:e,node:t,...r}))),n}let fl="no-unused-array-method-return",fu=new Set(["at","concat","entries","every","filter","find","findIndex","findLast","findLastIndex","flat","flatMap","includes","indexOf","join","keys","lastIndexOf","map","some","slice","toReversed","toSorted","toSpliced","values","with"]),fp=/^\p{Uppercase_Letter}/v,fc=Symbol("uncertainValue"),fd=new Set(["BigInt","Boolean","Number","RegExp","String"]),fm=(e,t,r)=>"Identifier"===e.type&&e.name===t&&r.sourceCode.isGlobalReference(e),ff="prefer-array-last-methods",fg="replace",fy=new Map([["find","findLast"],["findIndex","findLastIndex"],["indexOf","lastIndexOf"],["reduce","reduceRight"]]),fh=["reverse","toReversed"],fx="prefer-math-abs",fb=new Set([">",">=","<","<="]),fE={">":"<",">=":"<=","<":">","<=":">="},fD={">":"<",">=":"<="};function fS(e){return"TSBigIntKeyword"===e.type||"TSLiteralType"===e.type&&e5(e.literal)||"TSTypeAnnotation"===e.type&&fS(e.typeAnnotation)||"TSUnionType"===e.type&&e.types.some(e=>fS(e))||"TSIntersectionType"===e.type&&e.types.some(e=>fS(e))}function fv(e){return["TSAsExpression","TSTypeAssertion","TSNonNullExpression"].includes(e.type)?fv(e.expression):e}function fC(e){let t;return e5(e)||e7(e,{name:"BigInt",argumentsLength:1,optional:!1})||"UnaryExpression"===e.type&&"-"===e.operator&&fC(e.argument)||(t=function e(t){return"TSNonNullExpression"===t.type?e(t.expression):"TSAsExpression"===t.type||"TSTypeAssertion"===t.type?t.typeAnnotation:void 0}(e))&&fS(t)}function fA(e,t){return fC(e)||function(e,t){let r=fv(e);if("Identifier"!==r.type)return!1;let n=ei(t.sourceCode.getScope(r),r);return n?.defs.some(e=>"Parameter"===e.type?e.name.typeAnnotation&&fS(e.name.typeAnnotation)||"AssignmentPattern"===e.name.parent.type&&fC(e.name.parent.right):"Variable"===e.type&&(e.node.id.typeAnnotation&&fS(e.node.id.typeAnnotation)||e.node.init&&fC(e.node.init)))??!1}(e,t)}function fT(e,t){return"UnaryExpression"===e.type&&"-"===e.operator?tQ(e.argument,t):"BinaryExpression"===e.type&&"-"===e.operator&&e0(e.left,0)?tQ(e.right,t):"BinaryExpression"===e.type&&"*"===e.operator&&(tQ(e.left,t)&&tm(e.right)||tm(e.left)&&tQ(e.right,t))}function fw(e,t){if(!("BinaryExpression"!==e.type||!fb.has(e.operator)||fA(e.left,t)||fA(e.right,t)))return">"===e.operator||">="===e.operator?{value:e.left,threshold:e.right,operator:e.operator}:{value:e.right,threshold:e.left,operator:fE[e.operator]}}function fk(e,t){if(!("BinaryExpression"!==e.type||!fb.has(e.operator)||fA(e.left,t)||fA(e.right,t)))return"<"===e.operator||"<="===e.operator?{value:e.left,negativeThreshold:e.right,operator:e.operator}:{value:e.right,negativeThreshold:e.left,operator:fE[e.operator]}}function fI(e,t){let r=eZ(e,t);return"SequenceExpression"===e.type?`(${r})`:r}function fj(e,t,r){let n={node:e,messageId:fx};return r&&!(t.sourceCode.getCommentsInside(e).length>0)&&(n.fix=r),n}function fF(e){return["Identifier","Literal","ThisExpression"].includes((e=fv(e)).type)}let fB="prefer-split-limit",fR=(e,t)=>{let r=ew(e,t.getScope(e));if(r&&Number.isSafeInteger(r.value)&&!(r.value<0))return r.value},f$=e=>{let t;return td(e,{method:"split",argumentsLength:1})&&(e1(t=e.arguments[0])&&""!==t.value||e6(t))},fP=(e,t,r,n)=>({node:e,messageId:fB,fix:e=>ow(e,t,String(r+1),n)}),fL="prefer-queue-microtask",fN={create:e=>{let{checkSetImmediate:t,checkSetTimeout:r}=e.options[0];e.on("MemberExpression",t=>{if(tc(t,{object:"process",property:"nextTick",computed:!1,optional:!1})&&nR(t.object,e)&&("CallExpression"!==t.parent.type||t.parent.callee!==t||!t.parent.optional))return{node:t.property,messageId:fL,data:{name:"process.nextTick()"},fix:((e,t)=>{let{parent:r}=e;if("CallExpression"===r.type&&r.callee===e&&1===r.arguments.length&&"SpreadElement"!==r.arguments[0].type&&!(t.sourceCode.getCommentsInside(e).length>0))return t=>t.replaceText(e,"queueMicrotask")})(t,e)}}),e.on("CallExpression",n=>{let o;return t&&"Identifier"===n.callee.type&&"setImmediate"===n.callee.name&&!n.optional&&n.arguments.length>0&&"SpreadElement"!==n.arguments[0].type&&!nI(n.arguments[0])&&nO(n)&&nR(n.callee,e)?{node:n.callee,messageId:fL,data:{name:"setImmediate()"},fix:(e=>{if(1===e.arguments.length)return t=>t.replaceText(e.callee,"queueMicrotask")})(n)}:r&&"Identifier"===n.callee.type&&"setTimeout"===n.callee.name&&!n.optional&&n.arguments.length>=2&&"Literal"===(o=n.arguments[1]).type&&0===o.value&&"SpreadElement"!==n.arguments[0].type&&!nI(n.arguments[0])&&nO(n)&&nR(n.callee,e)?{node:n.callee,messageId:fL,data:{name:"setTimeout()"},fix:((e,t)=>{if(2!==e.arguments.length)return;let r=((e,t)=>{let{sourceCode:r}=t,[,n]=e.arguments,o=r.getTokenBefore(n),a=r.getTokenAfter(n),i=a?.value===","?r.getTokenAfter(a):a,s=[r.getRange(o)[0],a?.value===","?r.getRange(a)[1]:r.getRange(n)[1]];if(!re(t,[s[0],r.getRange(i)[0]]))return s})(e,t);if(r)return function*(t){yield t.replaceText(e.callee,"queueMicrotask"),yield t.removeRange(r)}})(n,e)}:void 0})},meta:{type:"suggestion",docs:{description:"Prefer `queueMicrotask()` over `process.nextTick()`, `setImmediate()`, and `setTimeout(…, 0)`.",recommended:"unopinionated"},fixable:"code",schema:[{type:"object",additionalProperties:!1,properties:{checkSetImmediate:{type:"boolean",description:"Whether to also check `setImmediate()`."},checkSetTimeout:{type:"boolean",description:"Whether to also check `setTimeout(…, 0)`."}}}],defaultOptions:[{checkSetImmediate:!1,checkSetTimeout:!1}],messages:{[fL]:"Prefer `queueMicrotask()` over `{{name}}`."},languages:["js/js"]}},fM="prefer-string-pad-start-end",fO="suggest-padding-method",fq=new Set(["ArrayExpression","ArrowFunctionExpression","ClassExpression","FunctionExpression","ObjectExpression"]),fU=(e,t)=>{let r,n=((e,t)=>{if("Identifier"!==e.type)return;let r=ei(t.sourceCode.getScope(e),e),n=r?.defs[0]?.node;return n?.type==="FunctionDeclaration"||n?.type==="ClassDeclaration"?n:n?.type==="VariableDeclarator"?n.init:void 0})(e,t);return(r=ew(e,t.sourceCode.getScope(e)))&&"string"!=typeof r.value||fq.has(e.type)||fq.has(n?.type)||n?.type==="FunctionDeclaration"||n?.type==="ClassDeclaration"},fW=(e,t)=>t.sourceCode.getCommentsInside(e).length>0,f_=e=>"Literal"===e.type&&"number"==typeof e.value,fV=e=>"Literal"===e.type&&"string"==typeof e.value||"TemplateLiteral"===e.type&&0===e.expressions.length,fz=({targetNode:e,targetLengthNode:t,paddingNode:r})=>"Identifier"===e.type&&f_(t)&&fV(r),fK=(e,t)=>{if(!td(e,{method:"repeat",argumentsLength:1,optionalCall:!1,optionalMember:!1}))return;let r=e.callee.object,n=((e,t)=>{let r=ew(e,t.sourceCode.getScope(e));if("string"==typeof r?.value)return r.value})(r,t);if(n?.length===1)return{paddingNode:r,paddingString:n,widthNode:e.arguments[0]}},fG=(e,t)=>{let r,n=fK(e,t);if(!n)return;let{widthNode:o}=n;if("BinaryExpression"===o.type&&"-"===o.operator&&(r=o.right,r?.type==="MemberExpression"&&!1===r.computed&&"Identifier"===r.property.type&&"length"===r.property.name))return{...n,targetLengthNode:o.left,targetNode:o.right.object}},fJ=({method:e,targetNode:t,targetLengthNode:r,paddingNode:n,paddingString:o},a)=>{let i=eZ(t,a),s=eZ(r,a),l=(({paddingNode:e,paddingString:t},r)=>" "===t?"":`, ${eZ(e,r)}`)({paddingNode:n,paddingString:o},a);return`${i}.${e}(${s}${l})`},fX=({node:e,method:t,replacement:r,context:n,canFix:o})=>{let a={node:e,messageId:fM,data:{method:t}};return o&&!fW(e,n)&&(a.fix=function(t){let o=nW(n.sourceCode.getTokenBefore(e),n,r)?";":"";return t.replaceText(e,`${o}${r}`)}),a},fY=({node:e,method:t,replacement:r,context:n,canSuggest:o})=>{let a={node:e,messageId:fM,data:{method:t}};return o&&!fW(e,n)&&(a.suggest=[{messageId:fO,data:{method:t},fix:t=>t.replaceText(e,r)}]),a},fH="require-css-escape",fZ=["closest","matches","querySelector","querySelectorAll"],fQ=e=>e.value.cooked,f0=(e,t)=>{let r,n="";for(let r of e.quasis.slice(0,t+1)){let e=fQ(r);if(void 0===e)return!1;n+=e}if(!((r=n).lastIndexOf("[")>r.lastIndexOf("]")))return!1;for(let r of e.quasis.slice(t+1)){let e=fQ(r);if(void 0===e)break;if(e.includes("]"))return!0}return!1},f1=e=>td(e,{object:"CSS",method:"escape",argumentsLength:1,optionalCall:!1,optionalMember:!1}),f2=e=>t=>"SequenceExpression"===e.type?[t.insertTextBefore(e,"CSS.escape(("),t.insertTextAfter(e,"))")]:[t.insertTextBefore(e,"CSS.escape("),t.insertTextAfter(e,")")],f3={create:e=>{let{checkAllSelectors:t}=e.options[0];e.on("CallExpression",function*(e){if(!td(e,{methods:fZ,minimumArguments:1})||nT(e.callee.object))return;let[r]=e.arguments;if("TemplateLiteral"===r.type&&0!==r.expressions.length)for(let[e,n]of r.expressions.entries())!f1(n)&&(t||f0(r,e))&&(yield{node:n,messageId:fH,fix:f2(n)})})},meta:{type:"suggestion",docs:{description:"Require `CSS.escape()` for interpolated values in CSS selectors.",recommended:"unopinionated"},fixable:"code",schema:[{type:"object",additionalProperties:!1,properties:{checkAllSelectors:{type:"boolean",description:"Check all selector interpolations instead of only attribute selector interpolations."}}}],defaultOptions:[{checkAllSelectors:!1}],messages:{[fH]:"Use `CSS.escape()` for interpolated values in CSS selectors."},languages:["js/js"]}},f8="require-passive-events",f6=new Set(["touchstart","touchmove","touchenter","touchend","touchleave","wheel","mousewheel"]),f9=e=>e.computed||"Identifier"!==e.property.type?e1(e.property)?e.property.value:void 0:e.property.name,f5=e=>{var t,r;return"MemberExpression"===e.parent.type&&e.parent.object===e&&"MemberExpression"===(t=e.parent).type&&"preventDefault"===f9(t)&&("CallExpression"===(r=t).parent.type&&r.parent.callee===r?r.parent:"ChainExpression"===r.parent.type&&"CallExpression"===r.parent.parent.type&&r.parent.parent.callee===r.parent?r.parent.parent:void 0)},f4=e=>{if("MemberExpression"!==e.parent.type||e.parent.object!==e)return!1;let t=f9(e.parent);return t&&"preventDefault"!==t&&!r3((e=>{for(;"MemberExpression"===e.parent.type&&e.parent.object===e;)e=e.parent;return e})(e.parent))},f7="this",ge="class",gt="class-unavailable",gr="super",gn="super-class",go="super-class-unavailable",ga="suggestion",gi=new Set(["PropertyDefinition","AccessorProperty","StaticBlock","ClassBody"]),gs=new Set(["TSAsExpression","TSInstantiationExpression","TSNonNullExpression","TSSatisfiesExpression","TSTypeAssertion"]),gl=e=>"MethodDefinition"===e.parent.type&&e.parent.value===e,gu=e=>"FunctionDeclaration"===e.type||"FunctionExpression"===e.type,gp=e=>{let t=e;for(let{parent:r}=e;r;t=r,r=r.parent)if("ArrowFunctionExpression"!==r.type){if(gu(r)&&!gl(r))return;if("MethodDefinition"===r.type)return r.static&&r.value===t?r:void 0;if(gi.has(r.type))return}},gc=e=>{if(e.id)return e.id;let{parent:t}=e;if("ClassExpression"===e.type&&"VariableDeclarator"===t.type&&t.init===e&&"Identifier"===t.id.type)return t.id},gd=(e,t,r)=>ei(e.getScope(t),t)===ei(e.getScope(r),r),gm=(e,t,r)=>ei(e.getScope(t),r.name)===ei(e.getScope(r),r),gf=(e,t)=>"AssignmentExpression"===e.type&&e.left===t||"UpdateExpression"===e.type&&e.argument===t||"UnaryExpression"===e.type&&"delete"===e.operator&&e.argument===t||("ForInStatement"===e.type||"ForOfStatement"===e.type)&&e.left===t,gg=e=>{let t;return(t=e.parent,gs.has(t.type)&&t.expression===e)?e.parent:void 0},gy=e=>{let{parent:t}=e;if("MemberExpression"===t.type&&t.object===e||"ChainExpression"===t.type&&t.expression===e)return t;let r=gg(e);return r||("Property"===t.type&&t.value===e&&"ObjectPattern"===t.parent.type?t.parent:"ObjectPattern"===t.type&&t.properties.includes(e)||"ArrayPattern"===t.type&&t.elements.includes(e)||"AssignmentPattern"===t.type&&t.left===e||"RestElement"===t.type&&t.argument===e?t:void 0)},gh=e=>{let t=e;for(;t.parent;){if(gf(t.parent,t))return!0;let e=gy(t);if(!e)break;t=e}return!1},gx=e=>"MemberExpression"===e.parent.type&&e.parent.object===e,gb=e=>{let t=e;for(;t.parent;){let e=gg(t);if(!e)break;t=e}return t},gE=e=>{let t=gb(e);return"CallExpression"===t.parent.type&&t.parent.callee===t||"NewExpression"===t.parent.type&&t.parent.callee===t||"TaggedTemplateExpression"===t.parent.type&&t.parent.tag===t},gD=e=>{let t=gb(e);return gx(t)&&"PrivateIdentifier"===t.parent.property.type},gS=e=>{let t=gb(e);return"BinaryExpression"===t.parent.type&&"in"===t.parent.operator&&"PrivateIdentifier"===t.parent.left.type&&t.parent.right===t},gv=e=>e.superClass?.type==="Identifier"?e.superClass:void 0,gC=({node:e,messageId:t,source:r,replacement:n,name:o})=>({node:e,messageId:t,data:{name:o},suggest:[{messageId:ga,data:{source:r,replacement:n},fix:t=>t.replaceText("ChainExpression"===e.parent.type?e.parent:e,n)}]}),gA=(e,t,r)=>({node:e,messageId:t,data:{name:r}}),gT={create:e=>{let{sourceCode:t}=e,{preferThis:r,preferSuper:n}=e.options[0];e.on("ThisExpression",e=>{if(r||gh(e)||gE(e)||gD(e)||gS(e))return;let n=gp(e);if(!n)return;let o=gc(n.parent.parent);return o&&gm(t,e,o)?gC({node:e,messageId:ge,source:"this",replacement:o.name,name:o.name}):gA(e,gt)}),e.on("Super",e=>{if(n||gh(e))return;let r=gp(e);if(!r)return;let o=gv(r.parent.parent);return o&&gm(t,e,o)?gC({node:e,messageId:gn,source:"super",replacement:o.name,name:o.name}):gA(e,go)}),e.on("Identifier",o=>{if(!function(e,t=[]){if("Identifier"!==e.type)return!1;let r=Array.isArray(t)?t:[t];return(!(r.length>0)||!!r.includes(e.name))&&!function(e){let{parent:t}=e;switch(t.type){case"MemberExpression":return!t.computed&&t.property===e;case"FunctionDeclaration":case"FunctionExpression":return t.params.includes(e)||t.id===e;case"ArrowFunctionExpression":return t.params.includes(e);case"ClassDeclaration":case"ClassExpression":case"VariableDeclarator":case"TSDeclareFunction":case"TSEnumMember":case"TSTypeAliasDeclaration":return t.id===e;case"PropertyDefinition":case"MethodDefinition":return!t.computed&&t.key===e;case"Property":return!t.computed&&t.key===e&&("ObjectExpression"===t.parent.type||"ObjectPattern"===t.parent.type)&&t.parent.properties.includes(t)||t.value===e&&"ObjectPattern"===t.parent.type&&t.parent.properties.includes(t);case"ArrayPattern":return t.elements.includes(e);case"LabeledStatement":case"ContinueStatement":case"BreakStatement":return t.label===e;case"ImportDefaultSpecifier":case"ImportNamespaceSpecifier":return t.local===e;case"ExportAllDeclaration":return t.exported===e;case"ImportSpecifier":return t.local===e||t.imported===e;case"ExportSpecifier":return t.local===e||t.exported===e;case"TSIndexSignature":return t.parameters.includes(e);case"TSTypeParameter":return t.name===e;case"TSMappedType":case"TSPropertySignature":return t.key===e}return!1}(e)}(o)||(e=>{let t=e;for(;"TSQualifiedName"===t.parent.type;)t=t.parent;return"TSTypeReference"===t.parent.type&&t.parent.typeName===t||"TSTypeQuery"===t.parent.type&&t.parent.exprName===t})(o)||gh(o)||gE(o)||gD(o)||gS(o))return;let a=gp(o);if(!a)return;let i=a.parent.parent;if(r){let e=gc(i);if(e&&o.name===e.name&&gd(t,o,e))return gC({node:o,messageId:f7,source:o.name,replacement:"this",name:o.name})}if(!n||!(gx(o)&&!o.parent.optional&&!gh(o.parent))||eQ(o,e))return;let s=gv(i);if(s&&o.name===s.name&&gd(t,o,s))return gC({node:o,messageId:gr,source:o.name,replacement:"super",name:o.name})})},meta:{type:"suggestion",docs:{description:"Enforce consistent class references in static methods.",recommended:!0},hasSuggestions:!0,schema:[{type:"object",properties:{preferThis:{type:"boolean",description:"Prefer `this` over the current class name in static methods."},preferSuper:{type:"boolean",description:"Prefer `super` over the superclass name in static methods."}},additionalProperties:!1}],defaultOptions:[{preferThis:!0,preferSuper:!0}],messages:{[f7]:"Use `this` instead of `{{name}}` in static methods.",[ge]:"Use `{{name}}` instead of `this` in static methods.",[gt]:"Use the class name instead of `this` in static methods.",[gr]:"Use `super` instead of `{{name}}` in static methods.",[gn]:"Use `{{name}}` instead of `super` in static methods.",[go]:"Use the superclass name instead of `super` in static methods.",[ga]:"Replace `{{source}}` with `{{replacement}}`."},languages:["js/js"]}},gw="consistent-optional-chaining/remove-optional",gk="consistent-optional-chaining/use-optional",gI="consistent-optional-chaining/suggest-remove-optional",gj="consistent-optional-chaining/suggest-use-optional",gF=new Set(["Identifier","ThisExpression","Super"]);function gB(e){let t;for(;e!==t;)t=e,"ChainExpression"===(e=ry(e)).type&&(e=e.expression);return e}function gR(e){return"MemberExpression"===(e=gB(e)).type?e:void 0}function g$(e){return e=gB(e),!!gF.has(e.type)||"MemberExpression"===e.type&&g$(e.object)}function gP(e,t){let r=ri(e,t);return!re(t,r)}function gL({memberExpression:e,context:t,fixer:r,replacement:n}){let o=ri(e,t);return r.replaceTextRange(o,n)}function gN(e,t,r){return gL({memberExpression:e,context:t,fixer:r,replacement:e.computed?"[":"."})}let gM="always",gO="never",gq="missing-delay",gU="redundant-delay",gW=new Set(["setTimeout","setInterval"]),g_=new Set(["window","globalThis","global","self"]),gV=e=>e0(e,0)||"UnaryExpression"===e.type&&("+"===e.operator||"-"===e.operator)&&gV(e.argument),gz="negative-index",gK="length-index",gG=["entries","keys","values"],gJ=["drop","filter","flatMap","map","take"],gX=["concat","from","zip","zipKeyed"],gY=e=>{for(;rg(e)||"ChainExpression"===e.type||"ParenthesizedExpression"===e.type;)e=e.expression;return e},gH="no-duplicate-loops",gZ=["filter","map"],gQ="no-declarations-before-early-exit",g0=e=>"VariableDeclaration"===e.type&&("let"===e.kind||"const"===e.kind),g1=e=>"use"===e||/^use[\dA-Z]/.test(e),g2=e=>!e||"Literal"===e.type||"TemplateLiteral"===e.type&&0===e.expressions.length,g3=(e,t,r)=>{let n="before"===r?e.getTokenBefore(t,{includeComments:!0}):e.getTokenAfter(t,{includeComments:!0});return n&&eg(n)},g8=(e,t)=>{let[r,n]=e.getRange(t);return new Set(tO(e.getScope(t)).filter(({identifier:t})=>{let[o,a]=e.getRange(t);return o>=r&&a<=n}).map(({identifier:e})=>e.name))};function*g6(e,t,r){let n;for(let[o,a]of t.entries())if(g0(a)&&!a.declare){n??=t.map(e=>{var t,n;return(t=e,n=r,"IfStatement"!==t.type||n(t.consequent)===(!!t.alternate&&n(t.alternate)))?void 0:e});for(let r=o+1;r<t.length;r++){let t=n[r];if(t){for(let n of a.declarations){let i=function({sourceCode:e,declaration:t,declarator:r,guardStatement:n,declarationIndex:o,guardIndex:a}){var i;let s;if("Identifier"!==r.id.type||(e=>{if(e?.type!=="CallExpression")return!1;let{callee:t}=e;return"Identifier"===t.type?g1(t.name):"MemberExpression"===t.type&&!t.computed&&"Identifier"===t.object.type&&/^[A-Z]/.test(t.object.name)&&"Identifier"===t.property.type&&g1(t.property.name)})(r.init)||r.init&&tk(r.init,e.visitorKeys)||a>o+1&&!g2(r.init)||r.init&&(i=r.init,s=g8(e,n),[...g8(e,i)].some(e=>s.has(e)))&&(eP(r.init,e)||eP(n.test,e)))return;let[l]=e.getDeclaredVariables(r),u=l.references.filter(e=>!e.init&&!function(e){let t=e;for(;"TSQualifiedName"===t.parent.type;)t=t.parent;return"TSTypeQuery"===t.parent.type}(e.identifier));if(0===u.length)return;let[,p]=e.getRange(n);if(u.some(t=>e.getRange(t.identifier)[0]<p))return;let c={node:r.id,messageId:gQ};return(({sourceCode:e,declaration:t,guardStatement:r,declarationIndex:n,guardIndex:o})=>o===n+1&&1===t.declarations.length&&g2(t.declarations[0].init)&&0===e.getCommentsInside(t).length&&!g3(e,t,"before")&&!g3(e,r,"after")&&!e.getTokensBetween(t,r,{includeComments:!0}).some(e=>eg(e)))({sourceCode:e,declaration:t,guardStatement:n,declarationIndex:o,guardIndex:a})&&(c.fix=function(e,t,r){let n=e.getText(t),o=e.getText(r),[a,i]=e.getRange(t),[s,l]=e.getRange(r),u=e.text.slice(i,s);return e=>e.replaceTextRange([a,l],`${o}${u}${n}`)}(e,t,n)),c}({sourceCode:e,declaration:a,declarator:n,guardStatement:t,declarationIndex:o,guardIndex:r});i&&(yield i)}break}}}}let g9="no-optional-chaining-on-undeclared-variable",g5=e=>"Type"===e.type||"ImportBinding"===e.type&&n_(e.node);function g4(e){let t;for(;e!==t;)t=e,("ChainExpression"===(e=ry(e)).type||"TSInstantiationExpression"===e.type)&&(e=e.expression);return e}let g7="no-object-methods-with-collections/error",ye="no-object-methods-with-collections/suggestion",yt=new Set(["Map","ReadonlyMap"]),yr=new Set(["Set","ReadonlySet"]),yn=new Set([...yt,...yr]),yo=new Set(["entries","keys","values"]),ya=e=>new Set([e]),yi=e=>yn.has(e)?e:void 0,ys=new Set(["ClassDeclaration","TSEnumDeclaration","TSInterfaceDeclaration","TSTypeAliasDeclaration"]),yl=e=>{if(e&&ys.has(e.type))return e.id?.name},yu=(e,t)=>{let r=(e=>{for(;e.parent;)e=e.parent;return"Program"===e.type?e:void 0})(t);if(!r)return!1;for(let t of r.body){if("ImportDeclaration"===t.type){if(t.specifiers.some(t=>t.local.name===e))return!0;continue}if("ExportNamedDeclaration"===t.type||"ExportDefaultDeclaration"===t.type){if(yl(t.declaration)===e)return!0;continue}if(yl(t)===e)return!0}return!1},yp=e=>{let t=new Set;for(let r of e){if(!r)return;for(let e of r)t.add(e)}return t},yc=(e,t)=>{let r=ei(t.sourceCode.getScope(e),e);return!r||"global"===r.scope.type&&0===r.defs.length},yd=(e,t)=>{if(rD.has(e.intrinsicName))return;if(e.isUnion())return yp(e.types.map(e=>yd(e,t)));let r=rv(e);if(!(r?.declarations?.length>0&&r.declarations.every(e=>t.isSourceFileDefaultLibrary(e.getSourceFile()))))return;let n=r.getName(),o=n&&yi(n);return o&&ya(o)},ym=(e,t)=>{switch(e?.type){case"TSTypeAnnotation":case"TSParenthesizedType":return ym(e.typeAnnotation);case"TSTypeOperator":return"readonly"===e.operator?ym(e.typeAnnotation):void 0;case"TSTypeReference":{if("Identifier"!==e.typeName.type||yu(e.typeName.name,e))return;let t=yi(e.typeName.name);return t&&ya(t)}case"TSUnionType":return yp(e.types.map(e=>ym(e)))}},yf=(e,t,r=new Set)=>((e,t)=>{let{parserServices:r}=t.sourceCode;if(r?.program)try{let{program:t}=r,n=yd(r.getTypeAtLocation(e),t);if(n&&!((e,t)=>{for(let r of e)if(yu(r,t))return!0;return!1})(n,e))return n}catch{}})(e,t)??((e,t,r)=>{if(te(e,{names:["Map","Set"]})&&yc(e.callee,t))return ya(e.callee.name);switch(e.type){case"Identifier":return((e,t,r)=>{let n=ei(t.sourceCode.getScope(e),e);if(!n||r.has(n)||1!==n.defs.length)return;r.add(n);let[o]=n.defs,a=ym(o.name?.typeAnnotation);return a||("Variable"===o.type&&"const"===o.parent.kind&&o.node.init?yf(o.node.init,t,r):void 0)})(e,t,r);case"TSAsExpression":case"TSSatisfiesExpression":case"TSTypeAssertion":return ym(e.typeAnnotation)??yf(e.expression,t,r);case"TSNonNullExpression":case"ParenthesizedExpression":return yf(e.expression,t,r)}})(e,t,r),yg="no-subtraction-comparison/error",yy="no-subtraction-comparison/suggestion",yh={">":"<",">=":"<=","<":">","<=":">=","===":"===","!==":"!==","==":"==","!=":"!="},yx=new Set(Object.keys(yh)),yb=new Set([">","<"]),yE=e=>"BinaryExpression"===e.type&&"-"===e.operator,yD=(e,t)=>{let r=ew(e,t)?.value;return"number"==typeof r&&Number.isFinite(r)},yS="no-unnecessary-global-this",yv=new Set(["TSAsExpression","TSInstantiationExpression","TSNonNullExpression","TSSatisfiesExpression","TSTypeAssertion"]),yC=e=>{for(;yv.has(e.parent.type)&&e.parent.expression===e;)e=e.parent;return e};function yA(e){return"CallExpression"===(e=yC(e)).parent.type&&e.parent.callee===e}let yT="computed-key",yw="nested-array",yk="deep-object",yI="property-assignment";function yj(e){let{parent:t}=e;if(t){if(rg(t)&&t.expression===e||"AssignmentPattern"===t.type&&t.left===e||"RestElement"===t.type&&t.argument===e)return yj(t);if("Property"===t.type&&t.value===e&&"ObjectPattern"===t.parent.type)return t.parent;if("ObjectPattern"===t.type||"ArrayPattern"===t.type)return t}}function yF(e){let t=0;for(;e;)"ObjectPattern"===e.type&&t++,e=yj(e);return t}let yB="no-useless-else",yR=new Set(["Program","BlockStatement","StaticBlock","SwitchCase"]),y$=new Set(["[","(","/","`","+","-"]),yP=(e,t)=>{let r=e.text.lastIndexOf("\n",t-1)+1;return/^[\t ]*/.exec(e.text.slice(r,t))[0]},yL=e=>y$.has(e.value[0]),yN="no-useless-recursion",yM=new Set(["using","await using"]),yO=e=>e?.type==="VariableDeclaration"&&yM.has(e.kind),yq=e=>"ForStatement"===e.type?yO(e.init):"ForOfStatement"===e.type&&yO(e.left),yU="prefer-add-event-listener-options",yW="prefer-direct-iteration",y_="Array",yV="FormData",yz="URLSearchParams",yK=new Set([y_,"Map","Set",yV,yz,...rE]),yG=new Map([["ReadonlyArray",y_],["ReadonlyMap","Map"],["ReadonlySet","Set"]]),yJ=new Map([[y_,["values"]],["Map",["entries"]],["Set",["values","keys"]],[yV,["entries"]],[yz,["entries"]],...rE.map(e=>[e,["values"]])]),yX=["Map","WeakMap","Set","WeakSet"],yY=["all","allSettled","any","race"],yH=new Set(["ArrayExpression","CallExpression","NewExpression"]),yZ=e=>new Set([e]),yQ=(e,t)=>td(e,{objects:rE,methods:t,optionalCall:!1,optionalMember:!1}),y0=e=>yK.has(e)?e:yG.get(e),y1=e=>{let t=new Set;for(let r of e){if(!r)return;for(let e of r)t.add(e)}return t},y2=(e,t,r)=>{if("any"===e.intrinsicName||"unknown"===e.intrinsicName)return;if(e.isUnion())return y1(e.types.map(e=>y2(e,t,r)));if(t.isArrayType(e)||t.isTupleType(e))return yZ(y_);let n=rv(e);if(!rC(n,r))return;let o=n.getName(),a=o&&y0(o);return a&&yZ(a)},y3=e=>{switch(e?.type){case"TSTypeAnnotation":case"TSParenthesizedType":return y3(e.typeAnnotation);case"TSArrayType":case"TSTupleType":return yZ(y_);case"TSTypeOperator":return"readonly"===e.operator?y3(e.typeAnnotation):void 0;case"TSTypeReference":{if("Identifier"!==e.typeName.type)return;let t=y0(e.typeName.name);return t&&yZ(t)}case"TSUnionType":return y1(e.types.map(e=>y3(e)))}},y8=(e,t,r=new Set)=>((e,t,r)=>{if("ArrayExpression"===e.type||te(e,{name:"Array"}))return yZ(y_);if(te(e,{names:rE})||te(e,{names:["Map","Set",yV,yz]}))return yZ(e.callee.name);if(e7(e,{name:"Array"})||td(e,{object:"Array",methods:["from","of"],optionalCall:!1,optionalMember:!1}))return yZ(y_);if(yQ(e,["from","of"]))return yZ(e.callee.object.name);switch(e.type){case"Identifier":return((e,t,r)=>{let n=ei(t.sourceCode.getScope(e),e);if(!n||r.has(n)||1!==n.defs.length)return;r.add(n);let[o]=n.defs,a=y3(o.name?.typeAnnotation);return a||("Variable"===o.type&&"const"===o.parent.kind&&o.node.init?y8(o.node.init,t,r):void 0)})(e,t,r);case"TSAsExpression":case"TSSatisfiesExpression":case"TSTypeAssertion":return y3(e.typeAnnotation)??y8(e.expression,t,r);case"TSNonNullExpression":case"ParenthesizedExpression":return y8(e.expression,t,r)}})(e,t,r)??((e,t)=>{let{parserServices:r}=t.sourceCode;if(r?.program)try{let{program:t}=r;return y2(r.getTypeAtLocation(e),t.getTypeChecker(),t)}catch{}})(e,t),y6="prefer-number-is-safe-integer/error",y9="prefer-number-is-safe-integer/suggestion",y5="prefer-number-is-safe-integer/integer-check-error",y4="prefer-number-is-safe-integer/integer-check-suggestion",y7=["_","lodash","underscore"],he=["floor","trunc"],ht=(e,t)=>{let r=ei(t.getScope(e),"Number");return!r||"global"===r.scope.type&&0===r.defs.length},hr=e=>{if("BinaryExpression"===e.type&&"%"===e.operator&&e0(e.right,1))return e.left},hn=(e,t)=>{if(td(e,{object:"Math",methods:he,argumentsLength:1,optionalCall:!1,optionalMember:!1,computed:!1})&&t.isGlobalReference(e.callee.object))return e.arguments[0]},{isIdentifierName:ho}=tL,ha="prefer-object-define-properties";function hi(e){if(e?.type!=="ExpressionStatement")return;let{expression:t}=e;if(td(t,{object:"Object",method:"defineProperty",argumentsLength:3,optionalCall:!1,optionalMember:!1,computed:!1}))return t}let hs="prefer-object-destructuring-defaults",hl="prefer-object-destructuring-defaults/suggestion",hu=new Set(Object.getOwnPropertyNames(Object.prototype)),hp={considerGetters:!0,considerImplicitTypeConversion:!0},hc=e=>"Property"===e.type&&"init"===e.kind&&!e.computed&&!e.method,hd=(e,t,r)=>tO(r.sourceCode.getScope(e)).some(n=>t.has(n.identifier.name)&&((e,t,r)=>{let[n,o]=r.getRange(e),[a,i]=r.getRange(t);return n>=a&&o<=i})(n.identifier,e,r.sourceCode)),hm=(e,t,r)=>{let{sourceCode:n}=r,o=n.getText(e.node.value),a=eZ(t.value,r);return e.node.shorthand?`${o} = ${a}`:`${n.getText(e.node.key)}: ${o} = ${a}`},hf="prefer-single-object-destructuring",hg=(e,t)=>{let r,n;if(!("VariableDeclaration"===t.type&&("const"===(r=t.kind)||"let"===r)&&!t.declare&&1===t.declarations.length))return;let[o]=t.declarations;if("ObjectPattern"===o.id.type&&!o.id.typeAnnotation&&(n=o.id).properties.length>0&&n.properties.every(e=>"Property"===e.type&&!e.computed&&"Identifier"===e.value.type)&&o.init?.type==="Identifier"&&((e,t)=>{let r=ei(e.getScope(t),t);if(!r||1!==r.defs.length)return!1;let[n]=r.defs;return"Variable"===n.type&&"VariableDeclarator"===n.node.type&&"VariableDeclaration"===n.parent.type&&!n.parent.declare&&"const"===n.parent.kind})(e,o.init))return{node:t,declarator:o,source:o.init.name}},hy=(e,t,r)=>{let n,o,a=hg(e,t),i=hg(e,r);if(!(a&&i&&a.node.kind===i.node.kind&&a.source===i.source&&0===e.getCommentsInside(a.node).length&&0===e.getCommentsInside(i.node).length&&(n=a.node,o=i.node,!e.getTokensBetween(n,o,{includeComments:!0}).some(e=>eg(e)))))return;let s=t=>t.properties.map(t=>e.getText(t)).join(", "),l=`${a.node.kind} {${s(a.declarator.id)}, ${s(i.declarator.id)}} = ${a.source};`;return{node:i.node,messageId:hf,data:{source:a.source},fix:t=>t.replaceTextRange([e.getRange(a.node)[0],e.getRange(i.node)[1]],l)}};function*hh(e,t){for(let[r,n]of t.entries()){if(0===r)continue;let o=hy(e,t[r-1],n);o&&(yield o)}}let hx="prefer-smaller-scope",hb=new Set(["ArrowFunctionExpression","ClassDeclaration","ClassExpression","FunctionDeclaration","FunctionExpression","StaticBlock","WithStatement"]);function hE(e,t){let r=e.parent;for(;r&&r!==t;){if(hb.has(r.type))return!1;r=r.parent}return r===t}function hD(e,t,r){let n="before"===r?e.getTokenBefore(t,{includeComments:!0}):e.getTokenAfter(t,{includeComments:!0});return!!(n&&eg(n))}function hS(e,t){let r=e.getTokenBefore(t),n=e.getTokenAfter(t);return r?.value==="("&&n?.value===")"}let hv="prefer-single-array-predicate/error",hC="prefer-single-array-predicate/suggestion",hA=new Map([["||","some"],["&&","every"]]),hT=new Set(["AssignmentExpression","ArrowFunctionExpression","ConditionalExpression","SequenceExpression","TSAsExpression","TSNonNullExpression","TSSatisfiesExpression","TSTypeAssertion","YieldExpression"]),hw="prefer-url-href",hk="non-url",hI="unknown",hj=new Set(["ClassName","ImportBinding","Type"]),hF=new Set(["any","error","unknown"]),hB=new Set(["node:url","url"]),hR=e=>hj.has(e.type),h$=(e,t,r,n)=>{for(;t;){let o=t.set.get(e);if(o?.defs.some(e=>nV(e,r,n)))return o;t=t.upper}},hP=e=>e.every(e=>"url"===e)?"url":!e.includes(hI)&&e.includes(hk)?hk:hI,hL=e=>{let t;if("ImportBinding"!==e.type)return!1;let{node:r,parent:n}=e;return t=n.source,hB.has(t.value)&&"ImportSpecifier"===r.type&&"Identifier"===r.imported.type&&"URL"===r.imported.name},hN=e=>"ImportBinding"===e.type&&("type"===e.parent.importKind||n_(e.node)),hM=e=>"Type"===e.type||hN(e),hO=e=>hL(e)&&!hN(e),hq=(e,t)=>{let r;return"NewExpression"===e.type&&(((e,t)=>{if("Identifier"!==e.type||"URL"!==e.name||((e,t,r,n)=>{for(;t;){let o=t.set.get(e);if(o?.defs.some(e=>!hM(e)&&nV(e,r,n)))return!0;t=t.upper}return!1})("URL",t.sourceCode.getScope(e),e,t))return!1;if(nR(e,t))return!0;let r=ei(t.sourceCode.getScope(e),e);return r?.defs.length>0&&r.defs.every(e=>hM(e))})(r=e.callee,t)||((e,t)=>{if("Identifier"!==e.type)return!1;let r=ei(t.sourceCode.getScope(e),e);return r?.defs.some(e=>hO(e))??!1})(r,t))},hU=(e,t)=>t.sourceCode.getScope(e.name??e.node),hW=(e,t,r,n=new Set)=>{switch(e?.type){case"TSTypeAnnotation":case"TSParenthesizedType":return hW(e.typeAnnotation,t,r,n);case"TSTypeReference":return((e,t,r,n)=>{if("Identifier"!==e.typeName.type)return hI;let o=e.typeName.name,a=h$(o,r,e.typeName,t),[i]=a?.defs??[];if(!i)return"URL"!==o||((e,t)=>{for(;t;){let r=t.set.get(e);if(r?.defs.some(e=>hR(e)))return!0;t=t.upper}return!1})(o,r)?hI:"url";if(n.has(o))return hI;if(hL(i))return"url";n.add(o);let s=hI;return"Type"===i.type&&"TSTypeAliasDeclaration"===i.node.type?s=hW(i.node.typeAnnotation,t,hU(i,t),n):"Type"===i.type&&"TSTypeParameter"===i.node.type?s=hI:"ClassName"===i.type&&(s=hk),n.delete(o),s})(e,t,r,n);case"TSUnionType":return hP(e.types.map(e=>hW(e,t,r,n)));case"TSIntersectionType":return hP(e.types.map(e=>hW(e,t,r,n)));case"TSImportType":let o;return(o=e.source,hB.has(o.value)&&e.qualifier?.type==="Identifier"&&"URL"===e.qualifier.name)?"url":hk;default:return e?hk:hI}},h_=(e,t)=>{let{checker:r,context:n,node:o,program:a}=t;if(hF.has(e.intrinsicName)||e.isTypeParameter?.())return hI;let i=r.getBaseConstraintOfType(e);if(i&&i!==e)return h_(i,t);if(e.isUnion()||e.isIntersection())return hP(e.types.map(e=>h_(e,t)));let s=((e,t,r)=>{if(!/^[\w$]+$/.test(e))return hI;let n=h$(e,r.sourceCode.getScope(t),t,r),o=n?.defs.filter(e=>"Type"===e.type||"ClassName"===e.type||hL(e))??[];return 0===o.length?hI:o.every(e=>hL(e))?"url":hk})(r.typeToString(e),o,n);if(s!==hI)return s;let l=rv(e);return rC(l,a)&&"URL"===l.getName()?"url":hk},hV=(e,t)=>{let{parserServices:r}=t.sourceCode;if(!r?.program)return hI;try{let{program:n}=r;return h_(r.getTypeAtLocation(e),{checker:n.getTypeChecker(),context:t,node:e,program:n})}catch{return hI}};function hz(e,t,r=new Set){if(!e)return hI;let n=t.sourceCode.getScope(e);switch(e.type){case"Identifier":{let n=((e,t,r)=>{let n=ei(t.sourceCode.getScope(e),e);if(!n||r.has(n)||1!==n.defs.length)return hI;let[o]=n.defs;if(!nV(o,e,t))return hI;r.add(n);let a="Variable"===o.type&&"const"===o.parent.kind&&o.node.init?hz(o.node.init,t,r):hI,i=hW(o.name?.typeAnnotation,t,hU(o,t)),s=hI;return a!==hI?s=a:i!==hI&&(s=i),r.delete(n),s})(e,t,r);if(n!==hI)return n;break}case"TSAsExpression":case"TSSatisfiesExpression":case"TSTypeAssertion":{let o=hW(e.typeAnnotation,t,n);return o===hI?hz(e.expression,t,r):o}case"TSNonNullExpression":case"ParenthesizedExpression":return hz(e.expression,t,r);case"SequenceExpression":return hz(e.expressions.at(-1),t,r);case"ConditionalExpression":return hP([hz(e.consequent,t,r),hz(e.alternate,t,r)])}if(hq(e,t))return"url";if("NewExpression"===e.type){if(((e,t)=>{if("Identifier"!==e.type)return!1;let r=ei(t.sourceCode.getScope(e),e);return r?.defs.some(e=>!hM(e)&&!hO(e))??!1})(e.callee,t))return hk;let r=hV(e,t);return r===hI?hk:r}let o=((e,t)=>{if("CallExpression"!==e.type||"Identifier"!==e.callee.type)return hI;let r=ei(t.sourceCode.getScope(e.callee),e.callee);if(r?.defs.length!==1)return hI;let[n]=r.defs;return hW(n.node.returnType,t,hU(n,t))})(e,t);return o!==hI?o:hV(e,t)}let hK=(e,t)=>{switch(e.type){case"TSAsExpression":case"TSSatisfiesExpression":case"TSTypeAssertion":case"ParenthesizedExpression":case"TSNonNullExpression":return hK(e.expression,t);case"SequenceExpression":return hK(e.expressions.at(-1),t);case"ConditionalExpression":return hK(e.consequent,t)&&hK(e.alternate,t);case"NewExpression":return hq(e,t);default:return!1}},hG=(e,t)=>0===t.sourceCode.getCommentsInside(e).length,hJ="require-proxy-trap-boolean-return",hX=new Set(["defineProperty","deleteProperty","has","isExtensible","preventExtensions","set","setPrototypeOf"]),hY=new Set(["ArrowFunctionExpression","FunctionDeclaration","FunctionExpression"]),hH=new Set(["ArrayExpression","ArrowFunctionExpression","ClassExpression","FunctionExpression","NewExpression","ObjectExpression","TemplateLiteral","UpdateExpression"]),hZ=new Set(["%","&","*","**","+","-","/","<<",">>",">>>","^","|"]),hQ=(e,t)=>({node:e,messageId:hJ,data:{name:t}}),h0=e=>{if(e)return hQ(e.node,e.data.name)},h1=(e,t,r)=>{if("AssignmentExpression"===e.type)return"="===e.operator?h0(h1(e.right,t,r)):hQ(e,t);if("ConditionalExpression"===e.type)return h1(e.consequent,t,r)??h1(e.alternate,t,r);if("LogicalExpression"===e.type)return h0(h1(e.left,t,r)??h1(e.right,t,r));if("SequenceExpression"===e.type)return h0(h1(e.expressions.at(-1),t,r));let n=((e,t)=>{let r=ew(e,t.getScope(e));if(null!==r&&"boolean"!=typeof r.value)return!!r.value})(e,r);if(void 0===n&&!(hH.has(e.type)||"UnaryExpression"===e.type&&"!"!==e.operator&&"delete"!==e.operator||"BinaryExpression"===e.type&&hZ.has(e.operator)))return;let o=((e,t,r)=>{if(!(r.getCommentsInside(e).length>0)&&("Literal"===e.type&&!e.regex||"TemplateLiteral"===e.type&&0===e.expressions.length||"Identifier"===e.type&&"undefined"===e.name))return String(t)})(e,n,r);return{...hQ(e,t),...o&&{fix:t=>t.replaceText(e,o)}}},h2=(e,t)=>{if("Property"!==e.type||"init"!==e.kind)return;let r=eI(e,t.getScope(e));if(hX.has(r)&&hY.has(e.value.type))return{name:r,functionNode:e.value}},h3=({functionNode:e,name:t},r,n)=>{if(e.async||e.generator)return hQ(e,t);if("BlockStatement"!==e.body.type)return h1(e.body,t,r);let o=[...function* e(t){if(t&&"string"==typeof t.type){if("ReturnStatement"===t.type)return void(yield t);if(!("BlockStatement"!==t.type&&hY.has(t.type))){for(let[r,n]of Object.entries(t))if("parent"!==r){if(Array.isArray(n)){for(let t of n)yield*e(t);continue}yield*e(n)}}}}(e.body)],a=n.get(e)??!1;if(0===o.length){if(a)return;return hQ(e,t)}for(let e of o){if(!e.argument)return hQ(e,t);let n=h1(e.argument,t,r);if(n)return n}if(!a)return hQ(e,t)},h8=f.builtinRules.get("logical-assignment-operators"),h6="ifNullish",h9="convertIf",h5={...h8.meta.messages,[h6]:"'if' statement can be replaced with a logical operator assignment with operator ||= or ??=."},h4=e=>e.fix??e.suggest?.[0]?.fix,h7={create:e=>{let{sourceCode:t}=e,r=Object.create(e,{report:{value(r){e.report(function(e,t){let r;if("if"!==e.messageId||e.data?.operator!=="||="||"function"!=typeof h4(e))return e;let n={...(r={...e},delete r.fix,delete r.suggest,r),messageId:h6};if(t.getCommentsInside(e.node).length>0)return n;let o=h4(e);return{...n,suggest:[{messageId:h9,data:{operator:"||="},fix:o},{messageId:h9,data:{operator:"??="},fix:e=>o(new Proxy(e,{get(e,t){if("insertTextBefore"!==t){let r=Reflect.get(e,t,e);return"function"==typeof r?r.bind(e):r}return(t,r)=>e.insertTextBefore(t,"||"===r?"??":r)}}))}]}}(r,t))}}});for(let[t,n]of Object.entries(h8.create(r)))e.on(t,n)},meta:{type:h8.meta.type,docs:{description:h8.meta.docs.description,recommended:!0},fixable:h8.meta.fixable,hasSuggestions:h8.meta.hasSuggestions,schema:h8.meta.schema,defaultOptions:[h8.meta.defaultOptions?.[0]],messages:h5,languages:["js/js"]}},xe="no-useless-coercion",xt=new Map([["Boolean",{type:"boolean",isType:ny}],["String",{type:"string",isType:nC}],["BigInt",{type:"bigint",isType:function(e,t){return!!e&&(!!("TSSatisfiesExpression"===e.type&&nx(e.typeAnnotation)||nb(e,t))||"bigint"==typeof ew(e,t.sourceCode.getScope(e))?.value)}}],["Number",{type:"number",isType:(e,t)=>nr(e,t.sourceCode.getScope(e))}]]),xr=e=>"Literal"===e.type&&""===e.value,xn="no-useless-boolean-cast",xo=["every","filter","find","findIndex","findLast","findLastIndex","some"],xa="no-useless-continue",xi="no-useless-override",xs=e=>e.isUnion()?e.types.every(e=>xs(e)):"void"===e.intrinsicName||"undefined"===e.intrinsicName,xl=(e,t)=>{let{parserServices:r}=t.sourceCode;if(r?.program)try{return{type:r.getTypeAtLocation(e),checker:r.program.getTypeChecker()}}catch{}},xu="prefer-has-check",xp=new Set(["Map","ReadonlyMap","WeakMap"]),xc=new Set(["Map","WeakMap"]),xd=new Set(["FormData","Headers","URLSearchParams"]),xm=new Set(["Array","ReadonlyArray"]),xf=new Set([...xc,...xd]),xg=new Set(["ClassName","ImportBinding","TSEnumName","Type"]),xy=new Set(["any","bigint","boolean","false","number","string","unknown","undefined","null","void"]),xh=new Set(["TSTypeAnnotation","TSParenthesizedType"]),xx=new Set(["TSAnyKeyword","TSNeverKeyword","TSUndefinedKeyword","TSUnknownKeyword","TSVoidKeyword"]),xb=new Set(["TSBigIntKeyword","TSBooleanKeyword","TSNumberKeyword","TSStringKeyword"]),xE=new Set(["TSArrayType","TSConstructorType","TSFunctionType","TSObjectKeyword","TSSymbolKeyword","TSTupleType"]),xD=new Set(["ArrayExpression","ArrowFunctionExpression","ClassExpression","FunctionExpression","NewExpression","ObjectExpression"]),xS=new Set(["ParenthesizedExpression","TSAsExpression","TSSatisfiesExpression","TSTypeAssertion","TSNonNullExpression"]),xv=e=>{for(;xS.has(e.type);)e=e.expression;return e},xC=e=>{if("Identifier"===e.type)return e.name;if("TSQualifiedName"===e.type){let t=xC(e.left);return t?`${t}.${e.right.name}`:void 0}},xA=e=>e.typeArguments?.params??e.typeParameters?.params??[],xT=(e,t)=>{for(;t;){let r=t.set.get(e)?.defs.find(e=>xg.has(e.type));if(r)return r;t=t.upper}},xw=e=>{if(e?.type==="Type"&&"TSTypeAliasDeclaration"===e.node.type&&0===xA(e.node).length)return e.node.typeAnnotation},xk=(e,t)=>{if(t.sourceCode.isGlobalReference(e))return!0;let r=ei(t.sourceCode.getScope(e),e);return!r||0===r.defs.length},xI=(e,t)=>tx(e)&&xk(e,t)||"UnaryExpression"===e.type&&"void"===e.operator&&"Literal"===e.argument.type&&0===e.argument.value,xj=(e,t)=>xp.has(e)?{kind:"map",typeName:e,valueType:t}:xd.has(e)?{kind:"null-sentinel",typeName:e}:void 0,xF=(e,t,r=new Set)=>{switch(e?.type){case"TSTypeAnnotation":case"TSParenthesizedType":return xF(e.typeAnnotation,t,r);case"TSTypeOperator":return"readonly"===e.operator?xF(e.typeAnnotation,t,r):void 0;case"TSTypeReference":{let n=xC(e.typeName);if(!n)return;if((xp.has(n)||xd.has(n))&&!xT(n,t))return xj(n,xA(e).at(-1));let o=((e,t,r)=>{if(!r.has(e))return r.add(e),xw(xT(e,t))})(n,t,r);return o?xF(o,t,r):void 0}}},xB=(e,t)=>{let r=t.sourceCode.getScope(e);return xF(e.typeAnnotation,r)},xR=(e,t,r=new Set)=>{let n=xB(e,t);if(n)return n;if(te(e=xv(e))&&"Identifier"===e.callee.type&&xf.has(e.callee.name)&&xk(e.callee,t))return xj(e.callee.name);if("Identifier"!==e.type)return;let o=ei(t.sourceCode.getScope(e),e);if(!o||r.has(o)||1!==o.defs.length)return;r.add(o);let[a]=o.defs,i=xF(a.name?.typeAnnotation,t.sourceCode.getScope(a.name));return i||("Variable"===a.type&&"const"===a.parent.kind&&a.node.id===a.name&&a.node.init?xR(a.node.init,t,r):void 0)},x$=(e,t)=>{for(let r of[e,e.target]){if(!r)continue;let e=rv(r);if(rC(e,t))return e.getName()}},xP=(e,t,r)=>{if(rD.has(e.intrinsicName)||rS.has(e.intrinsicName))return;if(e.isUnion()){let n=e.types.map(e=>xP(e,t,r));if(1===new Set(n.map(e=>e?.typeName)).size){let[e]=n;if(e?.kind!=="map")return e;let r=n.map(e=>e?.valueType);return{...e,valueType:r.every(Boolean)?t.getUnionType(r):void 0}}if(n.every(e=>e?.kind==="map")){let e=n.map(e=>e.valueType);return{kind:"map",typeName:"Map",valueType:e.every(Boolean)?t.getUnionType(e):void 0}}return n.every(e=>e?.kind==="null-sentinel")?{kind:"null-sentinel",typeName:"null-sentinel"}:void 0}if(e.isIntersection())return e.types.map(e=>xP(e,t,r)).find(e=>e?.kind==="map");let n=x$(e,r);return xj(n,xp.has(n)?t.getTypeArguments(e).at(-1):void 0)},xL=(e,t)=>{let{parserServices:r}=t.sourceCode;if(r?.program)try{let{program:t}=r;return xP(r.getTypeAtLocation(e),t.getTypeChecker(),t)}catch{}},xN=(e,t)=>xL(e,t)??xR(e,t),xM=(e,t)=>"truthy"===t?!!e:"not-undefined"===t?void 0!==e:null!=e,xO=(e,t,r,n=new Set)=>{if(!e||xx.has(e.type))return!1;if(xh.has(e.type))return xO(e.typeAnnotation,t,r,n);if("TSTypeOperator"===e.type)return"readonly"===e.operator&&xO(e.typeAnnotation,t,r,n);if("TSUnionType"===e.type||"TSIntersectionType"===e.type)return e.types.every(e=>xO(e,t,r,n));if("TSNullKeyword"===e.type)return"not-undefined"===r;if(xb.has(e.type))return"truthy"!==r;if(xE.has(e.type))return!0;if("TSTypeLiteral"===e.type)return"truthy"!==r;if("TSLiteralType"===e.type){var o;let t="Literal"===(o=e.literal).type?o.value:"TemplateLiteral"===o.type&&0===o.expressions.length?o.quasis[0].value.cooked:"UnaryExpression"===o.type&&("-"===o.operator||"+"===o.operator)&&"Literal"===o.argument.type&&("number"==typeof o.argument.value||"bigint"==typeof o.argument.value)?"-"===o.operator?-o.argument.value:o.argument.value:void 0;return void 0!==t&&xM(t,r)}return"TSTypeReference"===e.type&&((e,t,r,n)=>{let o,a,i=xC(e.typeName);if(!i||n.has(i))return!1;n.add(i);let s=(a=xw(o=xT(i,t.sourceCode.getScope(e.typeName))))?{type:"alias",node:a}:o?.type==="ClassName"||o?.type==="Type"&&"TSInterfaceDeclaration"===o.node.type?{type:"object"}:void 0,l=!1;return s?.type==="alias"?l=xO(s.node,t,r,n):s?.type==="object"&&(l="truthy"!==r),n.delete(i),l})(e,t,r,n)},xq=(e,t)=>e.isTypeParameter?.()?e.getConstraint()??t.getBaseConstraintOfType(e):e,xU=(e,t,r)=>{if(rD.has(e.intrinsicName))return!1;let n=xq(e,t);return n&&n!==e?xU(n,t,r):!e.isTypeParameter?.()&&(e.isUnion()||e.isIntersection()?e.types.every(e=>xU(e,t,r)):!r.has(e.intrinsicName))},xW=(e,t,r)=>{if(rD.has(e.intrinsicName)||rS.has(e.intrinsicName))return!1;let n=xq(e,t);if(n&&n!==e)return xW(n,t,r);if(e.isUnion()||e.isIntersection())return e.types.every(e=>xW(e,t,r));if(xy.has(e.intrinsicName))return!1;if("true"===e.intrinsicName||"symbol"===e.intrinsicName)return!0;if(e.isStringLiteral?.())return e.value.length>0;if(e.isNumberLiteral?.())return 0!==e.value;if(e.isBigIntLiteral?.())return e.value.negative||"0"!==e.value.base10Value;let o=t.typeToString(e);return/^-?\d+n$/u.test(o)?!/^-?0n$/u.test(o):"object"===t.typeToString(e)||xm.has(x$(e,r))||e.getCallSignatures().length>0||e.getConstructSignatures().length>0},x_=(e,t,r)=>{if(!te(e)||"Identifier"!==e.callee.type||!xc.has(e.callee.name)||!xk(e.callee,t))return;if(0===e.arguments.length)return!0;if(1!==e.arguments.length)return;let[n]=e.arguments;if("ArrayExpression"===n.type)return n.elements.every(e=>{var n;let o;return e?.type==="ArrayExpression"&&e.elements.length>=2&&e.elements[1]&&"SpreadElement"!==e.elements[1].type&&(n=e.elements[1],(o=ew(n,t.sourceCode.getScope(n)))?xM(o.value,r):!tx(n)&&xD.has(n.type))})},xV=(e,t,r)=>{let n=x_(xv(e),t,r);if(void 0!==n)return n;let o=xL(e,t)?.valueType;if(o){let{program:e}=t.sourceCode.parserServices,n=e.getTypeChecker();if("truthy"===r?xW(o,n,e):"not-undefined"===r?xU(o,n,new Set(["undefined","void"])):xU(o,n,new Set(["undefined","void","null"])))return!0}return function e(t,r,n,o={}){let a,i=o.visitedVariables??new Set,s=o.checkConstructorValues??!0,l=xB(t,r);if(l?.kind==="map")return!!l.valueType&&xO(l.valueType,r,n);let u=((e,t,r,n)=>{if(!te(e)||"Identifier"!==e.callee.type||!xc.has(e.callee.name)||!xk(e.callee,t))return;if(n){let n=x_(e,t,r);if(void 0!==n)return n}let o=xA(e).at(-1);return!!o&&xO(o,t,r)})(t=xv(t),r,n,s);if(void 0!==u)return u;let p=((e,t,r)=>{if("Identifier"!==e.type)return;let n=ei(t.sourceCode.getScope(e),e);if(!(!n||r.has(n))&&1===n.defs.length)return n})(t,r,i);if(!p)return!1;i.add(p);let[c]=p.defs,d=(a=xF(c.name?.typeAnnotation,r.sourceCode.getScope(c.name)),a?.kind==="map"?!!a.valueType&&xO(a.valueType,r,n):"Variable"===c.type&&"const"===c.parent.kind&&c.node.id===c.name&&!!c.node.init&&e(c.node.init,r,n,{visitedVariables:i,checkConstructorValues:!1}));return i.delete(p),d}(e,t,r)},xz=e=>"Literal"===e.type&&null===e.value,xK="logical",xG="ternary",xJ="consistent-conditional-object-spread",xX=new Set(["==","==="]),xY=new Set(["!=","!=="]),xH=e=>"SpreadElement"===e.parent.type&&e.parent.argument===e&&"ObjectExpression"===e.parent.parent.type&&e.parent.parent.properties.includes(e.parent);function xZ(e,t,r){if(tQ(e,t))return!0;if(e.type!==t.type)return!1;switch(e.type){case"AwaitExpression":return xZ(e.argument,t.argument,r);case"LogicalExpression":return e.operator===t.operator&&xZ(e.left,t.left,r)&&xZ(e.right,t.right,r);case"UnaryExpression":return e.operator===t.operator&&e.prefix===t.prefix&&xZ(e.argument,t.argument,r);case"UpdateExpression":return!1}return r.getText(e)===r.getText(t)}function xQ(e){return e9(e)?"null":tx(e)?"undefined":void 0}function x0(e){if("BinaryExpression"!==e.type||!xX.has(e.operator)&&!xY.has(e.operator))return;let t=xQ(e.left),r=xQ(e.right);if(!!t!=!!r)return{reference:t?e.right:e.left,kind:2===e.operator.length?"nullish":t??r,isTrueWhenNullish:xX.has(e.operator)}}let x1=(e,t)=>"null"===e.kind&&"undefined"===t.kind||"undefined"===e.kind&&"null"===t.kind;function x2(e,t){let r=x0(e);if(r?.kind==="nullish")return r;if("LogicalExpression"!==e.type)return;let n=x0(e.left),o=x0(e.right);if(n&&o&&xZ(n.reference,o.reference,t)){if("||"===e.operator&&n.isTrueWhenNullish&&o.isTrueWhenNullish&&x1(n,o))return{reference:n.reference,isTrueWhenNullish:!0};if("&&"===e.operator&&!n.isTrueWhenNullish&&!o.isTrueWhenNullish&&x1(n,o))return{reference:n.reference,isTrueWhenNullish:!1}}}function x3(e,t,r){let n=eZ(e,r);return!eQ(e,r)&&n6(e,{operator:"&&",property:t})&&(n=`(${n})`),n}function x8(e,t){let r=eZ(e,t);return!eQ(e,t)&&nQ(e)&&(r=`(${r})`),r}let x6="default-export-style/inline",x9="default-export-style/separate",x5="default-export-style/suggestion-inline",x4="default-export-style/suggestion-separate",x7="inline",be="separate",bt="ignore",br="class",bn="function",bo=()=>({enum:[x7,be,bt]}),ba=(e,t)=>e?.type==="ExportDefaultDeclaration"&&"Identifier"===e.declaration.type&&e.declaration.name===t,bi=e=>e.id?.name,bs=e=>{switch(e.type){case"ClassDeclaration":return br;case"FunctionDeclaration":return bn}},bl=e=>e===br?"classes":"functions",bu=(e,t)=>{let[,r]=e.sourceCode.getRange(t),n=e.sourceCode.getLoc(t).end.line;return t6(e).some(t=>e.sourceCode.getRange(t)[0]>=r&&e.sourceCode.getLoc(t).start.line===n)},bp=(e,t)=>ei(e,t)?.references.some(e=>!e.init&&e.isWrite())??!1,bc=e=>!!e&&!!(e.type.startsWith("TS")||e.typeAnnotation||e.typeParameters||e.returnType||e.implements?.length>0||e.superTypeArguments||e.accessibility||e.readonly||e.override||e.definite||e.optional&&"MemberExpression"!==e.type&&"CallExpression"!==e.type||e.abstract||e.declare||e.decorators?.length>0),bd=(e,t)=>{if(bc(e))return!0;for(let r of t[e.type]??[]){let n=e[r];if(Array.isArray(n)){if(n.some(e=>e?.type&&bd(e,t)))return!0;continue}if(n?.type&&bd(n,t))return!0}return!1},bm=(e,t)=>e.params.every(e=>!rm(e,t.sourceCode.visitorKeys)),bf=(e,t,r)=>ei(e,t)?.references.some(e=>!e.init&&e.identifier!==r)??!1,bg=(e,t)=>{let r=bi(e);if(r){let t=bs(e);return t&&{kind:t,name:r,declaration:e}}let n=((e,t)=>{if("VariableDeclaration"!==e.type||"const"!==e.kind||1!==e.declarations.length)return;let[r]=e.declarations;if(!("Identifier"!==r.id.type||bc(r.id)||r.init?.type!=="ArrowFunctionExpression"||bd(r.init,t.sourceCode.visitorKeys)))return r})(e,t);if(n)return{kind:bn,name:n.id.name,declaration:e,functionNode:n.init}},by=(e,t)=>e.params.map(e=>t.getText(e)).join(", "),bh=({context:e,declaration:t,exportDeclaration:r,name:n,scope:o,rangeStartNode:a=t})=>{if(!(e.sourceCode.getCommentsInside(r).length>e.sourceCode.getCommentsInside(t).length||bf(o,t.id,"Identifier"===r.declaration.type?r.declaration:void 0))&&"FunctionDeclaration"===t.type&&!t.generator&&!bd(t,e.sourceCode.visitorKeys)&&0===e.sourceCode.getCommentsInside(t).length&&bm(t,e)&&!rm(t.body,e.sourceCode.visitorKeys))return[{messageId:x4,fix:o=>o.replaceTextRange([e.sourceCode.getRange(a)[0],e.sourceCode.getRange(r)[1]],`const ${n} = ${t.async?"async ":""}(${by(t,e.sourceCode)}) => ${e.sourceCode.getText(t.body)};
|
|
19
|
+
export default ${n};`)}]},bx=({context:e,declaration:t,exportDeclaration:r,expectedStyle:n,kind:o,name:a,scope:i})=>{if(!(n===bt||((e,t,r)=>{let[,n]=e.sourceCode.getRange(t),[o]=e.sourceCode.getRange(r);return t6(e).some(t=>{let[r,a]=e.sourceCode.getRange(t);return r>=n&&a<=o})})(e,t,r)||bp(i,r.declaration))&&(o!==bn||"FunctionDeclaration"!==t.type||!t.generator)&&!(o===bn&&"FunctionDeclaration"===t.type&&bd(t,e.sourceCode.visitorKeys))){if(n===x7)return"VariableDeclaration"===t.type?{node:r,messageId:x6,data:{kind:o},suggest:(({context:e,declaration:t,exportDeclaration:r,name:n,scope:o})=>{let[{id:a,init:i}]=t.declarations;if(!(e.sourceCode.getCommentsInside(r).length>0||bu(e,r)||e.sourceCode.getCommentsInside(t).length>e.sourceCode.getCommentsInside(i).length||bf(o,a,r.declaration))&&"ArrowFunctionExpression"===i.type&&!bd(i,e.sourceCode.visitorKeys)&&0===e.sourceCode.getCommentsInside(i).length&&bm(i,e)&&!rm(i.body,e.sourceCode.visitorKeys))return[{messageId:x5,data:{kind:bn},fix:o=>o.replaceTextRange([e.sourceCode.getRange(t)[0],e.sourceCode.getRange(r)[1]],`export default ${i.async?"async ":""}function ${n}(${by(i,e.sourceCode)}) ${"BlockStatement"===i.body.type?e.sourceCode.getText(i.body):`{ return ${eZ(i.body,e)}; }`}`)}]})({context:e,declaration:t,exportDeclaration:r,name:a,scope:i})}:o===br&&bd(t,e.sourceCode.visitorKeys)?void 0:e.sourceCode.getCommentsInside(r).length>0||bu(e,r)?{node:r,messageId:x6,data:{kind:o}}:{node:r,messageId:x6,data:{kind:o},fix:function*(n){yield n.insertTextBefore(t,"export default "),yield n.removeRange([e.sourceCode.getRange(t)[1],e.sourceCode.getRange(r)[1]])}};if(n===be&&o===bn&&"FunctionDeclaration"===t.type)return{node:r,messageId:x9,data:{kind:o,style:"const arrow function"},suggest:bh({context:e,declaration:t,exportDeclaration:r,name:a,scope:i})}}},bb=({context:e,exportDeclaration:t,expectedStyle:r,kind:n})=>{let{declaration:o}=t,a=bi(o),i=e.sourceCode.getScope(t);if(!(!a||r===bt||r===x7||bp(i,a)||n===bn&&(o.generator||bd(o,e.sourceCode.visitorKeys)))){if(n===bn)return{node:t,messageId:x9,data:{kind:n,style:"const arrow function"},suggest:bh({context:e,declaration:o,exportDeclaration:t,name:a,scope:i,rangeStartNode:t})};if(!(n===br&&bd(o,e.sourceCode.visitorKeys)))return e.sourceCode.getCommentsInside(t).length>e.sourceCode.getCommentsInside(o).length?{node:t,messageId:x9,data:{kind:n,style:"class declaration"}}:{node:t,messageId:x9,data:{kind:n,style:"class declaration"},fix:r=>{let{declaration:n}=t;return r.replaceText(t,`${e.sourceCode.getText(n)}
|
|
20
|
+
export default ${n.id.name};`)}}}},bE={create:e=>{let t=e.options[0];e.on("Program",r=>{for(let[n,o]of r.body.entries()){if("ExportDefaultDeclaration"===o.type){let{declaration:r}=o,n=bs(r),a=bi(r);if(!n||!a)continue;let i=bb({context:e,exportDeclaration:o,expectedStyle:t[bl(n)],kind:n});if(i)return i;continue}let a=r.body[n+1],i=bg(o,e);if(!i||!ba(a,i.name))continue;let s=bx({context:e,exportDeclaration:a,expectedStyle:t[bl(i.kind)],scope:e.sourceCode.getScope(a),...i});if(s)return s}})},meta:{type:"suggestion",docs:{description:"Enforce consistent default export declarations.",recommended:!0},fixable:"code",hasSuggestions:!0,schema:[{type:"object",properties:{functions:bo(),classes:bo()},additionalProperties:!1}],defaultOptions:[{functions:x7,classes:x7}],messages:{[x6]:"Prefer declaring this default-exported {{kind}} inline.",[x9]:"Prefer declaring this default-exported {{kind}} as a separate {{style}}.",[x5]:"Use an inline default {{kind}} declaration.",[x4]:"Use a separate const arrow function default export."},languages:["js/js"]}};function bD(e){for(;;){let t=ry(e);if(t!==e){e=t;continue}if(e?.type!=="ParenthesizedExpression")return e;e=e.expression}}function bS(e,t){return ei(t.sourceCode.getScope(e),e)}let bv="no-array-concat-in-loop",bC="no-array-front-mutation",bA=["stream.unshift","this.unshift","this.stream.unshift","process.stdin.unshift","process.stdout.unshift","process.stderr.unshift"],bT="no-array-sort-for-min-max/error",bw="no-array-sort-for-min-max/suggestion",bk=e=>e8(e)&&0===e.value,bI=(e,t)=>{if(!td(e,{methods:["sort","toSorted"],argumentsLength:1,optionalCall:!1,optionalMember:!1})||rG(e.callee.object,t)||rh(e.callee.object))return;let[r]=e.arguments,n=(e=>{if(!tl(e)||e.async||e.generator||2!==e.params.length||e.params.some(e=>"Identifier"!==e.type))return;let t=ry((e=>{if("BlockStatement"!==e.body.type)return e.body;if(1!==e.body.body.length)return;let[t]=e.body.body;if("ReturnStatement"===t.type)return t.argument})(e));if(t?.type!=="BinaryExpression"||"-"!==t.operator)return;let[r,n]=e.params;if(r.name!==n.name){if(tQ(t.left,r)&&tQ(t.right,n))return"ascending";if(tQ(t.left,n)&&tQ(t.right,r))return"descending"}})(r);if(n)return{direction:n,node:e.callee.object}},bj=(e,t,r,n)=>{var o,a,i;let s=(o=t.direction,"first"===r?"ascending"===o?"min":"max":"ascending"===o?"max":"min"),l={node:e,messageId:bT,data:{method:s,extreme:"min"===s?"minimum":"maximum"}};if("Super"!==t.node.type&&0===n.sourceCode.getCommentsInside(e).length){let r,o=(a=t.node,i=n.sourceCode,r=nN(a)?i.getText(a):`(${i.getText(a)})`,`Math.${s}(...${r})`);l.suggest=[{messageId:bw,data:{replacement:o},fix:t=>t.replaceText(e,o)}]}return l},bF="no-boolean-sort-comparator",bB="no-boolean-sort-comparator/suggestion",bR=new Set(["sort","toSorted"]),b$=new Set([">",">=","<","<="]),bP=(e,t,r,n)=>(e=ry(e),t=ry(t),"Identifier"===e.type&&"Identifier"===t.type)?e.name===r.name&&t.name===n.name||e.name===n.name&&t.name===r.name:"MemberExpression"===e.type&&"MemberExpression"===t.type&&e.computed===t.computed&&(e.computed?!!tQ(e.property,t.property):e.property.name===t.property.name)&&bP(e.object,t.object,r,n),bL=(e,t)=>{for(;rg(e);){if(e.typeAnnotation&&nd(e.typeAnnotation,t,t.sourceCode.getScope(e)))return!0;e=e.expression}return!1},bN="no-chained-comparison/error",bM="no-chained-comparison/suggestion",bO=new Set(["<",">","<=",">="]),bq=new Set(["===","!==","==","!="]),bU=new Set([...bO,...bq]),bW=e=>"BinaryExpression"===e.type&&bU.has(e.operator),b_="no-constant-zero-expression/error",bV="no-constant-zero-expression/suggestion",bz="no-duplicate-logical-operands",bK="no-duplicate-logical-operands/suggestion",bG=new Set(["Identifier","ThisExpression","Literal"]),bJ=new Set(["Identifier","ThisExpression"]),bX=e=>{if(lx(e=ry(e)))return!1;switch(e.type){case"Identifier":case"Super":case"ThisExpression":return!0;case"MemberExpression":var t;return bX(e.object)&&(!e.computed||(t=ry(t=e.property),bG.has(t.type)));default:return!1}},bY="no-impossible-length-comparison",bH={"<":">","<=":">=",">":"<",">=":"<=","===":"===","!==":"!==","==":"==","!=":"!="},bZ="no-invalid-character-comparison",bQ=new Set(["==","===","!=","!=="]),b0=(e,t)=>!!(td(e,{method:"charAt",maximumArguments:1,optionalCall:!1,optionalMember:!1})&&nC(e.callee.object,t)||td(e,{method:"at",maximumArguments:1,optionalCall:!1,optionalMember:!1})&&nC(e.callee.object,t))||"MemberExpression"===e.type&&e.computed&&!e.optional&&(e=>{if(e8(e))return!0;if(!e1(e))return!1;let t=Number(e.value);return Number.isSafeInteger(t)&&t>=0&&String(t)===e.value})(e.property)&&nC(e.object,t),b1="no-loop-iterable-mutation",b2=["copyWithin","fill","pop","push","reverse","shift","sort","splice","unshift"],b3=["add","clear","delete"],b8=["clear","delete","set"],b6={array:new Set(b2),set:new Set(b3),map:new Set(b8),unknown:new Set([...b2,...b3,...b8])},b9=new Set(["entries","keys","values"]),b5=new Set(["ArrowFunctionExpression","ClassDeclaration","ClassExpression","FunctionDeclaration","FunctionExpression"]);function b4(e,t){return rK(e,t)?"array":rY(e,t)?"set":rH(e,t)?"map":void 0}function b7(e){return"VariableDeclaration"===e.left.type?e.left.declarations[0].id:e.left}function Ee(e){return"Identifier"===(e=ry(e)).type?e:void 0}function Et(e){if("ArrayPattern"!==(e=ry(e)).type)return;let[t]=e.elements;return t&&Ee(t)}function Er(e,t){if(lx(e=ry(e)))return;if(lh(e))return{collectionKind:b4(e,t),reference:e,method:"direct"};if("CallExpression"!==e.type||"MemberExpression"!==e.callee.type||e.arguments.length>0)return;let r=eI(e.callee,t.sourceCode.getScope(e.callee));if(!(!b9.has(r)||lx(e.callee.object))&&lh(e.callee.object))return{collectionKind:b4(e.callee.object,t),reference:e.callee.object,method:r}}function En(e,t){let r=b7(e);return"keys"===t.method?Ee(r):"entries"===t.method||"direct"===t.method&&"set"!==t.collectionKind?Et(r):void 0}function Eo(e,t){let r,n;if("VariableDeclaration"!==e.left.type||"const"!==e.left.kind)return{collectionKind:t.collectionKind,iterable:t.reference,loopBody:e.body};let o=(r=b7(e),"entries"===t.method?Et(r):"direct"!==t.method||"map"!==t.collectionKind?Ee(r):void 0),a=En(e,t),i=(n=b7(e),"set"===t.collectionKind&&("direct"===t.method||"values"===t.method)?Ee(n):"direct"===t.method&&"map"!==t.collectionKind?Ee(n)??Et(n):En(e,t));return{addArgumentIdentifier:o,collectionKind:t.collectionKind,deleteArgumentIdentifier:i,iterable:t.reference,loopBody:e.body,setKeyIdentifier:a}}function*Ea(e){"Identifier"===(e=ry(e)).type?yield e:"MemberExpression"===e.type&&(yield*Ea(e.object),e.computed&&(yield*Ea(e.property)))}function Ei(e,t,r){if(!ly(e,t))return!1;let n=[...Ea(e)],o=[...Ea(t)];return n.length!==o.length||0===n.length?n.length===o.length:n.every((e,t)=>{var n;let a,i;return n=o[t],a=ei(r.sourceCode.getScope(e),e),i=ei(r.sourceCode.getScope(n),n),a||i?a===i:e.name===n.name})}function Es(e,t,r){let[n]=e.arguments;return!!(t&&n&&Ei(n,t,r))}function El(e,t,r,n){return"add"===r&&Es(e,t.addArgumentIdentifier,n)||"set"===r&&Es(e,t.setKeyIdentifier,n)}let Eu="no-selector-as-dom-name",Ep=["add","remove","contains","toggle","replace"],Ec=/^[#.]-?[A-Z_a-z][\w-]*$/u,Ed=new Set([".","#"]),Em=e=>Ed.has(e?.[0]),Ef=e=>e3(e)??("TemplateLiteral"===e.type&&e.quasis[0].value.cooked),Eg=(e,t,r,n)=>({node:e,messageId:Eu,fix:((e,t,r,n)=>{let o=((e,t)=>{let[r]=t.getRange(e);return[r+1,r+2]})(e,n);if(t.startsWith(r)&&n.text[o[0]]===r){if("TemplateLiteral"===e.type&&e.expressions.length>0){if(1!==e.expressions.length||e.quasis[0].value.cooked!==r||""!==e.quasis[1].value.cooked)return;return e=>e.removeRange(o)}if(Ec.test(t))return e=>e.removeRange(o)}})(e,t,r,n)}),Ey=(e,t)=>e.map(e=>({node:e,expectedPrefix:t})),Eh="no-useless-compound-assignment/error",Ex="no-useless-compound-assignment/remove",Eb="no-useless-compound-assignment/replace",EE=new Map([["+=",0],["-=",0],["*=",1],["/=",1],["**=",1]]),ED="no-useless-delete-check",ES="removeCheck",Ev={considerGetters:!0},EC=new Set(["Map","Set","WeakMap","WeakSet"]),EA=new Set(["ArrayExpression","ArrowFunctionExpression","ClassExpression","FunctionExpression","ObjectExpression"]),ET=new Set(["ClassName","FunctionName"]),Ew=new Set(["TSConstructorType","TSFunctionType","TSObjectKeyword"]),Ek=e=>null!==e&&("object"==typeof e||"function"==typeof e),EI=e=>!!Ew.has(e?.type)||e?.type==="TSUnionType"&&e.types.every(e=>EI(e)),Ej=(e,t)=>{if("Identifier"!==e.type)return!1;let r=ei(t.sourceCode.getScope(e),e);return r?.defs.some(e=>ET.has(e.type))??!1},EF=(e,t)=>{let r=ew(e,t.sourceCode.getScope(e));return r&&"symbol"!=typeof r.value&&!Ek(r.value)?String(r.value):void 0},EB=(e,t)=>{let r=ew(e,t.sourceCode.getScope(e));if(r)return Ek(r.value);let n=ra(ry(e),t);if(n){let e=ry(n),r=ew(e,t.sourceCode.getScope(e));if(r)return Ek(r.value);if(EA.has(e.type))return!0}return!Ej(ry(e),t)&&EI(((e,t)=>{if("Identifier"!==(e=ry(e)).type)return;let r=ei(t.sourceCode.getScope(e),e);return r?.defs[0]?.name?.typeAnnotation?.typeAnnotation??e.typeAnnotation?.typeAnnotation})(e,t))},ER=(e,t)=>!eP(e,t.sourceCode,Ev),E$=(e,t)=>td(e,{method:t,argumentsLength:1,computed:!1,optionalCall:!1,optionalMember:!1,allowSpreadElement:!1}),EP=(e,t,r)=>n=>{if(re(r,r.sourceCode.getRange(e)))return;let o=r.sourceCode.getText(t.parent);return o.trimEnd().endsWith(";")||(o+=";"),nW(r.sourceCode.getTokenBefore(e),r,o)&&(o=`;${o}`),n.replaceText(e,o)},EL="no-useless-logical-operand",EN=new Map([["&&",!0],["||",!1]]),EM=new Map([["&&",!1],["||",!0]]),EO=new Set(["FunctionExpression","ClassExpression","ObjectExpression"]),Eq="prefer-boolean-return",EU=new Set(["==","!=","===","!==","<","<=",">",">=","in","instanceof"]);function EW(e){if(e){if("BlockStatement"===e.type){let t=e.body.filter(({type:e})=>"EmptyStatement"!==e);if(1===t.length)return EW(t[0])}return e}}let E_=e=>{if(e?.type==="ReturnStatement"&&e.argument?.type==="Literal"&&"boolean"==typeof e.argument.value)return e.argument.value};function EV(e,t){switch(e.type){case"Literal":return"boolean"==typeof e.value;case"UnaryExpression":return["!","delete"].includes(e.operator);case"BinaryExpression":return EU.has(e.operator);case"LogicalExpression":return EV(e.left,t)&&EV(e.right,t);case"CallExpression":return tC(e,t)||"CallExpression"===e.type&&!e.optional&&"MemberExpression"===e.callee.type&&!e.callee.optional&&!e.callee.computed&&"Identifier"===e.callee.object.type&&"Array"===e.callee.object.name&&t.sourceCode.isGlobalReference(e.callee.object)&&"Identifier"===e.callee.property.type&&"isArray"===e.callee.property.name;default:return!1}}let Ez="prefer-continue",EK=new Set(["ClassDeclaration","FunctionDeclaration","TSEnumDeclaration","TSInterfaceDeclaration","TSModuleDeclaration","TSTypeAliasDeclaration"]),EG=new Set(["const","let"]),EJ=(e,t)=>{let r=e.text.lastIndexOf("\n",t-1)+1;return/^[\t ]*/.exec(e.text.slice(r,t))[0]},EX=(e,[t,r],n)=>{let[o,a]=n.getRange(e);return o>=t&&a<=r},EY=e=>"VariableDeclaration"===e.type&&"var"!==e.kind&&!EG.has(e.kind)||EK.has(e.type),EH=(e,t)=>{let r=t.getTokenAfter(t.getFirstToken(e)),n=t.getTokenBefore(e.consequent);return[t.getRange(r)[1],t.getRange(n)[0]]},EZ=(e,t)=>{if(e7(e,{name:"eval",optional:!1}))return!0;for(let r of t.visitorKeys[e.type]??[]){let n=e[r];if(Array.isArray(n)){for(let e of n)if(e&&EZ(e,t))return!0;continue}if(n&&EZ(n,t))return!0}return!1},EQ={create:e=>{let{maximumStatements:t}=e.options[0];e.on(tu,r=>{if("BlockStatement"!==r.body.type||1!==r.body.body.length)return;let[n]=r.body.body;if("IfStatement"!==n.type||n.alternate||("EmptyStatement"===n.consequent.type?0:"BlockStatement"===n.consequent.type?n.consequent.body.length:1)<=t)return;let o=((e,t)=>{if(((e,t)=>{let r,n,{sourceCode:o}=t;return((e,t)=>{let{sourceCode:r}=t,{consequent:n}=e;return!(EY(n)||"BlockStatement"===n.type&&n.body.some(e=>EY(e)))&&((e,t)=>{var r;let n=(r=e.consequent,"BlockStatement"!==r.type?[]:r.body.flatMap(e=>"VariableDeclaration"===e.type&&EG.has(e.kind)?t.getDeclaredVariables(e):[]));if(0===n.length)return!0;let o=new Set(n.map(e=>e.name));return!EZ(e.test,t)&&!((e,t,r)=>{let[n,o]=t.getRange(e),a=e=>e.references.some(e=>{let[a,i]=t.getRange(e.identifier);return a>=n&&i<=o&&r.has(e.identifier.name)&&!(e.resolved&&e.resolved.identifiers.some(e=>EX(e,[n,o],t)))})||e.childScopes.some(e=>a(e));return a(t.getScope(e))})(e.test,t,o)})(e,r)&&!ro(n,t)})(e,t)&&(r=EH(e,o),n=o.getRange(e.consequent),!o.getCommentsInside(e).some(e=>!EX(e,r,o)&&!EX(e,n,o)))&&!("BlockStatement"!==e.consequent.type&&o.getText(e.consequent).includes("\n"))&&0===o.getCommentsAfter(e).length})(e,t))return r=>r.replaceText(e,((e,t)=>{let{sourceCode:r}=t,n=EJ(r,r.getRange(e)[0]),o=((e,t)=>{let r,n,{sourceCode:o}=t;if(r=EH(e,o),n=o.getRange(e.test),o.getCommentsInside(e).some(e=>EX(e,r,o)&&!EX(e,n,o))){let t=o.text.slice(...EH(e,o)).trimStart();return`!(${t})`}return((e,t)=>{let{sourceCode:r}=t;if("UnaryExpression"===e.type&&"!"===e.operator&&e.prefix){let n=r.getFirstToken(e),o=r.getRange(n),a=r.getRange(e),i=r.getRange(e.argument);return r.getCommentsInside(e).some(e=>r.getRange(e)[0]>=o[1]&&r.getRange(e)[1]<=i[0])?r.text.slice(o[1],a[1]).trim():eZ(e.argument,t)}let n=r.getText(e);return n8(e,"!")?`!(${n})`:`!${n}`})(e.test,t)})(e,t),a=((e,t)=>{let{consequent:r}=e;return"BlockStatement"===r.type?((e,t,r)=>{let n=r.getFirstToken(e),o=r.getLastToken(e),a=r.text.slice(r.getRange(n)[1],r.getRange(o)[0]);if(!a.includes("\n")){let e=a.trim();return e?`${EJ(r,r.getRange(t)[0])}${e}`:""}let i=a.split("\n");if(i[0]?.trim()===""&&i.shift(),i.at(-1)?.trim()===""&&i.pop(),0===i.length)return"";let s=r.getTokenAfter(n,{includeComments:!0}),l=EJ(r,r.getRange(t)[0]),u=s&&s!==o?EJ(r,r.getRange(s)[0]):`${l} `;return i.map(e=>""===e.trim()?"":e.startsWith(u)?`${l}${e.slice(u.length)}`:`${l}${e.trimStart()}`).join("\n")})(r,e,t):`${EJ(t,t.getRange(e)[0])}${t.getText(r).trim()}`})(e,r);return`if (${o}) {
|
|
21
21
|
${n} continue;
|
|
22
22
|
${n}}
|
|
23
23
|
|
|
24
|
-
${a}`})(e,t))})(n,e);return{node:n,messageId:
|
|
24
|
+
${a}`})(e,t))})(n,e);return{node:n,messageId:Ez,...o&&{fix:o}}})},meta:{type:"suggestion",docs:{description:"Prefer early continues over whole-loop conditional wrapping.",recommended:!0},fixable:"code",schema:[{type:"object",additionalProperties:!1,properties:{maximumStatements:{type:"integer",minimum:0,description:"Maximum number of statements allowed in a whole-loop conditional wrapper."}}}],defaultOptions:[{maximumStatements:1}],messages:{[Ez]:"Prefer an early continue over wrapping the whole loop body in an `if` statement."},languages:["js/js"]}},E0="prefer-flat-math-min-max",E1=["min","max"],E2=(e,t)=>td(e,{object:"Math",method:t,optionalCall:!1,optionalMember:!1}),E3=(e,t)=>{let r=[];for(let n of e.arguments){if(E2(n,t)){r.push(...E3(n,t));continue}r.push(n)}return r},E8="prefer-hoisting-branch-code/start",E6="prefer-hoisting-branch-code/end",E9="prefer-hoisting-branch-code/suggestion",E5=new Set(["await using","using"]);function E4(e,t){if("TaggedTemplateExpression"===e.type||eP(e,t))return!0;for(let r of t.visitorKeys[e.type]??[]){let n=e[r];if(Array.isArray(n)){for(let e of n)if(e&&E4(e,t))return!0;continue}if(n&&E4(n,t))return!0}return!1}let E7=(e,t)=>{let r=t.getTokens(e),n=r.at(-1);return n?.type==="Punctuator"&&";"===n.value?r.slice(0,-1):r},De=(e,t,r)=>{let n=E7(e,r),o=E7(t,r);return 0!==n.length&&n.length===o.length&&n.every((e,t)=>e.type===o[t].type&&e.value===o[t].value)};function Dt(e,{leading:t,trailing:r,isStart:n},o){let{sourceCode:a}=o,{body:i}=e;if(n){let[e]=a.getRange(i[0]),[r]=a.getRange(i[t]);return[e,r]}let[,s]=a.getRange(i[i.length-r-1]),[,l]=a.getRange(i.at(-1));return[s,l]}function Dr({ifStatement:e,blocks:t,leading:r,trailing:n,isStart:o},a){var i;let{sourceCode:s}=a,l=t[0].body,u=o?l.slice(0,r):l.slice(l.length-n),p=u.every(e=>!rn(e))&&function(e){let{parent:t}=e;return["Program","BlockStatement","StaticBlock","SwitchCase"].includes(t.type)}(e)&&!((i={leading:r,trailing:n,isStart:o}).isStart&&((e,t)=>{let{sourceCode:r}=t,[n]=r.getRange(e),o=r.getTokenBefore(e);return re(t,[o?r.getRange(o)[1]:0,n])})(e,a)||!i.isStart&&((e,t)=>{let{sourceCode:r}=t,n=r.getCommentsAfter(e)[0];return!!(n&&r.getLoc(n).start.line===r.getLoc(e).end.line)})(e,a)||t.some(e=>{let{sourceCode:t}=a,[r]=t.getRange(e),[n]=t.getRange(e.body[0]);if(i.isStart&&re(a,[r+1,n]))return!0;if(!i.isStart){let[,r]=t.getRange(e.body.at(-1)),[,n]=t.getRange(e);if(re(a,[r,n-1]))return!0}return re(a,Dt(e,i,a))}))&&(o||t.every(e=>!function(e,t,r){let{sourceCode:n}=r,{body:o}=e,[a]=n.getRange(o[o.length-t]),[i,s]=n.getRange(e);for(let t of n.getScope(e).variables){let[e]=t.defs;if(!e||e.parent?.type==="VariableDeclaration"&&"var"===e.parent.kind)continue;let[r]=n.getRange(e.name);if(!(r<=i)&&!(r>=a)){if(e.parent?.type==="VariableDeclaration"&&E5.has(e.parent.kind))return!0;for(let e of t.references){let[t]=n.getRange(e.identifier);if(t>=a&&t<=s)return!0}}}return!1}(e,n,a))),c={loc:{start:s.getLoc(u[0]).start,end:s.getLoc(u.at(-1)).end},messageId:o?E8:E6};if(p){let i=function({ifStatement:e,blocks:t,leading:r,trailing:n,isStart:o},a){let{sourceCode:i}=a,s=t8(e,a),l=o?r:n,u=t[0].body,p=o?u.slice(0,l):u.slice(u.length-l),c=function(e,t,r){let{sourceCode:n}=r,[o]=n.getRange(e[0]),[,a]=n.getRange(e.at(-1)),i=n.text.slice(o,a),s=t8(e[0],r);return s===t?i:i.split("\n").map((e,r)=>0===r?e:e.startsWith(s)?`${t}${e.slice(s.length)}`:e).join("\n")}(p,s,a);return function*(l){if(o){let t=i.getTokenBefore(e),r=t&&nW(t,a,c)?";":"";yield l.insertTextBefore(e,`${r}${c}
|
|
25
25
|
${s}`)}else{let t=i.getLastToken(p.at(-1)),r=i.getTokenAfter(e),n=r&&nW(t,a,r.value)?";":"";yield l.insertTextAfter(e,`
|
|
26
|
-
${s}${c}${n}`)}for(let e of t)yield l.removeRange(Dc(e,{leading:r,trailing:n,isStart:o},a))}}({ifStatement:e,blocks:t,leading:r,trailing:n,isStart:o},a);!o||function(e,t){for(let r=e;r?.type==="IfStatement";r=r.alternate)if(Dl(r.test,t))return!1;return!0}(e,s)&&u.every(e=>"ExpressionStatement"===e.type&&!Dl(e,s))?c.fix=i:c.suggest=[{messageId:Di,fix:i}]}return c}let{parse:Dm}=im,Df="prefer-single-replace",Dg=new Set(["g","m","s"]),Dy=new Map([["\\",String.raw`\\`],["]",String.raw`\]`],["\n",String.raw`\n`],["\r",String.raw`\r`],[" ",String.raw`\t`],["\f",String.raw`\f`],["\v",String.raw`\v`],["\u2028",String.raw`\u2028`],["\u2029",String.raw`\u2029`]]);function Dh(e){if(!td(e,{methods:["replace","replaceAll"],argumentsLength:2,optionalCall:!1,optionalMember:!1,computed:!1}))return;let[t]=e.arguments;if(e1(t)){if("replaceAll"!==e.callee.property.name)return;return 1===t.value.length?t.value:void 0}if(e6(t))return function({pattern:e,flags:t}){let r;if(t.includes("g")){for(let e of t)if(!Dg.has(e))return;try{r=Dm(e,t,{namedGroups:!0,lookbehind:!0})}catch{return}return function e(t){return"value"===t.type?String.fromCodePoint(t.codePoint):("alternative"!==t.type||1!==t.body.length)&&("characterClass"!==t.type||t.negative||1!==t.body.length)?void 0:e(t.body[0])}(r)}}(t.regex)}let Dx={configs:{node:{name:"@eslint-sukka/eslint-plugin-sukka-full node preset",plugins:{get sukka(){return Dx}},rules:{"sukka/unicorn/prefer-node-protocol":"error","sukka/unicorn/prefer-import-meta-properties":"error","no-process-exit":"off","sukka/unicorn/no-process-exit":"warn","no-buffer-constructor":"off","sukka/unicorn/no-new-buffer":"error"}},comment:{name:"@eslint-sukka/eslint-plugin-sukka-full comments preset",plugins:{get sukka(){return Dx}},rules:{"sukka/ban-eslint-disable":["error","allow-with-description"]}},recommended:{...u.eslint_plugin_sukka.configs.recommended,plugins:{get sukka(){return Dx}},rules:{...u.eslint_plugin_sukka.configs.recommended.rules,"sukka/prefer-single-boolean-return":"off","sukka/array/no-unneeded-flat-map":"error","sukka/browser/prefer-location-assign":"warn","sukka/jsx/no-template-literal":"error","sukka/jsx/no-unneeded-nested":"error","sukka/string/no-locale-case":"warn","sukka/string/no-simple-template-literal":"error","sukka/unicode/no-bidi":"warn","sukka/unicode/no-invisible":"warn","sukka/no-redundant-variable":"error","sukka/no-single-return":"warn","sukka/prefer-early-return":["error",{maximumStatements:16}],"sukka/prefer-fetch":"error","sukka/prefer-timer-id":"warn"}},recommended_unicorn:{name:"@eslint-sukka/eslint-plugin-sukka-full recommended unicorn preset",plugins:{get sukka(){return Dx}},rules:{"sukka/unicorn/no-lonely-if":"error","sukka/unicorn/no-negated-condition":"warn","sukka/unicorn/catch-error-name":["error",{ignore:[/^(?:e|err|error|\w+Err|\w+Error)[\d_]?$/]}],"sukka/unicorn/custom-error-definition":"error","sukka/unicorn/require-array-join-separator":"warn","sukka/unicorn/no-thenable":"error","sukka/unicorn/no-invalid-remove-event-listener":"error","sukka/unicorn/consistent-function-scoping":"warn","sukka/unicorn/prefer-event-target":"warn","sukka/unicorn/prefer-keyboard-event-key":"warn","sukka/unicorn/prefer-text-content":"warn","sukka/unicorn/no-console-spaces":"warn","sukka/unicorn/no-empty-file":"warn","sukka/unicorn/no-useless-fallback-in-spread":"warn","sukka/unicorn/no-useless-length-check":"warn","sukka/unicorn/no-useless-promise-resolve-reject":"warn","sukka/unicorn/no-zero-fractions":"warn","sukka/unicorn/prefer-export-from":["warn",{checkUsedVariables:!1}],"sukka/unicorn/prefer-native-coercion-functions":"warn","sukka/unicorn/prefer-negative-index":"warn","sukka/unicorn/no-document-cookie":"error","sukka/unicorn/prefer-add-event-listener":"warn","sukka/unicorn/prefer-array-index-of":"warn","sukka/unicorn/prefer-blob-reading-methods":"warn","sukka/unicorn/prefer-date-now":"warn","sukka/unicorn/dom-node-dataset":"warn","sukka/unicorn/prefer-modern-math-apis":"warn","sukka/unicorn/number-literal-case":"error","sukka/unicorn/prefer-number-properties":["warn",{checkInfinity:!1}],"sukka/unicorn/prefer-reflect-apply":"warn","sukka/unicorn/prefer-set-size":"warn","sukka/unicorn/prefer-string-replace-all":"warn","sukka/unicorn/prefer-string-slice":"warn","sukka/unicorn/prefer-string-trim-start-end":"warn","sukka/unicorn/no-unreadable-iife":"warn","sukka/unicorn/throw-new-error":"warn","sukka/unicorn/escape-case":"warn","sukka/unicorn/prefer-unicode-code-point-escapes":"warn","sukka/unicorn/prefer-prototype-methods":"warn","sukka/unicorn/error-message":"error","sukka/unicorn/no-instanceof-builtins":["error",{strategy:"loose"}],"sukka/unicorn/prefer-type-error":"error","sukka/unicorn/consistent-destructuring":"warn","sukka/unicorn/new-for-builtins":"warn","sukka/unicorn/prefer-single-call":"warn","sukka/unicorn/no-static-only-class":"warn","sukka/unicorn/no-unreadable-array-destructuring":"error","sukka/unicorn/no-useless-spread":"error","sukka/unicorn/no-useless-switch-case":"warn","sukka/unicorn/no-useless-undefined":["error",{checkArguments:!1}],"sukka/unicorn/numeric-separators-style":["warn",{onlyIfContainsSeparator:!1,number:{minimumDigits:7,groupLength:3},binary:{minimumDigits:9,groupLength:4},octal:{minimumDigits:9,groupLength:4},hexadecimal:{minimumDigits:5,groupLength:2}}],"sukka/unicorn/prefer-array-find":"warn","sukka/unicorn/prefer-array-flat-map":"warn","sukka/unicorn/prefer-array-flat":"warn","sukka/unicorn/prefer-array-some":"warn","sukka/unicorn/prefer-code-point":"warn","sukka/unicorn/prefer-default-parameters":"warn","sukka/unicorn/prefer-logical-operator-over-ternary":"warn","sukka/unicorn/prefer-optional-catch-binding":"error","sukka/unicorn/prefer-regexp-test":"warn","sukka/unicorn/prefer-set-has":"error","sukka/unicorn/prefer-switch":"warn","sukka/unicorn/require-number-to-fixed-digits-argument":"warn","sukka/unicorn/prefer-string-raw":"warn","sukka/unicorn/no-single-promise-in-promise-methods":"error","sukka/unicorn/no-await-in-promise-methods":"error","sukka/unicorn/no-magic-array-flat-depth":"error","sukka/unicorn/no-object-as-default-parameter":"error","sukka/unicorn/template-indent":["warn",{tags:["outdent","dedent","gql","sql","html","styled","css"],functions:["dedent","stripIndent","strip_indent","stripTags","striptags","strip_tags","stripHtml","stripHTML","strip_html"],selectors:[],comments:["HTML","html","CSS","css","indent"]}],"sukka/unicorn/no-negation-in-equality-check":"error","sukka/unicorn/no-unnecessary-slice-end":"error","sukka/unicorn/consistent-date-clone":"error","sukka/unicorn/no-accessor-recursion":"error","sukka/unicorn/no-unnecessary-array-flat-depth":"error","sukka/unicorn/no-unnecessary-array-splice-count":"error","sukka/unicorn/no-useless-error-capture-stack-trace":"error","sukka/unicorn/prefer-class-fields":"error","sukka/unicorn/prefer-bigint-literals":"error","sukka/unicorn/prefer-classlist-toggle":"warn","sukka/unicorn/require-module-attributes":"error","sukka/unicorn/no-immediate-mutation":"error","sukka/unicorn/no-useless-collection-argument":"error","sukka/unicorn/prefer-response-static-json":"error","sukka/unicorn/consistent-template-literal-escape":"error","sukka/unicorn/no-useless-iterator-to-array":"error","sukka/unicorn/prefer-simple-condition-first":"error","sukka/unicorn/switch-case-break-position":"error","sukka/unicorn/better-dom-traversing":"warn","sukka/unicorn/no-blob-to-file":"error","sukka/unicorn/no-canvas-to-image":"warn","sukka/unicorn/no-confusing-array-splice":"error","sukka/unicorn/no-duplicate-set-values":"error","sukka/unicorn/no-incorrect-query-selector":"error","sukka/unicorn/no-invalid-file-input-accept":"error","sukka/unicorn/no-late-current-target-access":"error","sukka/unicorn/no-unused-array-method-return":"error","sukka/unicorn/prefer-array-last-methods":"warn","sukka/unicorn/prefer-math-abs":"warn","sukka/unicorn/prefer-split-limit":"warn","sukka/unicorn/prefer-queue-microtask":"warn","sukka/unicorn/prefer-string-pad-start-end":"warn","sukka/unicorn/require-css-escape":"error","sukka/unicorn/require-passive-events":"warn","sukka/unicorn/class-reference-in-static-methods":"warn","sukka/unicorn/consistent-optional-chaining":"error","sukka/unicorn/explicit-timer-delay":"warn","sukka/unicorn/no-confusing-array-with":"error","sukka/unicorn/no-duplicate-loops":"warn","sukka/unicorn/no-declarations-before-early-exit":"warn","sukka/unicorn/no-optional-chaining-on-undeclared-variable":"error","sukka/unicorn/no-object-methods-with-collections":"error","sukka/unicorn/no-subtraction-comparison":"warn","sukka/unicorn/no-unnecessary-global-this":"warn","sukka/unicorn/no-useless-else":"error","sukka/unicorn/no-useless-recursion":"error","sukka/unicorn/prefer-add-event-listener-options":"warn","sukka/unicorn/prefer-direct-iteration":"warn","sukka/unicorn/prefer-number-is-safe-integer":"warn","sukka/unicorn/prefer-object-define-properties":"warn","sukka/unicorn/prefer-object-destructuring-defaults":"warn","sukka/unicorn/prefer-single-object-destructuring":"warn","sukka/unicorn/prefer-smaller-scope":"warn","sukka/unicorn/prefer-single-array-predicate":"warn","sukka/unicorn/prefer-url-href":"warn","sukka/unicorn/require-proxy-trap-boolean-return":"error","sukka/unicorn/logical-assignment-operators":"error","sukka/unicorn/no-useless-coercion":"error","sukka/unicorn/no-useless-boolean-cast":"warn","sukka/unicorn/no-useless-continue":"error","sukka/unicorn/no-useless-override":"error","sukka/unicorn/prefer-has-check":"warn","sukka/unicorn/prefer-minimal-ternary":"warn","sukka/unicorn/consistent-conditional-object-spread":"error","sukka/unicorn/no-boolean-sort-comparator":"error","sukka/unicorn/no-chained-comparison":"error","sukka/unicorn/no-constant-zero-expression":"error","sukka/unicorn/no-duplicate-logical-operands":"error","sukka/unicorn/no-impossible-length-comparison":"error","sukka/unicorn/no-invalid-character-comparison":"error","sukka/unicorn/no-loop-iterable-mutation":"error","sukka/unicorn/no-selector-as-dom-name":"error","sukka/unicorn/no-array-concat-in-loop":"error","sukka/unicorn/no-array-front-mutation":"warn","sukka/unicorn/no-array-sort-for-min-max":"warn","sukka/unicorn/no-useless-compound-assignment":"warn","sukka/unicorn/no-useless-delete-check":"warn","sukka/unicorn/no-useless-logical-operand":"error","sukka/unicorn/prefer-boolean-return":"warn","sukka/unicorn/prefer-continue":"warn","sukka/unicorn/prefer-flat-math-min-max":"warn","sukka/unicorn/prefer-hoisting-branch-code":"warn","sukka/unicorn/prefer-single-replace":"warn"}},stylistic_unicorn:{name:"@eslint-sukka/eslint-plugin-sukka-full stylistic unicorn preset",plugins:{get sukka(){return Dx}},rules:{"sukka/unicorn/no-nested-ternary":"warn","sukka/unicorn/filename-case":["error",{cases:{kebabCase:!0,snakeCase:!0},ignore:[/fixtures/i,/^_/,/^\./,/rc$/i,/\.(md|json|yaml|toml|yml|ini|conf|jsonc|json5)$/i]}],"sukka/unicorn/no-unnecessary-nested-ternary":"error","sukka/unicorn/no-unreadable-object-destructuring":"error","sukka/unicorn/consistent-compound-words":"warn","sukka/unicorn/default-export-style":"warn"}},recommended_extra_with_typed_lint:{...u.eslint_plugin_sukka.configs.recommended_extra_with_typed_lint,plugins:{get sukka(){return Dx}},rules:{...u.eslint_plugin_sukka.configs.recommended_extra_with_typed_lint.rules,"sukka/string/no-unneeded-to-string":"error","sukka/type/no-force-cast-via-top-type":"error","sukka/type/no-wrapper-type-reference":"error","sukka/no-default-error":"off"}},recommended_react:{...u.eslint_plugin_sukka.configs.recommended_react,plugins:{get sukka(){return Dx}}}},rules:Object.assign(u.eslint_plugin_sukka.rules,{"array/no-unneeded-flat-map":A,"browser/prefer-location-assign":w,"jsx/no-template-literal":I,"jsx/no-unneeded-nested":j,"string/no-locale-case":B,"string/no-simple-template-literal":R,"unicode/no-bidi":q,"unicode/no-invisible":W,"no-redundant-variable":_,"no-single-return":z,"prefer-early-return":G,"prefer-fetch":J,"prefer-timer-id":H,"string/no-unneeded-to-string":Z,"type/no-force-cast-via-top-type":Q,"type/no-wrapper-type-reference":et,"no-default-error":er},Object.fromEntries(Object.entries({"unicorn/catch-error-name":pW,"unicorn/custom-error-definition":{create:e=>{e.on("ClassDeclaration",t=>ce(e,t)),e.on("AssignmentExpression",t=>{if("ClassExpression"===t.right.type)return ce(e,t.right)}),e.on("AssignmentExpression",e=>{if("MemberExpression"===e.left.type&&"Identifier"===e.left.object.type&&"exports"===e.left.object.name){let t=e.right;if("ClassExpression"!==t.type||!pZ(t)||!t.id)return;let r=t.id.name;return e.left.property.name!==r?{node:e.left.property,messageId:p_,fix:t=>t.replaceText(e.left.property,r)}:void 0}})},meta:{type:"problem",docs:{description:"Enforce correct `Error` subclassing.",recommended:!1},fixable:"code",messages:{[p_]:"Exported error name should match error class",[pV]:"Do not pass the error message to `super()` when the class defines a `message` accessor.",[pz]:"Do not assign to `this.message` when the class defines a `message` getter without a setter.",[pK]:"Error constructors should accept `options` as the second parameter.",[pG]:"Error constructors should use `options` as the second parameter.",[pJ]:"Pass the error message to `super()` as the first argument.",[pX]:"Pass `options` to `super()` as the second argument."},languages:["js/js"]}},"unicorn/no-nested-ternary":{create:e=>{e.on("ConditionalExpression",t=>{if([t.test,t.consequent,t.alternate].some(e=>"ConditionalExpression"===e.type))return;let{sourceCode:r}=e,n=r.getAncestors(t).toReversed(),o=n.findIndex(e=>"ConditionalExpression"!==e.type);return 1!==o||eQ(t,e)?o>1?{node:o>2?n[o-3]:t,messageId:oi}:void 0:{node:t,messageId:os,fix:e=>[e.insertTextBefore(t,"("),e.insertTextAfter(t,")")]}})},meta:{type:"suggestion",docs:{description:"Disallow nested ternary expressions.",recommended:!0},fixable:"code",messages:{[oi]:"Do not nest ternary expressions.",[os]:"Nested ternary expression should be parenthesized."},languages:["js/js"]}},"unicorn/prefer-event-target":{create:e=>{e.on("Identifier",t=>{if("EventEmitter"!==t.name||("ClassDeclaration"!==t.parent.type&&"ClassExpression"!==t.parent.type||t.parent.superClass!==t)&&("NewExpression"!==t.parent.type||t.parent.callee!==t))return;let r=e.sourceCode.getScope(t);if(!function(e){if(!e)return!1;let t=function(e,t){let r=e=>e.type===t;for(;e.parent;e=e.parent)if(r(e))return e}(e,"ImportDeclaration");return!!(ou.has(t?.source.value)||"Property"===e.parent.type&&e.parent.value===e&&"Identifier"===e.parent.key.type&&"EventEmitter"===e.parent.key.name&&"ObjectPattern"===e.parent.parent.type&&e.parent.parent.properties.includes(e.parent)&&op(e.parent.parent)&&oc(e.parent.parent.parent.init))||!!(op(e)&&tc(e.parent.init,{property:"EventEmitter",optional:!1,computed:!1})&&oc(e.parent.init.object))}(ei(r,t)?.defs[0]?.name))return{node:t,messageId:ol}})},meta:{type:"suggestion",docs:{description:"Prefer `EventTarget` over `EventEmitter`.",recommended:"unopinionated"},messages:{[ol]:"Prefer `EventTarget` over `EventEmitter`."},languages:["js/js"]}},"unicorn/prefer-keyboard-event-key":{create:e=>{e.on("Identifier",t=>{if(og.has(t.name)){for(let r of oE(e,t))if(r.references?.some(e=>ob(t,e.identifier)))return oD(t,r)}}),e.on("Property",t=>{let r;if("Identifier"===t.key.type&&og.has(t.key.name)&&"Property"===(r=t.key).parent.type&&r.parent.key===r&&"ObjectPattern"===r.parent.parent.type&&!r.parent.computed){for(let r of oE(e,t))if(ov(t.key,r))return oD(t.key,r);for(let r of oE(e,t))if(oS(t.key,r))return oD(t.key,r)}})},meta:{type:"suggestion",docs:{description:"Prefer `KeyboardEvent#key` over deprecated keyboard event properties.",recommended:"unopinionated"},fixable:"code",hasSuggestions:!0,messages:{[om]:"Use `.key` instead of `.{{name}}`.",[of]:"Use `.key` with `{{key}}`."},languages:["js/js"]}},"unicorn/prefer-text-content":{create:e=>{e.on("MemberExpression",t=>{if(!tc(t,{property:"innerText"})||r1(t.object,e))return;let r=t.property;return{node:r,messageId:oC,suggest:[{messageId:oA,fix:e=>e.replaceText(r,"textContent")}]}}),e.on("Identifier",t=>{if("innerText"===t.name&&"Property"===t.parent.type&&t.parent.key===t&&!t.parent.computed&&"init"===t.parent.kind&&"ObjectPattern"===t.parent.parent.type&&t.parent.parent.properties.includes(t.parent)&&!((e,t)=>{if(r1(e,t))return!0;let{parent:r}=e;return"VariableDeclarator"===r.type?r.id===e&&r.init&&r1(r.init,t):"AssignmentExpression"===r.type&&r.left===e&&r1(r.right,t)})(t.parent.parent,e))return{node:t,messageId:oC,suggest:[{messageId:oA,fix:e=>e.replaceText(t,t.parent.shorthand?"textContent: innerText":"textContent")}]}})},meta:{type:"suggestion",docs:{description:"Prefer `.textContent` over `.innerText`.",recommended:"unopinionated"},hasSuggestions:!0,messages:{[oC]:"Prefer `.textContent` over `.innerText`.",[oA]:"Switch to `.textContent`."},languages:["js/js"]}},"unicorn/require-array-join-separator":{create:e=>{e.on("CallExpression",t=>{if(!(td(t,{method:"join",argumentsLength:0,optionalCall:!1})||td(t,{method:"call",argumentsLength:1,optionalCall:!1,optionalMember:!1})&&tb(t.callee.object,{property:"join"}))||0===t.arguments.length&&rX(t.callee.object,e))return;let{sourceCode:r}=e,[n,o]=r.getLastTokens(t,2),a=1===t.arguments.length;return{loc:{start:r.getLoc(n)[a?"end":"start"],end:r.getLoc(o).end},messageId:oz,fix:r=>ow(r,t,"','",e)}})},meta:{type:"suggestion",docs:{description:"Enforce using the separator argument with `Array#join()`.",recommended:"unopinionated"},fixable:"code",messages:{[oz]:"Missing the separator argument."},languages:["js/js"]}},"unicorn/no-thenable":{create:e=>{for(let{selector:t,selectors:r,messageId:n,getNodes:o}of oH)e.on(t??r,function*(t){for(let r of o(t,e))yield{node:r,messageId:n}})},meta:{type:"problem",docs:{description:"Disallow `then` property.",recommended:"unopinionated"},messages:{[oK]:"Do not add `then` to an object.",[oG]:"Do not export `then`.",[oJ]:"Do not add `then` to a class."},languages:["js/js"]}},"unicorn/no-invalid-remove-event-listener":{create:e=>{e.on("CallExpression",t=>{if(!(td(t,{method:"removeEventListener",minimumArguments:2,optionalCall:!1})&&"SpreadElement"!==t.arguments[0].type&&("FunctionExpression"===t.arguments[1].type||"ArrowFunctionExpression"===t.arguments[1].type||td(t.arguments[1],{method:"bind",optionalCall:!1,optionalMember:!1}))))return;let[,r]=t.arguments;return["ArrowFunctionExpression","FunctionExpression"].includes(r.type)?{node:r,loc:eh(r,e.sourceCode),messageId:oZ}:{node:r.callee.property,messageId:oZ}})},meta:{type:"problem",docs:{description:"Prevent calling `EventTarget#removeEventListener()` with the result of an expression.",recommended:"unopinionated"},messages:{[oZ]:"The listener argument should be a function reference."},languages:["js/js"]}},"unicorn/consistent-function-scoping":o9,"unicorn/no-new-buffer":{create:e=>{let{sourceCode:t}=e;e.on("NewExpression",r=>{if(!te(r,{name:"Buffer"}))return;let n=((e,t)=>{if(1!==e.length)return"from";let[r]=e;if("SpreadElement"===r.type)return;if("ArrayExpression"===r.type||"TemplateLiteral"===r.type)return"from";if(nr(r,t))return"alloc";let n=ew(r,t);if(n){let{value:e}=n;if("string"==typeof e||Array.isArray(e))return"from"}})(r.arguments,t.getScope(r));return n?{node:r,messageId:o5,data:{method:n},fix:ae(r,e,n)}:{node:r,messageId:o4,suggest:["from","alloc"].map(t=>({messageId:o7,data:{replacement:t},fix:ae(r,e,t)}))}})},meta:{type:"problem",docs:{description:"Enforce the use of `Buffer.from()` and `Buffer.alloc()` instead of the deprecated `new Buffer()`.",recommended:"unopinionated"},fixable:"code",hasSuggestions:!0,messages:{[o5]:"`new Buffer()` is deprecated, use `Buffer.{{method}}()` instead.",[o4]:"`new Buffer()` is deprecated, use `Buffer.alloc()` or `Buffer.from()` instead.",[o7]:"Switch to `Buffer.{{replacement}}()`."},languages:["js/js"]}},"unicorn/no-console-spaces":{create:e=>{let{sourceCode:t}=e,r=(r,n,o)=>{let[a,i]=t.getRange(r),s="leading"===o?a+1:i-2,l=[s,s+1];return{loc:n7(l,e),messageId:at,data:{method:n,position:o},fix:e=>e.removeRange(l)}};e.on("CallExpression",function*(e){if(!td(e,{object:"console",methods:["log","debug","info","warn","error"],minimumArguments:1,optionalCall:!1,optionalMember:!1}))return;let n=e.callee.property.name,{arguments:o}=e,{length:a}=o;for(let[e,i]of o.entries()){if(!e1(i)&&"TemplateLiteral"!==i.type)continue;let o=t.getText(i).slice(1,-1);0!==e&&ar(o)&&(yield r(i,n,"leading")),e!==a-1&&an(o)&&(yield r(i,n,"trailing"))}})},meta:{type:"suggestion",docs:{description:"Do not use leading/trailing space between `console.log` parameters.",recommended:"unopinionated"},fixable:"code",messages:{[at]:"Do not use {{position}} space between `console.{{method}}` parameters."},languages:["js/js"]}},"unicorn/no-empty-file":aa,"unicorn/no-useless-fallback-in-spread":{create:e=>{e.on("ObjectExpression",t=>{if(ta(t)&&"LogicalExpression"===t.parent.type&&t.parent.right===t&&("||"===t.parent.operator||"??"===t.parent.operator)&&"SpreadElement"===t.parent.parent.type&&t.parent.parent.argument===t.parent&&"ObjectExpression"===t.parent.parent.parent.type&&t.parent.parent.parent.properties.includes(t.parent.parent))return{node:t,messageId:ai,*fix(r,{abort:n}){let{sourceCode:o}=e,a=t.parent;if(o.getCommentsInside(a).length>0)return n();let{left:i}=a,s=eQ(i,e),[,l]=s?eH(i,e):o.getRange(i),[,u]=o.getRange(a);yield r.removeRange([l,u]),(s||"SequenceExpression"!==i.type)&&(yield oT(a,r,e))}}})},meta:{type:"suggestion",docs:{description:"Disallow useless fallback when spreading in object literals.",recommended:"unopinionated"},fixable:"code",messages:{[ai]:"The empty object is useless."},languages:["js/js"]}},"unicorn/no-useless-length-check":{create:e=>{let t=[],r=new Set,n=new Set,o=new Set,a=new Set;e.on("BinaryExpression",e=>{if(!("BinaryExpression"===e.type&&"Literal"===e.right.type&&"0"===e.right.raw&&tc(e.left,{property:"length",optional:!1})&&tE(e.parent)))return;let{operator:t}=e;"==="===t?r.add(e):(">"===t||"!=="===t)&&n.add(e)}),e.on("CallExpression",t=>{td(t,{optionalCall:!1,optionalMember:!1,computed:!1})&&"Identifier"===t.callee.property.type&&!rG(t.callee.object,e)&&("some"===t.callee.property.name?o.add(t):"every"===t.callee.property.name&&a.add(t))}),e.on("LogicalExpression",e=>{tE(e)&&t.push(e)}),e.on("Program:exit",function*(){let i=new Set(t.flatMap(e=>(function(e){let{operator:t}=e;return(function e(t){return[t.left,t.right].flatMap(r=>"LogicalExpression"===r.type&&r.operator===t.operator?e(r):[r])})(e).filter((e,i,s)=>(function({node:e,operator:t,siblings:i}){return"||"===t&&r.has(e)&&i.some(t=>a.has(t)&&tQ(e.left.object,t.callee.object))||"&&"===t&&n.has(e)&&i.some(t=>o.has(t)&&tQ(e.left.object,t.callee.object))})({node:e,operator:t,siblings:[s[i-1],s[i+1]].filter(Boolean)}))})(e))),{sourceCode:s}=e;for(let t of i)yield{loc:{start:s.getLoc(t.left.property).start,end:s.getLoc(t).end},messageId:r.has(t)?"zero":"non-zero",fix(r){let{left:n,right:o}=t.parent,a=eH(n,e),i=eH(o,e),s=[];return n===t?(s[0]=a[0],s[1]=i[0]):(s[0]=a[1],s[1]=i[1]),r.removeRange(s)}}})},meta:{type:"suggestion",docs:{description:"Disallow useless array length check.",recommended:"unopinionated"},fixable:"code",messages:{"non-zero":"The non-empty check is useless as `Array#some()` returns `false` for an empty array.",zero:"The empty check is useless as `Array#every()` returns `true` for an empty array."},languages:["js/js"]}},"unicorn/no-useless-promise-resolve-reject":{create:e=>{e.on("CallExpression",t=>{if(!(td(t,{object:"Promise",methods:["resolve","reject"],optionalCall:!1,optionalMember:!1})&&("ArrowFunctionExpression"===t.parent.type&&t.parent.body===t||"ReturnStatement"===t.parent.type&&t.parent.argument===t||"YieldExpression"===t.parent.type&&!t.parent.delegate&&t.parent.argument===t)))return;let{functionNode:r,isInTryStatement:n}=function(e){let t,r=!1;for(;e;e=e.parent){if(tl(e)){t=e;break}"TryStatement"===e.type&&(r=!0)}return{functionNode:t,isInTryStatement:r}}(t);if(r&&(r.async||function(e){if("CallExpression"===e.parent.type&&"MemberExpression"===e.parent.callee.type&&!e.parent.callee.computed&&"Identifier"===e.parent.callee.property.type){let{callee:{property:t},arguments:r}=e.parent;if(1===r.length&&["then","catch","finally"].includes(t.name)&&r[0]===e||2===r.length&&"then"===t.name&&(r[0]===e||"SpreadElement"!==r[0].type&&r[1]===e))return!0}return!1}(r)))return function(e,t){let{callee:r,parent:n}=e,o=r.property.name;return{node:r,messageId:o,data:{type:"YieldExpression"===n.type?"yield":"return"},fix:t}}(t,function(e,t,r){if(e.arguments.length>1)return;let{callee:n,parent:o,arguments:a}=e,[i]=a;if(i?.type==="SpreadElement")return;let s="reject"===n.property.name,l="YieldExpression"===o.type;if(!s||!t&&(!l||"ExpressionStatement"===o.parent.type))return function(t){let n="ArrowFunctionExpression"===o.type,a=i?r.sourceCode.getText(i):"";if(i?.type==="SequenceExpression"&&(a=`(${a})`),s){if(a||="undefined",a=`throw ${a}`,l)return t.replaceTextRange(eH(o,r),a);if(a+=";",n)return a=`{ ${a} }`,t.replaceTextRange(eH(e,r),a)}else l?a=`yield${a?" ":""}${a}`:"ReturnStatement"===o.type?a=`return${a?" ":""}${a};`:(i?.type==="ObjectExpression"&&(a=`(${a})`),a||="{}");return t.replaceText(n?e:o,a)}}(t,n,e))})},meta:{type:"suggestion",docs:{description:"Disallow returning/yielding `Promise.resolve/reject()` in async functions or promise callbacks",recommended:"unopinionated"},fixable:"code",messages:{resolve:"Prefer `{{type}} value` over `{{type}} Promise.resolve(value)`.",reject:"Prefer `throw error` over `{{type}} Promise.reject(error)`."},languages:["js/js"]}},"unicorn/no-zero-fractions":{create:e=>{e.on("Literal",t=>{if(!e8(t))return;let{raw:r}=t,n=r.match(/^(?<before>[\d_]*)(?<dotAndFractions>\.[\d_]*)(?<after>.*)$/);if(!n)return;let{before:o,dotAndFractions:a,after:i}=n.groups,s=(o+a.replaceAll(/[.0_]+$/g,"")||"0")+i;if(s===r)return;let l="."===a,{sourceCode:u}=e,p=u.getRange(t)[0]+o.length+a.length;return{loc:n7([p-(r.length-s.length),p],e),messageId:l?al:as,*fix(r){let n=s;"MemberExpression"===t.parent.type&&t.parent.object===t&&n0.test(s)&&!eQ(t,e)&&(n=`(${n})`,nW(u.getTokenBefore(t),e,n)&&(n=`;${n}`)),yield r.replaceText(t,n),yield oP(r,t,e)}}})},meta:{type:"suggestion",docs:{description:"Disallow number literals with zero fractions or dangling dots.",recommended:"unopinionated"},fixable:"code",messages:{[as]:"Don't use a zero fraction in the number.",[al]:"Don't use a dangling dot in the number."},languages:["js/js"]}},"unicorn/prefer-export-from":ah,"unicorn/prefer-native-coercion-functions":{create:e=>{e.on(ts,t=>{if(t.async||t.generator||t.returnType?.type==="TSTypeAnnotation"&&"TSTypePredicate"===t.returnType.typeAnnotation.type||0===t.params.length||"Identifier"!==t.params[0].type||("MethodDefinition"===t.parent.type&&("constructor"===t.parent.kind||"set"===t.parent.kind)||"Property"===t.parent.type&&"set"===t.parent.kind)&&t.parent.value===t)return;let r=function(e){if(("ArrowFunctionExpression"===e.type&&"Identifier"===e.body.type&&e.body.name===e.params[0].name||"BlockStatement"===e.body.type&&1===e.body.body.length&&"ReturnStatement"===e.body.body[0].type&&e.body.body[0].argument?.type==="Identifier"&&e.body.body[0].argument.name===e.params[0].name)&&"CallExpression"===e.parent.type&&!e.parent.optional&&e.parent.arguments[0]===e&&"MemberExpression"===e.parent.callee.type&&!e.parent.callee.computed&&!e.parent.callee.optional&&"Identifier"===e.parent.callee.property.type&&aE.has(e.parent.callee.property.name))return{replacementFunction:"Boolean",fix:t=>t.replaceText(e,"Boolean")}}(t)||function(e){let t,r=(t=e.params[0].name,"ArrowFunctionExpression"===e.type&&aD(e.body,t)?e.body:"BlockStatement"===e.body.type&&1===e.body.body.length&&"ReturnStatement"===e.body.body[0].type&&aD(e.body.body[0].argument,t)?e.body.body[0].argument:void 0);if(!r)return;let{name:n}=r.callee,o={replacementFunction:n};return"FunctionDeclaration"===e.type||1!==r.arguments.length||(o.fix=t=>{let r=n;return"Property"===e.parent.type&&e.parent.method&&e.parent.value===e?r=`: ${r}`:"MethodDefinition"===e.parent.type&&(r=` = ${r};`),t.replaceText(e,r)}),o}(t);if(!r)return;let{sourceCode:n}=e,{replacementFunction:o,fix:a}=r;return r={node:t,loc:eh(t,n),messageId:ax,data:{functionNameWithKind:ej(t,n),replacementFunction:o}},!a||1!==t.params.length||n.getCommentsInside(t).length>0||(r.fix=a),r})},meta:{type:"suggestion",docs:{description:"Prefer using `String`, `Number`, `BigInt`, `Boolean`, and `Symbol` directly.",recommended:"unopinionated"},fixable:"code",messages:{[ax]:"{{functionNameWithKind}} is equivalent to `{{replacementFunction}}`. Use `{{replacementFunction}}` directly."},languages:["js/js"]}},"unicorn/no-document-cookie":{create(e){aT.listen({context:e})},meta:{type:"problem",docs:{description:"Do not use `document.cookie` directly.",recommended:"unopinionated"},messages:{[aA]:"Do not use `document.cookie` directly."},languages:["js/js"]}},"unicorn/prefer-add-event-listener":aj,"unicorn/prefer-array-index-of":aN,"unicorn/prefer-blob-reading-methods":{create:e=>{e.on("CallExpression",e=>{if(!td(e,{methods:["readAsText","readAsArrayBuffer"],argumentsLength:1,optionalCall:!1,optionalMember:!1}))return;let t=e.callee.property,r=t.name;return{node:t,messageId:aM,data:{method:r,replacement:"readAsArrayBuffer"===r?"arrayBuffer":"text"}}})},meta:{type:"suggestion",docs:{description:"Prefer `Blob#arrayBuffer()` over `FileReader#readAsArrayBuffer(…)` and `Blob#text()` over `FileReader#readAsText(…)`.",recommended:"unopinionated"},messages:{[aM]:"Prefer `Blob#{{replacement}}()` over `FileReader#{{method}}(blob)`."},languages:["js/js"]}},"unicorn/prefer-date-now":{create:e=>{e.on("CallExpression",e=>{if(td(e,{methods:["getTime","valueOf"],argumentsLength:0,optionalCall:!1,optionalMember:!1})&&aW(e.callee.object)){let t=e.callee.property;return a_(e,{node:t,messageId:aq,data:{method:t.name}})}if(e7(e,{names:["Number","BigInt"],argumentsLength:1,optional:!1})&&aW(e.arguments[0])){let{name:t}=e.callee;return"Number"===t?a_(e,{messageId:aU}):a_(e.arguments[0])}}),e.on("UnaryExpression",t=>{if(("+"===t.operator||"-"===t.operator)&&aW(t.argument))return a_("-"===t.operator?t.argument:t,{},e)}),e.on("AssignmentExpression",e=>{if(("-="===e.operator||"*="===e.operator||"/="===e.operator||"%="===e.operator||"**="===e.operator)&&aW(e.right))return a_(e.right)}),e.on("BinaryExpression",function*(e){if("-"===e.operator||"*"===e.operator||"/"===e.operator||"%"===e.operator||"**"===e.operator)for(let t of[e.left,e.right])aW(t)&&(yield a_(t))})},meta:{type:"suggestion",docs:{description:"Prefer `Date.now()` to get the number of milliseconds since the Unix Epoch.",recommended:"unopinionated"},fixable:"code",messages:{[aO]:"Prefer `Date.now()` over `new Date()`.",[aq]:"Prefer `Date.now()` over `Date#{{method}}()`.",[aU]:"Prefer `Date.now()` over `Number(new Date())`."},languages:["js/js"]}},"unicorn/dom-node-dataset":a0,"unicorn/prefer-modern-math-apis":{create:e=>{let t=[];e.on("CallExpression",t=>{if(!td(t,{object:"Math",method:"sqrt",argumentsLength:1,optionalCall:!1,optionalMember:!1}))return;let r=a5(t.arguments[0]);if(r.some(e=>!("BinaryExpression"===e.type&&("*"===e.operator&&tQ(e.left,e.right)||"**"===e.operator&&e0(e.right,2)))))return;let n=1===r.length?"abs":"hypot",o=new Set(1===r.length?[]:r.map(e=>e.parent));return{node:t.callee.property,messageId:a1,data:{replacement:`Math.${n}(…)`,description:"Math.sqrt(…)"},*fix(a){let{sourceCode:i}=e;for(let r of(yield a.replaceText(t.callee.property,n),o)){let t=i.getTokenAfter(r.left,e=>"Punctuator"===e.type&&"+"===e.value);yield oV(t,",",a,e),yield oT(r,a,e)}for(let t of r)yield a.removeRange([eH(t.left,e)[1],i.getRange(t)[1]])}}}),e.on("BinaryExpression",e=>{t.push(e)}),e.on("Program:exit",function*(){for(let r of t)for(let t of a9){let n=t(r,e);n&&(yield n)}})},meta:{type:"suggestion",docs:{description:"Prefer modern `Math` APIs over legacy patterns.",recommended:"unopinionated"},fixable:"code",messages:{[a1]:"Prefer `{{replacement}}` over `{{description}}`."},languages:["js/js"]}},"unicorn/number-literal-case":ie,"unicorn/prefer-number-properties":is,"unicorn/prefer-reflect-apply":{create:e=>{e.on("CallExpression",t=>{if(!td(t,{optionalCall:!1,optionalMember:!1})||"Literal"===t.callee.object.type||"ArrayExpression"===t.callee.object.type||"ObjectExpression"===t.callee.object.type)return;let{sourceCode:r}=e,n=((e,t)=>{if("apply"===eI(e.callee)&&2===e.arguments.length&&iu(e.arguments[0],e.arguments[1]))return r=>r.replaceText(e,ip(t,e.callee.object,e.arguments[0],e.arguments[1]))})(t,r)||((e,t)=>{if("call"===eI(e.callee)&&"apply"===eI(e.callee.object)&&"prototype"===eI(e.callee.object.object)&&e.callee.object.object.object?.type==="Identifier"&&"Function"===e.callee.object.object.object.name&&3===e.arguments.length&&iu(e.arguments[1],e.arguments[2]))return r=>r.replaceText(e,ip(t,e.arguments[0],e.arguments[1],e.arguments[2]))})(t,r);if(n)return{node:t,messageId:il,fix:n}})},meta:{type:"suggestion",docs:{description:"Prefer `Reflect.apply()` over `Function#apply()`.",recommended:"unopinionated"},fixable:"code",messages:{[il]:"Prefer `Reflect.apply()` over `Function#apply()`."},languages:["js/js"]}},"unicorn/prefer-set-size":{create:e=>{e.on("MemberExpression",t=>{var r;if(!tc(t,{property:"length",optional:!1}))return;let n="ArrayExpression"===(r=t.object).type&&1===r.elements.length&&r.elements[0]?.type==="SpreadElement"?r.elements[0].argument:td(r,{object:"Array",method:"from",argumentsLength:1,optionalCall:!1,optionalMember:!1})?r.arguments[0]:void 0;if(n&&rY(n,e))return{node:t.property,messageId:ic,fix:function(e,t,r){let{sourceCode:n}=e,{object:o,property:a}=t;if(!(n.getCommentsInside(o).length>n.getCommentsInside(r).length))return function*(i){yield i.replaceText(a,"size");let s=n.getText(r);n2(r,e)&&(s=`(${s})`),yield i.replaceText(o,s),"ArrayExpression"===o.type&&(yield oP(i,t,e))}}(e,t,n)}})},meta:{type:"suggestion",docs:{description:"Prefer using `Set#size` instead of `Array#length`.",recommended:"unopinionated"},fixable:"code",messages:{[ic]:"Prefer using `Set#size` instead of `Array#length`."},languages:["js/js"]}},"unicorn/prefer-string-replace-all":{create:e=>{e.on("CallExpression",t=>{let r,n,o=((e,t)=>{let r;if(!td(e,{method:"join",argumentsLength:1,optionalCall:!1,optionalMember:!1})||!td(e.callee.object,{method:"split",argumentsLength:1,optionalCall:!1,optionalMember:!1})||t.sourceCode.getCommentsInside(e).length>0)return;let n=e.callee.object;if(nv(n.callee.object,t))return;let[o]=n.arguments,[a]=e.arguments,i=e3(o);if("string"==typeof i){if(0===i.length)return;r=tF(i)}else if(!(r=(e=>{if(!e6(e)||e.regex.flags.includes("y"))return;let t=iw(e);if(!t||ij(t)||0===iI(t))return;let{pattern:r,flags:n}=e.regex;return`/${r}/${n.includes("g")?n:`g${n}`}`})(o)))return;let s=e3(a);if("string"==typeof s)return`${eZ(n.callee.object,t)}.replaceAll(${r}, ${tF(s.replaceAll("$","$$$$"))})`})(t,e);if(o)return{node:t.callee.property,messageId:iE,fix:e=>e.replaceText(t,o)};if(!td(t,{methods:["replace","replaceAll"],argumentsLength:2,optionalCall:!1})||td(t,{method:"replace",argumentsLength:2,optionalCall:!1,optionalMember:!1})&&e6(r=t.arguments[0])&&r.regex.flags.includes("g")&&!r.regex.flags.includes("y")&&(e=>{if(!e.startsWith("[")||!e.endsWith("]")||e.startsWith("[^"))return;let t=new Set,r=e.slice(1,-1);for(let e=0;e<r.length;e++){let n=r[e],o=!1;if("\\"===n&&(n=r[++e],o=!0,!n)||"-"===n&&!o&&0!==e&&e!==r.length-1||"]"===n&&!o&&0!==e||!iy.has(n))return;t.add(n)}return t})(r.regex.pattern)?.size>=8&&e1(n=t.arguments[1])&&n.value===ig)return;let{arguments:a,callee:{property:i}}=t;if(nv(t.callee.object,e))return;let[s]=a;if(!((e,t)=>{if(e6(e))return e.regex.flags.includes("g");if(te(e,{name:"RegExp"})&&e.arguments[0]?.type!=="SpreadElement"&&e.arguments[1]?.type==="Literal"&&"string"==typeof e.arguments[1].value)return e.arguments[1].value.includes("g");let r=ew(e,t);if(!r)return!1;let{value:n}=r;return"[object RegExp]"===Object.prototype.toString.call(n)&&n.global})(s,e.sourceCode.getScope(s)))return;let l=i.name,u=function(e){if(!e6(e))return;let t=iw(e);if(!t)return;let{flags:r}=e.regex;if(!function(e){if(!e.includes("g"))return!1;for(let t of e)if(iD.has(t))return!1;return!0}(r))return;let n="alternative"===t.type?iT(t.body):iA(t);if(n)return"'"+n+"'"}(s);if("replaceAll"===l){if(!u)return;return{node:s,messageId:ib,data:{replacement:u.length<20?u:"a string literal"},fix:e=>e.replaceText(s,u)}}return{node:i,messageId:ix,*fix(e){yield e.insertTextAfter(i,"All"),u&&(yield e.replaceText(s,u))}}})},meta:{type:"suggestion",docs:{description:"Prefer `String#replaceAll()` over regex searches with the global flag and `String#split().join()`.",recommended:"unopinionated"},fixable:"code",messages:{[ix]:"Prefer `String#replaceAll()` over `String#replace()`.",[ib]:"This pattern can be replaced with {{replacement}}.",[iE]:"Prefer `String#replaceAll()` over `String#split().join()`."},languages:["js/js"]}},"unicorn/prefer-string-slice":{create:e=>{e.on("CallExpression",t=>{if(!td(t,{methods:["substr","substring"]})||nv(t.callee.object,e))return;let r=t.callee.property.name;if(!("substring"===r&&(e=>{if(!td(e,{method:"substring",argumentsLength:2}))return;let[t,r]=e.arguments;if(iF(t)&&iF(r)&&1===Math.abs(t.value-r.value))return t.value<r.value?t:r;let n=(e=>{if("BinaryExpression"===e.type&&"-"===e.operator&&e0(e.right,1))return e.left})(t);return iB(r,t)??(iB(t,r)?r:void 0)??(n&&tQ(n,r)?t:void 0)})(t)))return{node:t,messageId:r,*fix(n,{abort:o}){if(yield n.replaceText(t.callee.property,"slice"),0!==t.arguments.length){if(t.arguments.length>2||t.arguments.some(e=>"SpreadElement"===e.type))return o();yield("substr"===r?function*({node:e,fixer:t,context:r,abort:n}){let o=e.arguments,[a,i]=o;if(!i)return;let{sourceCode:s}=r,l=ew(a,s.getScope(e)),u=eH(i,r);if(l?.value===0){let n=((e,t,r)=>{let n,o,{sourceCode:a}=r;if(!("BinaryExpression"!==e.type||"-"!==e.operator||!(e8(n=e.right)&&Number.isSafeInteger(n.value)&&n.value>0)||!i$(e.left)||!("Identifier"===t.type||e1(t))||!tQ(e.left.object,t)||(o=((e,t)=>{let[r,n]=eH(e,t),o=t.sourceCode.getTokenByRangeStart(r),a=t.sourceCode.getTokenBefore(o);return[t.sourceCode.getRange(a)[1],n]})(e,r),a.getAllComments().some(e=>{let t=a.getRange(e);return t[0]>=o[0]&&t[1]<=o[1]}))))return`-${e.right.raw}`})(i,e.callee.object,r);if(n)return void(yield oI(t,i,n,r));if(e8(i)||i$(i))return;let o=iR(i);return"number"==typeof o?void(yield oI(t,i,String(Math.max(0,o)),r)):(yield t.insertTextBeforeRange(u,"Math.max(0, "),void(yield t.insertTextAfterRange(u,")")))}if(o.every(e=>e8(e))){let e;return void(yield(e=String(a.value+i.value),oI(t,i,e,r)))}return n()}:function*({node:e,fixer:t,context:r,abort:n}){let[o,a]=e.arguments,i=o?iR(o):void 0;if(!a){if(i$(o))return;if(void 0!==i)return void(yield oI(t,o,String(Math.max(0,i)),r));let e=eH(o,r);return yield t.insertTextBeforeRange(e,"Math.max(0, "),void(yield t.insertTextAfterRange(e,")"))}let s=iR(a);if(void 0!==i&&void 0!==s){let e=[Math.max(0,i),Math.max(0,s)];i>s&&e.reverse(),e[0]!==i&&(yield oI(t,o,String(e[0]),r)),e[1]!==s&&(yield oI(t,a,String(e[1]),r));return}if(0===i||0===s){let e=eZ(o,r),n=eZ(a,r);yield oI(t,o,"0",r),yield oI(t,a,`Math.max(0, ${0===i?n:e})`,r);return}return n()})({node:t,fixer:n,context:e,abort:o})}}}})},meta:{type:"suggestion",docs:{description:"Prefer `String#slice()` over `String#substr()` and `String#substring()`.",recommended:"unopinionated"},fixable:"code",messages:{substr:"Prefer `String#slice()` over `String#substr()`.",substring:"Prefer `String#slice()` over `String#substring()`."},languages:["js/js"]}},"unicorn/prefer-string-trim-start-end":{create:e=>{e.on("CallExpression",t=>{if(!td(t,{methods:["trimLeft","trimRight"],argumentsLength:0,optionalCall:!1})||nv(t.callee.object,e))return;let r=t.callee.property,n=r.name,o="trimLeft"===n?"trimStart":"trimEnd";return{node:r,messageId:iP,data:{method:n,replacement:o},fix:e=>e.replaceText(r,o)}})},meta:{type:"suggestion",docs:{description:"Prefer `String#trimStart()` / `String#trimEnd()` over `String#trimLeft()` / `String#trimRight()`.",recommended:"unopinionated"},fixable:"code",messages:{[iP]:"Prefer `String#{{replacement}}()` over `String#{{method}}()`."},languages:["js/js"]}},"unicorn/no-unreadable-iife":{create:e=>{e.on("CallExpression",t=>{if("ArrowFunctionExpression"!==t.callee.type||"BlockStatement"===t.callee.body.type||!eQ(t.callee.body,e))return;let{body:r}=t.callee,n={node:t,loc:n7(eH(r,e),e),messageId:iL};return!function(e,t){let{sourceCode:r}=t,[n,o]=eH(e,t),[a,i]=r.getRange(e);return r.getCommentsInside(e.parent).some(e=>{let[t,s]=r.getRange(e);return t>=n&&s<=o&&(t<a||s>i)})}(r,e)&&(n.suggest=[{messageId:iN,fix:t=>t.replaceTextRange(eH(r,e),`{ return ${e.sourceCode.getText(r)}; }`)}]),n})},meta:{type:"suggestion",docs:{description:"Disallow unreadable IIFEs.",recommended:"unopinionated"},hasSuggestions:!0,messages:{[iL]:"IIFE with parenthesized arrow function body is considered unreadable.",[iN]:"Use a block statement body."},languages:["js/js"]}},"unicorn/throw-new-error":{create:e=>{e.on("CallExpression",t=>{if("Decorator"===t.parent.type)return;let{callee:r}=t;if(!(t.optional||rh(r))&&("Identifier"===r.type&&iO.test(r.name)||"MemberExpression"===r.type&&!r.computed&&"Identifier"===r.property.type&&iO.test(r.property.name))&&!tc(r,{object:"Data",property:"TaggedError",computed:!1}))return{node:t,messageId:iM,fix:r=>oL(t,e,r)}})},meta:{type:"suggestion",docs:{description:"Require `new` when creating an error.",recommended:"unopinionated"},fixable:"code",messages:{[iM]:"Use `new` when creating an error."},languages:["js/js"]}},"unicorn/escape-case":{create:e=>{let t="lowercase"===e.options[0];e.on("Literal",e=>{if(e1(e))return iV({node:e,original:e.raw,lowercase:t})}),e.on("Literal",e=>{if(e6(e))return iV({node:e,original:e.raw,regex:i_,lowercase:t})}),e.on("TemplateElement",r=>{if(!th(r.parent))return iV({node:r,original:r.value.raw,lowercase:t,fix:(t,n)=>o_(r,n,e,t)})})},meta:{type:"suggestion",docs:{description:"Require escape sequences to use uppercase or lowercase values.",recommended:"unopinionated"},fixable:"code",schema:[{enum:["uppercase","lowercase"],description:"The case style for escape sequences."}],defaultOptions:["uppercase"],messages:{[iq]:"Use uppercase characters for the value of the escape sequence.",[iU]:"Use lowercase characters for the value of the escape sequence."},languages:["js/js"]}},"unicorn/prefer-unicode-code-point-escapes":{create:e=>{e.on("Literal",e=>e1(e)?i6(e,e.raw):e6(e)?function(e){let t,{raw:r}=e,{pattern:n,flags:o}=(t=r.lastIndexOf("/"),{pattern:r.slice(1,t),flags:r.slice(t+1)}),{fixed:a,hasReplacement:i}=i8(n,{isRegex:!0,supportsNestedCharacterClasses:o.includes("v")}),s=o.includes("u")||o.includes("v"),l=function(e){for(let t=0;t<e.length;t++)if(void 0!==function(e,t){var r;if(!e.startsWith(iG,t))return;let n=t+iG.length;for(;r=e[n],iJ.test(r);)n++;if(n===t+iG.length||"}"!==e[n])return;let o=Number.parseInt(e.slice(t+iG.length,n),16);if(!(o>1114111))return o}(e,t)&&iZ(e,t))return!0;return!1}(n);if(!i&&(s||!l))return;let u=`/${i?a:n}/${i9(o)}`;return s?{node:e,messageId:iz,fix:t=>t.replaceText(e,u)}:!function(e,t){try{return new RegExp(e,t),!0}catch{return!1}}(i?a:n,i9(o))?{node:e,messageId:iz}:{node:e,messageId:iz,suggest:[{messageId:iK,fix:t=>t.replaceText(e,u)}]}}(e):void 0),e.on("TemplateElement",t=>{if(!th(t.parent))return i6(t,t.value.raw,(r,n)=>o_(t,n,e,r))})},meta:{type:"suggestion",docs:{description:"Prefer Unicode code point escapes over legacy escape sequences.",recommended:"unopinionated"},fixable:"code",hasSuggestions:!0,messages:{[iz]:"Prefer Unicode code point escapes.",[iK]:"Use Unicode code point escapes and add the `u` flag."},languages:["js/js"]}},"unicorn/prefer-prototype-methods":{create:function(e){let{sourceCode:t}=e,r=[];e.on("CallExpression",e=>{r.push(e)}),e.onExit("Program",function*(n){let o=new WeakMap;for(let{node:e,path:r}of new ez(t.getScope(n)).iterateGlobalReferences(Object.fromEntries(i5.map(e=>[e,{[ez.READ]:!0}]))))o.set(e,r);for(let t of r)yield function(e,{context:t,globalReferences:r}){let n;td(e,{object:"Reflect",method:"apply",minimumArguments:1,optionalCall:!1,optionalMember:!1})?n=e.arguments[0]:td(e,{methods:["apply","bind","call"],optionalCall:!1,optionalMember:!1})&&(n=e.callee.object);let{isGlobalReference:o,constructorName:a,methodName:i}=function(e,{context:t,globalReferences:r}){if(!e)return;if(r.has(e))return{isGlobalReference:!0,constructorName:"Object",methodName:r.get(e).at(-1)};if(!tc(e,{optional:!1}))return;let n=e.object;if(to(n)||ta(n))return{constructorName:"ArrayExpression"===n.type?"Array":"Object",methodName:eI(e,t.sourceCode.getScope(e))}}(n,{context:t,globalReferences:r})??{};if(a)return{node:n,messageId:i?"known-method":"unknown-method",data:{constructorName:a,methodName:i},*fix(r){if(o)return void(yield r.replaceText(n,`${a}.prototype.${i}`));if(tc(n)){let o=n.object;yield r.replaceText(o,`${a}.prototype`),("ArrayExpression"===o.type||"ObjectExpression"===o.type)&&(yield oP(r,e,t))}}}}(t,{context:e,globalReferences:o})})},meta:{type:"suggestion",docs:{description:"Prefer borrowing methods from the prototype instead of the instance.",recommended:"unopinionated"},fixable:"code",messages:{"known-method":"Prefer using `{{constructorName}}.prototype.{{methodName}}`.","unknown-method":"Prefer using method from `{{constructorName}}.prototype`."},languages:["js/js"]}},"unicorn/error-message":{create:e=>{e.on(["CallExpression","NewExpression"],t=>{if(!(tt(t,{names:i4,optional:!1})&&e.sourceCode.isGlobalReference(t.callee)))return;let r=t.callee.name,n=sr.has(r)?sr.get(r):0,o=t.arguments;if(o.some((e,t)=>t<=n&&"SpreadElement"===e.type))return;let a=o[n];if(!a)return{node:t,messageId:i7,data:{constructorName:r}};if("ArrayExpression"===a.type||"ObjectExpression"===a.type)return{node:a,messageId:st};let i=ew(a,e.sourceCode.getScope(a));if(!i)return;let{value:s}=i;return"string"!=typeof s?{node:a,messageId:st}:""===s?{node:a,messageId:se}:void 0})},meta:{type:"problem",docs:{description:"Enforce passing a `message` value when creating a built-in error.",recommended:"unopinionated"},messages:{[i7]:"Pass a message to the `{{constructorName}}` constructor.",[se]:"Error message should not be an empty string.",[st]:"Error message should be a string."},languages:["js/js"]}},"unicorn/no-instanceof-builtins":su,"unicorn/prefer-type-error":{create:e=>{e.on("ThrowStatement",e=>{let t;if(!(te(e.argument,{name:"Error"})&&e.parent&&e.parent.body&&1===e.parent.body.length&&e.parent.parent&&"IfStatement"===(t=e.parent.parent).type&&sh(t.test)))return;let r=e.argument.callee;return{node:r,messageId:sp,fix:e=>e.insertTextBefore(r,"Type")}})},meta:{type:"suggestion",docs:{description:"Enforce throwing `TypeError` in type checking conditions.",recommended:"unopinionated"},fixable:"code",messages:{[sp]:"`new Error()` is too unspecific for a type check. Use `new TypeError()` instead."},languages:["js/js"]}},"unicorn/consistent-destructuring":{create:e=>{let{sourceCode:t}=e,r=new Map,n=[],o=[],a=e=>{let r=ry(e.object);if(e.computed||"Identifier"!==e.property.type||!["Identifier","ThisExpression"].includes(r.type))return;let n=t.getScope(e);o.push({propertyName:e.property.name,rootIdentifierName:"Identifier"===r.type?r.name:void 0,rootVariable:"Identifier"===r.type?ei(n,r):void 0,thisScopeBoundary:"ThisExpression"===r.type?sD(r):void 0,start:t.getRange(e)[0],scope:n})},i=e=>{switch(e.type){case"MemberExpression":a(e);break;case"AssignmentPattern":i(e.left);break;case"RestElement":i(e.argument);break;case"ObjectPattern":for(let t of e.properties)i("Property"===t.type?t.value:t.argument);break;case"ArrayPattern":for(let t of e.elements)t&&i(t)}};e.on("AssignmentExpression",e=>{i(e.left)}),e.on(["ForInStatement","ForOfStatement"],e=>{"VariableDeclaration"!==e.left.type&&i(e.left)}),e.on("UpdateExpression",e=>{"MemberExpression"===e.argument.type&&a(e.argument)}),e.on("UnaryExpression",e=>{"delete"===e.operator&&"MemberExpression"===e.argument.type&&a(e.argument)}),e.on("VariableDeclarator",e=>{let n;if(!("ObjectPattern"===e.id.type&&"const"===e.parent.kind&&e.init&&("Identifier"===(n=e.init).type||"ThisExpression"===n.type)))return;let o="Identifier"===e.init.type?e.init:void 0,a={scope:t.getScope(e),object:e.init,rootIdentifierName:o?.name,rootVariable:o&&ei(t.getScope(e),o),thisScopeBoundary:"ThisExpression"===e.init.type?sD(e.init):void 0,objectPattern:e.id},i=t.getText(e.init);r.set(i,[...r.get(i)??[],a])});let s=e=>{let n;if(e.computed||tt(e.parent)&&e.parent.callee===e||"TaggedTemplateExpression"===e.parent.type&&e.parent.tag===e||r3(e))return;let a=ry(e.object),i=r.get(t.getText(a));if(!i)return;let s=t.getScope(e),l="Identifier"===a.type?a:void 0,u=l&&ei(s,l),p="ThisExpression"===a.type?sD(a):void 0,c=t.getText(e.property);for(let r of i.toReversed())if(sC({declaration:r,memberExpressionNode:e,memberScope:s,memberRootIdentifier:l,memberRootVariable:u,memberThisScopeBoundary:p,memberExpressionWrites:o,sourceCode:t})&&(n=sv(r.objectPattern.properties.filter(e=>sS(e)&&"Identifier"===e.value.type),c,s,t)))break;if(!n||((e,t)=>{let r=e,{parent:n}=e;for(;n&&!sw(n);){if(sT(n,r,e,t))return!0;r=n,n=n.parent}return!1})(e,t))return;if("MemberExpression"===e.parent.type)return{node:e,messageId:sx};let d=t.getText(e),m=n.value.name;return{node:e,messageId:sx,suggest:[{messageId:sb,data:{expression:d,property:m},fix:t=>t.replaceText(e,m)}]}};e.on("MemberExpression",e=>{n.push(e)}),e.onExit("Program",function*(){for(let e of n){let t=s(e);t&&(yield t)}})},meta:{type:"suggestion",docs:{description:"Use destructured variables over properties.",recommended:!1},hasSuggestions:!0,messages:{[sx]:"Use destructured variables over properties.",[sb]:"Replace `{{expression}}` with destructured property `{{property}}`."},languages:["js/js"]}},"unicorn/new-for-builtins":{create:e=>{sR.listen({context:e}),s$.listen({context:e}),sP.listen({context:e}),sL.listen({context:e})},meta:{type:"suggestion",docs:{description:"Enforce correct use of `new` for builtin constructors.",recommended:"unopinionated"},fixable:"code",hasSuggestions:!0,messages:{enforce:"Use `new {{name}}()` instead of `{{name}}()`.",disallow:"Use `{{name}}()` instead of `new {{name}}()`.",disallowCallOrNew:"`{{name}}` is not a function or constructor.",[sj]:"Use `String(new Date())` instead of `Date()`.",[sF]:"Switch to `String(new Date())`."},languages:["js/js"]}},"unicorn/prefer-single-call":sW,"unicorn/no-process-exit":{create:e=>{if(0===e.sourceCode.lines[0].indexOf("#!"))return;let t=0,r=!1,n=[],o=e=>td(e,{object:"process",methods:["on","once"],minimumArguments:1,optionalCall:!1,optionalMember:!1});e.on("CallExpression",e=>{tf(e)&&sV(e.arguments[0])&&(r=!0)}),e.on("ImportDeclaration",e=>{"Literal"===e.source.type&&sV(e.source)&&(r=!0)}),e.on("CallExpression",e=>{o(e)&&t++}),e.onExit("CallExpression",e=>{o(e)&&t--}),e.on("CallExpression",e=>{0===t&&td(e,{object:"process",method:"exit",optionalCall:!1,optionalMember:!1})&&n.push(e)}),e.onExit("Program",function*(){if(!r)for(let e of n)yield{node:e,messageId:s_}})},meta:{type:"suggestion",docs:{description:"Disallow `process.exit()`.",recommended:"unopinionated"},messages:{[s_]:"Only use `process.exit()` in CLI apps. Throw an error instead."},languages:["js/js"]}},"unicorn/no-static-only-class":{create:function(e){e.on(["ClassDeclaration","ClassExpression"],t=>{if(!(t.superClass||t.decorators&&t.decorators.length>0||"ClassBody"!==t.body.type||0===t.body.body.length||t.body.body.some(e=>!function(e){let{private:t,static:r,declare:n,readonly:o,accessibility:a,decorators:i,key:s}=e;return!(!s0(e)&&"MethodDefinition"!==e.type||!r||t||"PrivateIdentifier"===s.type||n||o||void 0!==a||Array.isArray(i)&&i.length>0)}(e))))return{node:t,loc:function(e,t){let{sourceCode:r}=t,{body:n}=e,o=r.getTokenBefore(n),{start:a}=r.getLoc(e),{end:i}=r.getLoc(o);return{start:a,end:i}}(t,e),messageId:sZ,fix:function(e,t){let{type:r,id:n,body:o,declare:a,abstract:i,implements:s,parent:l}=e;if(a||i||Array.isArray(s)&&s.length>0||"ClassExpression"===r&&n)return;let u="ClassDeclaration"===e.type&&"ExportDefaultDeclaration"===e.parent.type&&e.parent.declaration===e;if(u&&n)return;let{sourceCode:p}=t;for(let e of o.body)if(s0(e)&&(e.typeAnnotation||e.value&&p.getText(e.value).includes("this")))return;return function*(n){let a=p.getFirstToken(e);if(tw(a,{expected:{type:"Keyword",value:"class"},ruleId:"no-static-only-class"}),u||"ClassExpression"===r)if("ClassExpression"===r&&"ReturnStatement"===l.type&&p.getLoc(o).start.line!==p.getLoc(l).start.line&&p.text.slice(p.getRange(a)[1],p.getRange(o)[0]).trim()){yield n.replaceText(a,"{");let e=p.getFirstToken(o);yield n.remove(e)}else yield n.replaceText(a,""),yield oB(a,t,n);else yield n.replaceText(a,"const"),yield n.insertTextBefore(o,"= "),yield n.insertTextAfter(o,";");for(let e of o.body)yield function*(e,t,r){let{sourceCode:n}=t,o=n.getFirstToken(e);tw(o,{expected:{type:"Keyword",value:"static"},ruleId:"no-static-only-class"}),yield r.remove(o),yield oB(o,t,r);let a=s0(e)?n.getLastToken(e):n.getTokenAfter(e),i=ep(a);if(s0(e)){let{key:t,value:o}=e;if(o){let e=n.getTokenAfter(t,sQ);yield r.replaceText(e,":")}else i?yield r.insertTextBefore(a,": undefined"):yield r.insertTextAfter(e,": undefined")}yield i?r.replaceText(a,","):r.insertTextAfter(e,",")}(e,t,n)}}(t,e)}})},meta:{type:"suggestion",docs:{description:"Disallow classes that only have static members.",recommended:"unopinionated"},fixable:"code",messages:{[sZ]:"Use an object instead of a class with only static members."},languages:["js/js"]}},"unicorn/no-unreadable-array-destructuring":s3,"unicorn/no-useless-spread":{create:e=>{let{sourceCode:t}=e;e.on(["ArrayExpression","ObjectExpression"],r=>{if(!("SpreadElement"===r.parent.type&&r.parent.argument===r&&("ObjectExpression"===r.type&&"ObjectExpression"===r.parent.parent.type&&r.parent.parent.properties.includes(r.parent)||"ArrayExpression"===r.type&&("ArrayExpression"===r.parent.parent.type&&r.parent.parent.elements.includes(r.parent)||tt(r.parent.parent)&&r.parent.parent.arguments.includes(r.parent)))))return;let n=r.parent,o=t.getFirstToken(n),a=n.parent.type,i={node:o,messageId:s8,data:{argumentType:"ArrayExpression"===r.type?"array":"object",parentDescription:li[a]}};return"NewExpression"===a&&la(r)&&te(n.parent,{names:lr,argumentsLength:1,allowSpreadElement:!0})?i:{...i,*fix(i){let s;yield i.remove(o),yield oT(r,i,e);let l=t.getFirstToken(r);yield i.remove(l);let[u,p]=t.getLastTokens(r,2);if(yield i.remove(p),eu(u)&&(yield i.remove(u)),to(r)||ta(r)){let e=t.getTokenAfter(n);eu(e)&&(yield i.remove(e))}if("CallExpression"===a||"NewExpression"===a)for(let[e,n]of(s=t.getFirstToken(r),r.elements.map((e,n,o)=>{if(n===o.length-1){let e=t.getLastToken(r,{skip:1});return eu(e)?e:void 0}let a=t.getTokenAfter(e||s,eu);return s=a,a})).entries())null===r.elements[e]&&(yield i.insertTextBefore(n,"undefined"))}}}),e.on("ObjectExpression",r=>{if(!("ObjectExpression"===r.type&&r.properties.length>0&&r.properties.every(e=>"SpreadElement"===e.type&&"ObjectExpression"!==e.argument.type)))return;let n=r.parent;if(!td(n,{object:"Object",method:"assign",minimumArguments:2,optionalMember:!1,optionalCall:!1}))return;let o=n.arguments.indexOf(r),a=n.arguments.slice(0,o).some(e=>"SpreadElement"!==e.type);if(o<=0||!a)return;let i={node:t.getFirstToken(r.properties[0]),messageId:s7};return t.getCommentsInside(r).length>0?i:{...i,suggest:[{messageId:lt,fix:t=>t.replaceText(r,r.properties.map(t=>eZ(t.argument,e)).join(", "))}]}}),e.on("NewExpression",e=>{if(te(e,{names:lr,argumentsLength:1,allowSpreadElement:!0})&&"SpreadElement"===e.arguments[0].type&&"ArrayExpression"!==e.arguments[0].argument.type)return{node:e.arguments[0],messageId:s4,data:{constructorName:`new ${e.callee.name}(…)`}}}),e.on("ArrayExpression",t=>{if(!la(t))return;let{parent:r}=t;if(!("ForOfStatement"===r.type&&r.right===t||"YieldExpression"===r.type&&r.delegate&&r.argument===t||(te(r,{names:lr,argumentsLength:1})||te(r,{names:rE,minimumArguments:1})||td(r,{object:"Promise",methods:["all","allSettled","any","race"],argumentsLength:1,optionalCall:!1,optionalMember:!1})||td(r,{objects:["Array",...rE],method:"from",argumentsLength:1,optionalCall:!1,optionalMember:!1})||td(r,{object:"Object",method:"fromEntries",argumentsLength:1,optionalCall:!1,optionalMember:!1}))&&r.arguments[0]===t))return;let n="",o=s6;switch(r.type){case"ForOfStatement":o=s9;break;case"YieldExpression":o=s5;break;case"NewExpression":n=`new ${r.callee.name}(…)`;break;case"CallExpression":n=`${r.callee.object.name}.${r.callee.property.name}(…)`}return{node:t,messageId:o,data:{parentDescription:n},fix:r=>ls(r,t,e)}}),e.on("ArrayExpression",t=>{if(!la(t))return;let r=t.elements[0].argument,n=!!td(r,{methods:lo,optionalCall:!1,optionalMember:!1})&&rK(r.callee.object,e)&&rK(r,e);if(!n&&!(!rG(r,e)&&(td(r,{methods:ln,optionalCall:!1,optionalMember:!1})?!ll(r,e):td(r,{method:"concat",optionalCall:!1,optionalMember:!1})?!("Identifier"===r.callee.object.type&&"Iterator"===r.callee.object.name||ll(r,e)):td(r,{method:"split",optionalCall:!1,optionalMember:!1})||td(r,{object:"Object",methods:["keys","values"],argumentsLength:1,optionalCall:!1,optionalMember:!1})||"AwaitExpression"===r.type&&td(r.argument,{object:"Promise",methods:["all","allSettled"],argumentsLength:1,optionalCall:!1,optionalMember:!1})||td(r,{object:"Array",methods:["from","of"],optionalCall:!1,optionalMember:!1})||te(r,{name:"Array"}))))return;let o={node:t,messageId:le};return te(r,{name:"Array"})||td(r,{method:"slice",optionalCall:!1,optionalMember:!1})&&!n?o:Object.assign(o,{fix:r=>ls(r,t,e)})})},meta:{type:"suggestion",docs:{description:"Disallow unnecessary spread.",recommended:"unopinionated"},fixable:"code",hasSuggestions:!0,messages:{[s8]:"Spread an {{argumentType}} literal in {{parentDescription}} is unnecessary.",[s6]:"`{{parentDescription}}` accepts an iterable as an argument, it's unnecessary to convert to an array.",[s9]:"`for…of` can iterate over an iterable, it's unnecessary to convert to an array.",[s5]:"`yield*` can delegate to an iterable, it's unnecessary to convert to an array.",[s4]:"`{{constructorName}}` accepts a single iterable argument, spreading is misleading.",[s7]:"`Object.assign(…)` source object with only spread properties is unnecessary.",[le]:"Unnecessarily cloning an array.",[lt]:"Remove the object literal wrapper."},languages:["js/js"]}},"unicorn/no-useless-switch-case":{create:e=>{let t=ru(e.physicalFilename);e.on("SwitchStatement",function*(r){let{cases:n}=r;if(!(n.length<2)&&null===n.at(-1).test)for(let r=n.length-2;r>=0;r--){let o=n[r];if(!lc(o))break;t&&ld(o)||(yield{node:o,loc:function(e,t){let{sourceCode:r}=t,n=e.test||r.getFirstToken(e),o=r.getTokenAfter(n,ec);return{start:r.getLoc(e).start,end:r.getLoc(o).end}}(o,e),messageId:lu,suggest:[{messageId:lp,fix:e=>e.remove(o)}]})}})},meta:{type:"suggestion",docs:{description:"Disallow useless case in switch statements.",recommended:"unopinionated"},hasSuggestions:!0,messages:{[lu]:"Useless case in switch statement.",[lp]:"Remove this case."},languages:["js/js"]}},"unicorn/no-useless-undefined":lB,"unicorn/numeric-separators-style":lL,"unicorn/prefer-array-find":l3,"unicorn/prefer-array-flat-map":{create:e=>{e.on("CallExpression",t=>{if(!(td(t,{method:"flat",optionalCall:!1,optionalMember:!1})&&(0===t.arguments.length||1===t.arguments.length&&"Literal"===t.arguments[0].type&&"1"===t.arguments[0].raw)&&td(t.callee.object,{method:"map",optionalCall:!1})))return;let r=t.callee.object;if(ty(r.callee.object,l5)||rX(r.callee.object,e))return;let{sourceCode:n}=e,o=r.callee.property,a=t4(e,t,[r])||t.typeArguments||t.typeParameters||r.typeArguments||r.typeParameters?void 0:function*(r){yield oO(r,t,e),yield r.replaceText(o,"flatMap")};return{node:t,loc:{start:n.getLoc(o).start,end:n.getLoc(t).end},messageId:l8,fix:a}}),e.on("CallExpression",t=>{if(!td(t,{method:"flatMap",argumentsLength:1,optionalCall:!1,optionalMember:!1,computed:!1})||t.typeArguments||t.typeParameters)return;let r=t.callee.object;if(!td(r,{method:"filter",argumentsLength:1,optionalCall:!1,optionalMember:!1,computed:!1})||r.typeArguments||r.typeParameters||rh(r.callee.object)||rG(r.callee.object,e))return;let{sourceCode:n}=e;if(n.getCommentsInside(t).length>0)return;let[o]=r.arguments,[a]=t.arguments;if(!l7(o)||!l7(a))return;let[i]=o.params,[s]=a.params;if(!nB(i,s))return;let l=function(e,t){if(eQ(e,t))return eZ(e,t);let r=t.sourceCode.getText(e);return n2(e,t)?`(${r})`:r}(r.callee.object,e),u=n.getText(i),p=function(e,t){if(eQ(e,t))return eZ(e,t);let r=t.sourceCode.getText(e);return l4.has(e.type)?`(${r})`:r}(o.body,e),c=function(e,t){if(eQ(e,t))return eZ(e,t);let r=t.sourceCode.getText(e);return nQ(e)?`(${r})`:r}(a.body,e);return{node:t.callee.property,messageId:l6,suggest:[{messageId:l9,fix:e=>e.replaceText(t,`${l}.flatMap(${u} => ${p} ? ${c} : [])`)}]}})},meta:{type:"suggestion",docs:{description:"Prefer `.flatMap(…)` over `.map(…).flat()` and `.filter(…).flatMap(…)`.",recommended:"unopinionated"},fixable:"code",hasSuggestions:!0,messages:{[l8]:"Prefer `.flatMap(…)` over `.map(…).flat()`.",[l6]:"Prefer a single `.flatMap(…)` over `.filter(…).flatMap(…)`.",[l9]:"Replace `.filter(…).flatMap(…)` with a single `.flatMap(…)`."},languages:["js/js"]}},"unicorn/prefer-array-flat":ul,"unicorn/prefer-array-some":ud,"unicorn/prefer-code-point":{create:e=>{e.on("CallExpression",e=>{if(td(e,{method:"charCodeAt",optionalCall:!1}))return um(e.callee.property,"codePointAt")}),e.on("MemberExpression",e=>{if(tc(e,{object:"String",property:"fromCharCode",optional:!1}))return um(e.property,"fromCodePoint")})},meta:{type:"suggestion",docs:{description:"Prefer `String#codePointAt(…)` over `String#charCodeAt(…)` and `String.fromCodePoint(…)` over `String.fromCharCode(…)`.",recommended:"unopinionated"},hasSuggestions:!0,messages:{"error/charCodeAt":"Prefer `String#codePointAt()` over `String#charCodeAt()`.","error/fromCharCode":"Prefer `String.fromCodePoint()` over `String.fromCharCode()`.","suggestion/codePointAt":"Use `String#codePointAt()`.","suggestion/fromCodePoint":"Use `String.fromCodePoint()`."},languages:["js/js"]}},"unicorn/prefer-default-parameters":{create:e=>{let{sourceCode:t}=e,r=[],n=(e,n,o,a)=>{let i,s=r.at(-1);if(!s||!n||!o||"Identifier"!==n.type||"LogicalExpression"!==o.type||"||"!==o.operator&&"??"!==o.operator||"Identifier"!==o.left.type||"Literal"!==o.right.type)return;let{name:l}=n,{left:{name:u},right:{raw:p}}=o;if(a&&l!==u)return;let c=ei(t.getScope(e),u);if(!c)return;let{references:d}=c,{params:m}=s,f=m.find(e=>"Identifier"===e.type&&e.name===u);if(((e,t,r)=>{for(let n of t.body.body){if(n===r)break;if(uh(e,n))return!0}return!1})(t,s,e)||a&&d[0].identifier!==n||!a&&d.length>1||(i=m.at(-1),!f||f!==i))return;let g=((e,t)=>{if("ArrowFunctionExpression"!==t.type||t.params.length>1)return!1;let[r]=t.params,n=e.getTokenBefore(r),o=e.getTokenAfter(r);return!o||!n||"("!==n.value||")"!==o.value})(t,s)?`(${l} = ${p})`:`${l} = ${p}`;return{node:e,messageId:uf,suggest:[{messageId:ug,fix:r=>[r.replaceText(f,g),((e,t,r)=>{let{line:n}=t.getLoc(r).start,{column:o}=t.getLoc(r).end,a=t.getText(r),i=t.lines[n-1];if(i.trim()===a)return e.removeRange([t.getIndexFromLoc({line:n,column:0}),t.getIndexFromLoc({line:n+1,column:0})]);if(" "===i[o]){let[n,o]=t.getRange(r);return e.removeRange([n,o+1])}return e.remove(r)})(r,t,e)]}]}};e.on(ts,e=>{r.push(e)}),e.onExit(ts,()=>{r.pop()}),e.on("AssignmentExpression",e=>{if("ExpressionStatement"===e.parent.type&&e.parent.expression===e)return n(e.parent,e.left,e.right,!0)}),e.on("VariableDeclarator",e=>{if("VariableDeclaration"===e.parent.type&&e.parent.declarations[0]===e)return n(e.parent,e.id,e.init,!1)})},meta:{type:"suggestion",docs:{description:"Prefer default parameters over reassignment.",recommended:"unopinionated"},hasSuggestions:!0,messages:{[uf]:"Prefer default parameters over reassignment.",[ug]:"Replace reassignment with default parameter."},languages:["js/js"]}},"unicorn/prefer-logical-operator-over-ternary":{create:e=>{let{sourceCode:t}=e;e.on("ConditionalExpression",r=>{let{test:n,consequent:o,alternate:a}=r,i=function(e,t){let{test:r,consequent:n,alternate:o}=e,a=function(e,t){let r=uw(e);if(r?.kind==="nullish")return r;if("LogicalExpression"!==e.type)return;let n=uw(e.left),o=uw(e.right);if(n&&o&&uC(n.reference,o.reference,t)){if("||"===e.operator&&n.isTrueWhenNullish&&o.isTrueWhenNullish&&uk(n,o))return{reference:n.reference,isTrueWhenNullish:!0};if("&&"===e.operator&&!n.isTrueWhenNullish&&!o.isTrueWhenNullish&&uk(n,o))return{reference:n.reference,isTrueWhenNullish:!1}}}(r,t.sourceCode);if(!a||t.sourceCode.getCommentsInside(e).length>0)return;let{reference:i}=a;if(a.isTrueWhenNullish&&uC(i,o,t.sourceCode))return uA({context:t,conditionalExpression:e,left:o,right:n,operators:["??"]});if(!a.isTrueWhenNullish&&uC(i,n,t.sourceCode))return uA({context:t,conditionalExpression:e,left:n,right:o,operators:["??"]});let s=a.isTrueWhenNullish?n:o,l=a.isTrueWhenNullish?o:n;if(!tx(s)||!tc(l)||l.optional||!tQ(ry(i),ry(l.object))||function(e){let t=e,{parent:r}=t;for(;rg(r)&&r.expression===t;)r=(t=r).parent;return"UnaryExpression"===r.type&&"delete"===r.operator&&r.argument===t||"CallExpression"===r.type&&r.callee===t||"TaggedTemplateExpression"===r.type&&r.tag===t}(e))return;let u=function(e,t){let{sourceCode:r}=t,n=ri(e,t);if(re(t,n))return;let[o,a]=r.getRange(e),[i,s]=n;return r.text.slice(o,i)+(e.computed?"?.[":"?.")+r.text.slice(s,a)}(l,t);if(u)return{node:e,messageId:ub,suggest:[{messageId:uD,fix(r){let n=u;return nW(t.sourceCode.getTokenBefore(e),t,n)&&(n=`;${n}`),r.replaceText(e,n)}}]}}(r,e);return i||(uC(n,o,t)?uA({context:e,conditionalExpression:r,left:n,right:a}):"UnaryExpression"===n.type&&"!"===n.operator&&n.prefix&&uC(n.argument,a,t)?uA({context:e,conditionalExpression:r,left:n.argument,right:o}):void 0)})},meta:{type:"suggestion",docs:{description:"Prefer using a logical operator over a ternary.",recommended:"unopinionated"},hasSuggestions:!0,messages:{[ux]:"Prefer using a logical operator over a ternary.",[ub]:"Prefer using optional chaining over a ternary.",[uE]:"Switch to `{{operator}}` operator.",[uD]:"Switch to optional chaining."},languages:["js/js"]}},"unicorn/prefer-optional-catch-binding":{create:e=>{e.on("CatchClause",t=>{let r=t.param;if(!r)return;let{sourceCode:n}=e;if(n.getDeclaredVariables(r.parent).some(e=>e.references.length>0))return;let{type:o,name:a,parent:i}=r,s=n.getCommentsInside(r).length>0;return{node:r,messageId:"Identifier"===o?uI:uj,data:{name:a},fix:s?void 0:function*(e){let t=n.getTokenBefore(r);tw(t,{test:ed,expected:"(",ruleId:"prefer-optional-catch-binding"});let o=n.getTokenAfter(r);tw(o,{test:em,expected:")",ruleId:"prefer-optional-catch-binding"}),yield e.remove(t),yield e.remove(r),yield e.remove(o);let[,a]=n.getRange(o),[s]=n.getRange(i.body),l=n.text.slice(a,s),u=l.length-l.trimStart().length;0!==u&&(yield e.removeRange([a,a+u]))}}})},meta:{type:"suggestion",docs:{description:"Prefer omitting the `catch` binding parameter.",recommended:"unopinionated"},fixable:"code",messages:{[uI]:"Remove unused catch binding `{{name}}`.",[uj]:"Remove unused catch binding."},languages:["js/js"]}},"unicorn/prefer-regexp-test":u9,"unicorn/prefer-set-has":pc,"unicorn/prefer-string-raw":{create:e=>{e.on("Literal",t=>{if(!e1(t)||function(e){let{parent:t}=e,{type:r}=t;return tr(t)||["Property","PropertyDefinition","MethodDefinition","AccessorProperty"].includes(r)&&!t.computed&&t.key===e||["TSAbstractPropertyDefinition","TSAbstractMethodDefinition","TSAbstractAccessorProperty","TSPropertySignature"].includes(r)&&t.key===e||["ImportDeclaration","ExportNamedDeclaration","ExportAllDeclaration"].includes(r)&&t.source===e||"ImportAttribute"===r&&(t.key===e||t.value===e)||"ImportSpecifier"===r&&t.imported===e||"ExportSpecifier"===r&&(t.local===e||t.exported===e)||"ExportAllDeclaration"===r&&t.exported===e||"JSXAttribute"===r&&t.value===e||"TSEnumMember"===r&&(t.initializer===e||t.id===e)||"TSModuleDeclaration"===r&&t.id===e||"TSExternalModuleReference"===r&&t.expression===e||"TSLiteralType"===r&&t.literal===e||"TSImportType"===r&&t.source===e}(t)||pd(t))return;let{sourceCode:r}=e,{raw:n}=t;if("\\"===n.at(-2)||!n.includes("\\\\")||n.includes("`")||n.includes("${")||r.getLoc(t).start.line!==r.getLoc(t).end.line)return;let o=pg(n.slice(1,-1),n.charAt(0));if(o===t.value)return{node:t,messageId:pm,*fix(r){yield oP(r,t,e),yield r.replaceText(t,`String.raw\`${o}\``)}}}),e.on("TemplateLiteral",t=>{if(!("TaggedTemplateExpression"===t.parent.type&&t.parent.quasi===t||t.quasis.every(({value:{cooked:e,raw:t}})=>e===t)||t.quasis.some(({value:{cooked:e,raw:t}})=>"\\"===e.at(-1)||pg(t)!==e)||pd(t)))return{node:t,messageId:pm,*fix(r){for(let n of(yield oP(r,t,e),yield r.insertTextBefore(t,"String.raw"),t.quasis)){let{cooked:t,raw:o}=n.value;t!==o&&(yield o_(n,t,e,r))}}}}),e.on("TaggedTemplateExpression",t=>{let{quasi:r,tag:n,parent:o}=t,{sourceCode:a}=e;if(!tc(n,{object:"String",property:"raw",optional:!1})||!a.isGlobalReference(n.object)||r.quasis.some(e=>e.value.raw.includes("\\")))return;let i=a.getText(r),s=r.expressions.length>0||/\r?\n/.test(i)?i:`'${i.slice(1,-1).replaceAll("'",()=>String.raw`\'`)}'`;return{node:n,messageId:pf,*fix(r){let n=a.getTokenBefore(t);nW(n,e,s)&&(yield r.insertTextBefore(t,";")),"ReturnStatement"!==o.type&&"ThrowStatement"!==o.type||nF(n,t.quasi,e)||eQ(t,e)||(yield oF(r,o,e)),"YieldExpression"!==o.type||o.delegate||o.argument!==t||nF(n,t.quasi,e)||eQ(t,e)||(yield r.insertTextBefore(t,"("),yield r.insertTextAfter(t,")")),yield r.replaceText(t.quasi,s),yield oT(t.tag,r,e),yield r.remove(t.tag)}}})},meta:{type:"suggestion",docs:{description:"Prefer using the `String.raw` tag to avoid escaping `\\`.",recommended:"unopinionated"},fixable:"code",messages:{[pm]:"`String.raw` should be used to avoid escaping `\\`.",[pf]:"Using `String.raw` is unnecessary as the string does not contain any `\\`."},languages:["js/js"]}},"unicorn/prefer-switch":pS,"unicorn/require-number-to-fixed-digits-argument":{create:e=>{e.on("CallExpression",t=>{if(!td(t,{method:"toFixed",argumentsLength:0,optionalCall:!1})||"NewExpression"===t.callee.object.type)return;let{sourceCode:r}=e,[n,o]=r.getLastTokens(t,2);return{loc:{start:r.getLoc(n).start,end:r.getLoc(o).end},messageId:pv,fix:r=>ow(r,t,"0",e)}})},meta:{type:"suggestion",docs:{description:"Enforce using the digits argument with `Number#toFixed()`.",recommended:"unopinionated"},fixable:"code",messages:{[pv]:"Missing the digits argument."},languages:["js/js"]}},"unicorn/template-indent":{create:e=>{let{sourceCode:t}=e,r={...e.options[0]},n=(e=>{let t=new Set,r=[e.ast];for(;r.length>0;){let n=r.pop();if(n){if("TemplateLiteral"===n.type){let{start:{line:r},end:{line:o}}=e.getLoc(n);for(let e=r+1;e<=o;e++)t.add(e)}for(let t of e.visitorKeys[n.type]??[]){let e=n[t];Array.isArray(e)?r.push(...e):r.push(e)}}}return t})(t);r.comments=r.comments.map(e=>e.toLowerCase());let o=new WeakSet,a=a=>{let i;if("TemplateLiteral"!==a.type||o.has(a))return;o.add(a);let s="__PLACEHOLDER__"+Math.random(),l=a.quasis.map(e=>t.getText(e).slice(1,e.tail?-1:-2)).join(s),u=l.match(/\r?\n/);if(!u)return;let p=u[0],c=t.getLoc(a),d=t.lines[c.start.line-1].match(/^(\s*)\S/),m=d?d[1]:"";i="string"==typeof r.indent?r.indent:"number"==typeof r.indent?" ".repeat(r.indent):((e,t,r,n)=>{if(""===r){let r;return pk(pj(e.lines,t)).indent||pk(pC(r=pj(n.split(/\r?\n/)))).indent||pk(r).indent||" "}return r.startsWith(" ")?" ":" "})(t,n,m,l);let f=pC(l).replaceAll(RegExp(`^${p}|${p}[ ]*$`,"g"),""),g=p+function(e,t=1,r={}){let{indent:n=" ",includeEmptyLines:o=!1}=r;if("string"!=typeof e)throw TypeError(`Expected \`input\` to be a \`string\`, got \`${typeof e}\``);if("number"!=typeof t)throw TypeError(`Expected \`count\` to be a \`number\`, got \`${typeof t}\``);if(t<0)throw RangeError(`Expected \`count\` to be at least 0, got \`${t}\``);if("string"!=typeof n)throw TypeError(`Expected \`options.indent\` to be a \`string\`, got \`${typeof n}\``);return 0===t?e:e.replace(o?/^/gm:/^(?!\s*$)/gm,n.repeat(t))}(f,1,{indent:m+i})+p+m;if(g!==l)return{node:a,messageId:pI,fix:t=>g.split(s).map((r,n)=>o_(a.quasis[n],r,e,t))}};e.on("TemplateLiteral",e=>{if((e=>{if(r.comments.length>0){let n=t.getTokenBefore(e,{includeComments:!0});if(n?.type==="Block"&&r.comments.includes(n.value.trim().toLowerCase()))return!0}return!!(pd(e)||r.tags.length>0&&th(e,r.tags))||!!(r.functions.length>0&&"CallExpression"===e.parent.type&&e.parent.arguments.includes(e)&&ty(e.parent.callee,r.functions))})(e))return a(e)}),e.on(r.selectors,e=>a(e))},meta:{type:"suggestion",docs:{description:"Fix whitespace-insensitive template indentation.",recommended:!0},fixable:"code",schema:pF,defaultOptions:[{tags:["outdent","dedent","gql","sql","html","styled"],functions:["dedent","stripIndent"],selectors:[],comments:["HTML","indent"]}],messages:{[pI]:"Templates should be properly indented."},languages:["js/js"]}},"unicorn/no-single-promise-in-promise-methods":{create:e=>{e.on("CallExpression",t=>{if(!(td(t,{object:"Promise",methods:sJ,optionalMember:!1,optionalCall:!1,argumentsLength:1})&&"ArrayExpression"===t.arguments[0].type&&1===t.arguments[0].elements.length&&t.arguments[0].elements[0]&&"SpreadElement"!==t.arguments[0].elements[0].type))return;let r=t.callee.property.name,n={node:t.arguments[0],messageId:sz,data:{method:r}},{sourceCode:o}=e;if("AwaitExpression"===t.parent.type&&t.parent.argument===t&&("all"!==r||ti(t.parent.parent)))return n.fix=r=>r.replaceText(t,sX(t,e)),n;return"all"===r?(n.fix=((e,t)=>{let{sourceCode:r}=t;if(sY(r,e))return;let n=e.parent;if("AwaitExpression"!==n.type||n.argument!==e)return;let o=(e=>{let{parent:t}=e;return"VariableDeclarator"===t.type&&t.init===e&&sH(t.id)?t.id:"AssignmentExpression"===t.type&&t.right===e&&sH(t.left)&&ti(t.parent)?t.left:void 0})(n);if(o){if(sY(r,o))return;return function*(n){yield n.replaceText(o,r.getText(o.elements[0])),yield n.replaceText(e,sX(e,t))}}let a=n.parent;if("MemberExpression"===a.type&&a.computed&&e0(a.property,0)&&a.object===n&&("VariableDeclarator"===a.parent.type&&a.parent.init===a||"AssignmentExpression"===a.parent.type&&a.parent.right===a)&&!sY(r,a))return r=>r.replaceText(a,`await ${sX(e,t)}`)})(t,e),n):(n.suggest=[{messageId:sK,fix:r=>{let[n]=t.arguments[0].elements,o=eZ(n,e);return eQ(n,e)||"Identifier"===n.type||"MemberExpression"===n.type||(o=`(${o})`),nW(e.sourceCode.getTokenBefore(t),e,o)&&(o=`;${o}`),r.replaceText(t,o)}},{messageId:sG,fix:function*(e){let r=t.callee.property;yield e.replaceText(r,"resolve");let[n]=t.arguments,a=o.getFirstToken(n),[i,s]=o.getLastTokens(n,2);yield e.remove(a),yield e.remove(s),eu(i)&&(yield e.remove(i))}}],n)})},meta:{type:"suggestion",docs:{description:"Disallow passing single-element arrays to `Promise` methods.",recommended:"unopinionated"},fixable:"code",hasSuggestions:!0,messages:{[sz]:"Wrapping single-element array with `Promise.{{method}}()` is unnecessary.",[sK]:"Use the value directly.",[sG]:"Switch to `Promise.resolve(…)`."},languages:["js/js"]}},"unicorn/no-await-in-promise-methods":{create:e=>{e.on("CallExpression",function*(t){if(td(t,{object:"Promise",methods:p$,optionalMember:!1,optionalCall:!1,argumentsLength:1})&&"ArrayExpression"===t.arguments[0].type)for(let r of t.arguments[0].elements)r?.type==="AwaitExpression"&&(yield{node:r,messageId:pB,data:{method:t.callee.property.name},suggest:[{messageId:pR,*fix(t){let n=e.sourceCode.getFirstToken(r);yield t.remove(n),yield oB(n,e,t)}}]})})},meta:{type:"suggestion",docs:{description:"Disallow using `await` in `Promise` method parameters.",recommended:"unopinionated"},hasSuggestions:!0,messages:{[pB]:"Promise in `Promise.{{method}}()` should not be awaited.",[pR]:"Remove `await`."},languages:["js/js"]}},"unicorn/no-negation-in-equality-check":{create:e=>{e.on("BinaryExpression",t=>{let{operator:r,left:n}=t;if(!("BinaryExpression"===t.type&&pN.has(t.operator)&&pM(n)&&!pM(n.argument)))return;let{sourceCode:o}=e,a=o.getFirstToken(n),i=`${r.startsWith("!")?"=":"!"}${r.slice(1)}`;return{node:a,messageId:pP,suggest:[{messageId:pL,data:{operator:i},*fix(s){yield oP(s,t,e);let l=o.getTokenAfter(a),{parent:u}=t;("ReturnStatement"===u.type||"ThrowStatement"===u.type)&&!eQ(t,e)&&(nF(o.getFirstToken(u),l,e)||(yield oF(s,u,e))),yield s.remove(a),nW(o.getTokenBefore(a),e,l.value)&&(yield s.insertTextAfter(a,";"));let p=o.getTokenAfter(n,e=>"Punctuator"===e.type&&e.value===r);yield s.replaceText(p,i)}}]}})},meta:{type:"problem",docs:{description:"Disallow negated expression in equality check.",recommended:"unopinionated"},hasSuggestions:!0,messages:{[pP]:"Negated expression is not allowed in equality check.",[pL]:"Switch to '{{operator}}' check."},languages:["js/js"]}},"unicorn/no-unnecessary-slice-end":{create(e){pO(e,{methods:["slice"],messageId:pq})},meta:{type:"suggestion",docs:{description:"Disallow using `.length` or `Infinity` as the `end` argument of `{Array,String,TypedArray}#slice()`.",recommended:"unopinionated"},fixable:"code",messages:{[pq]:"Passing `{{description}}` as the `end` argument is unnecessary."},languages:["js/js"]}},"unicorn/no-lonely-if":{create:e=>{e.on("IfStatement",t=>{if(cr(t)&&("BlockStatement"===t.parent.type&&1===t.parent.body.length&&t.parent.body[0]===t&&cr(t.parent.parent)&&t.parent.parent.consequent===t.parent||cr(t.parent)&&t.parent.consequent===t))return{node:t,messageId:ct,fix:function(e,t){let{sourceCode:r}=t;return n=>{var o,a;let i=("BlockStatement"===e.parent.type?e.parent:e).parent,s={...i,...cn(i,r)},l={...e,...cn(e,r)},u=cs(s,r),p=cl(s,t,r),c=ci(ca(cs(l,r)),cl(l,t,r)),d=function(e,t,r,n){let o=[...n.getRange(e)];if("BlockStatement"===t.type)return o;let a=n.getLastToken(t);if(ey(a)){let t=n.getTokenAfter(e);t&&nW(a,r,t.value)&&(o[1]=n.getRange(t)[0])}return o}(i,l.consequent,t,r),m={outerConditionGap:s.openingBraceToken?ca(co(s.closingParenthesisToken,s.openingBraceToken,r)):"",outerLeadingContent:s.openingBraceToken?ca(co(s.openingBraceToken,l.ifToken,r)):ca(co(s.closingParenthesisToken,l.ifToken,r)),outerTrailingContent:s.openingBraceToken?ca(co(l,s.closingBraceToken,r)):""},f=(o=m.outerConditionGap,a=m.outerLeadingContent,o.trimStart().startsWith("//")?{leadingStatementText:ca(a).trimStart(),conditionSuffixText:o}:{leadingStatementText:ca(ci(o,a)).trimStart(),conditionSuffixText:""}),{leadingStatementText:g}=f,y=function({outerIfStatement:e,inner:t,replacementRange:r,sourceCode:n,consequentTextPieces:o,outerConditionGapTextPieces:a}){let{outerTrailingContent:i}=o,{conditionSuffixText:s}=a;if("BlockStatement"===t.consequent.type){let e=co(t.closingParenthesisToken,t.openingBraceToken,n),r=co(t.openingBraceToken,t.closingBraceToken,n);return`${s}${e}{${r}${i}}`}let l=co(t.closingParenthesisToken,t.consequent,n),u=`${s}${l}${((e,t)=>{let[r,n]=t.getRange(e);return t.text.slice(r,n)})(t.consequent,n)}${i}`;return`${u}${((e,t,r)=>{let[,n]=r.getRange(e);if(t[1]===n)return"";let o=r.text.slice(n,t[1]);return""===o.trim()?o.includes("\n")?`;${o}`:";":`;${o}`})(e,r,n)}`}({outerIfStatement:i,inner:l,replacementRange:d,sourceCode:r,consequentTextPieces:m,outerConditionGapTextPieces:f});return n.replaceTextRange(d,`${g}if${u}(${p} && ${c})${y}`)}}(t,e)}})},meta:{type:"suggestion",docs:{description:"Disallow `if` statements as the only statement in `if` blocks without `else`.",recommended:"unopinionated"},fixable:"code",messages:{[ct]:"Unexpected `if` as the only statement in a `if` block without `else`."},languages:["js/js"]}},"unicorn/no-magic-array-flat-depth":{create:e=>{e.on("CallExpression",t=>{if(!td(t,{method:"flat",argumentsLength:1,optionalCall:!1}))return;let[r]=t.arguments;if(!e8(r)||1===r.value)return;let{sourceCode:n}=e,{openingParenthesisToken:o,closingParenthesisToken:a}=tX(t,e);if(!n.commentsExistBetween(o,a))return{node:r,messageId:cu}})},meta:{type:"suggestion",docs:{description:"Disallow a magic number as the `depth` argument in `Array#flat(…).`",recommended:"unopinionated"},messages:{[cu]:"Magic number as depth is not allowed."},languages:["js/js"]}},"unicorn/no-negated-condition":{create:e=>{e.on(["IfStatement","ConditionalExpression"],t=>{if("IfStatement"===t.type&&(!t.alternate||"IfStatement"===t.alternate.type))return;let{test:r}=t;if("UnaryExpression"===r.type&&"!"===r.operator||"BinaryExpression"===r.type&&("!="===r.operator||"!=="===r.operator))return{node:r,messageId:cp,*fix(n){if(yield function*(e,t,r){let{sourceCode:n}=r,{test:o}=t;if("UnaryExpression"===o.type){let a=n.getFirstToken(o);"IfStatement"===t.type&&(yield oT(o.argument,e,r)),yield e.remove(a);return}let a=n.getTokenAfter(o.left,e=>"Punctuator"===e.type&&e.value===o.operator);yield e.replaceText(a,"="+a.value.slice(1))}(n,t,e),yield function*(e,t,r){let n="IfStatement"===t.type,[o,a]=[t.consequent,t.alternate].map(e=>{let t=eH(e,r),o=r.sourceCode.text.slice(...t);return n&&"BlockStatement"!==e.type&&(o=`{${o}}`),{range:t,text:o}});if(o.text===a.text)return;let{sourceCode:i}=r;yield e.replaceTextRange(i.getRange(o),a.text),yield e.replaceTextRange(i.getRange(a),o.text)}(n,t,e),"ConditionalExpression"!==t.type||"UnaryExpression"!==r.type)return;yield oP(n,t,e);let{sourceCode:o}=e,{parent:a}=t,[i,s]=o.getFirstTokens(r,2);"ReturnStatement"!==a.type&&"ThrowStatement"!==a.type||a.argument!==t||nF(i,s,e)||eQ(t,e)||eQ(r,e)?nW(o.getTokenBefore(t),e,s.value)&&(yield n.insertTextBefore(t,";")):yield oF(n,a,e)}}})},meta:{type:"suggestion",docs:{description:"Disallow negated conditions.",recommended:"unopinionated"},fixable:"code",messages:{[cp]:"Unexpected negated condition."},languages:["js/js"]}},"unicorn/no-object-as-default-parameter":{create:e=>{e.on("AssignmentPattern",e=>{if(!("ObjectExpression"===e.right.type&&e.right.properties.length>0&&tl(e.parent)&&e.parent.params.includes(e)))return;let{left:t,right:r}=e;return"Identifier"===t.type?{node:t,messageId:cc,data:{parameter:t.name}}:{node:r,messageId:cd}})},meta:{type:"problem",docs:{description:"Disallow the use of objects as default parameters.",recommended:"unopinionated"},messages:{[cc]:"Do not use an object literal as default for parameter `{{parameter}}`.",[cd]:"Do not use an object literal as default."},languages:["js/js"]}},"unicorn/prefer-negative-index":{create:e=>{e.on("CallExpression",t=>{if("MemberExpression"!==t.callee.type)return;let r=function(e){let{callee:t,arguments:r}=e,n=t.property.name,o=t.object,a=r;if(cf.has(n))return{method:n,target:o,argumentsNodes:a};if("call"!==n&&"apply"!==n||(n=cg(t.object),!cf.has(n)))return;let i="apply"===t.property.name,{supportObjects:s}=cf.get(n),l=t.object.object;if(to(l)||"slice"===n&&e0(l,"")||"prototype"===cg(l)&&"Identifier"===l.object.type&&s.has(l.object.name)){if([o]=r,i){let[,e]=r;if(!e||"ArrayExpression"!==e.type)return;a=e.elements}else a=r.slice(1);return{method:n,target:o,argumentsNodes:a}}}(t);if(!r)return;let{method:n,target:o,argumentsNodes:a}=r,{argumentsIndexes:i}=cf.get(n),s=i.map(e=>(function e(t,r){let n;if(!t)return;let{type:o,operator:a,left:i,right:s}=t=ry(t);if("BinaryExpression"!==o||"-"!==a||!(e8(n=ry(s))&&n.value>0))return;let l=ry(i);return"MemberExpression"===l.type&&!l.computed&&!l.optional&&"Identifier"===l.property.type&&"length"===l.property.name&&ly(l.object,r)?i:e(i,r)})(a[e],o)).filter(Boolean);if(0!==s.length)return{node:t,messageId:cm,data:{method:n},*fix(t){for(let r of s)yield function(e,t,r){let[n,o]=eH(e,r);return t.removeRange([n,o+r.sourceCode.text.slice(o).match(/\S|$/).index])}(r,t,e)}}})},meta:{type:"suggestion",docs:{description:"Prefer negative index over `.length - index` when possible.",recommended:"unopinionated"},fixable:"code",messages:{[cm]:"Prefer negative index over length minus index for `{{method}}`."},languages:["js/js"]}},"unicorn/prefer-node-protocol":{create:e=>{e.on("Literal",t=>{if(!(["ImportDeclaration","ExportNamedDeclaration","ExportAllDeclaration","ImportExpression","TSImportType"].includes(t.parent.type)&&t.parent.source===t||(td(t.parent,{object:"process",method:"getBuiltinModule",argumentsLength:1,optionalCall:!1,optionalMember:!1})||tf(t.parent))&&t.parent.arguments[0]===t))return;let{value:r}=t;if(!("string"==typeof r&&!r.startsWith(cb)&&ch(r)&&ch(`${cb}${r}`)))return;let n=e.sourceCode.getRange(t)[0]+1;return{node:t,messageId:cx,data:{moduleName:r},fix:e=>e.insertTextAfterRange([n,n],cb)}})},meta:{type:"suggestion",docs:{description:"Prefer using the `node:` protocol when importing Node.js builtin modules.",recommended:"unopinionated"},fixable:"code",messages:{[cx]:"Prefer `node:{{moduleName}}` over `{{moduleName}}`."},languages:["js/js"]}},"unicorn/consistent-date-clone":{create:e=>{e.on("NewExpression",t=>{if(!te(t,{name:"Date",argumentsLength:1}))return;let[r]=t.arguments;if(!td(r,{method:"getTime",argumentsLength:0,optionalCall:!1,optionalMember:!1}))return;let{sourceCode:n}=e;return{node:r,loc:{start:n.getLoc(r.callee.property).start,end:n.getLoc(r).end},messageId:cE,fix:t=>oO(t,r,e)}})},meta:{type:"suggestion",docs:{description:"Prefer passing `Date` directly to the constructor when cloning.",recommended:"unopinionated"},fixable:"code",messages:{[cE]:"Unnecessary `.getTime()` call."},languages:["js/js"]}},"unicorn/no-accessor-recursion":{create:e=>{let{sourceCode:t}=e;e.on("ThisExpression",e=>{let r=((e,t)=>{for(let r=e.getScope(t);r;r=r.upper){if("class"===r.type)return;if("function"===r.type&&"ArrowFunctionExpression"!==r.block.type)return r}})(t,e);if(!r)return;let n=r.block.parent;if(["Property","MethodDefinition"].includes(n?.type)&&!n.computed&&["set","get"].includes(n.kind)&&cS(n.key)&&("get"===n.kind&&(cC(e,n)||"VariableDeclarator"===e.parent.type&&e.parent.init===e&&"ObjectPattern"===e.parent.id.type&&e.parent.id.properties.some(e=>"Property"===e.type&&!e.computed&&cv(e.key,n.key)))||"set"===n.kind&&((e,t)=>{if(!cC(e,t))return!1;let r=e.parent,{parent:n}=r;return("AssignmentExpression"===n.type||"AssignmentPattern"===n.type)&&n.left===r||"UpdateExpression"===n.type&&n.argument===r||"ArrayPattern"===n.type&&n.elements.includes(r)||"RestElement"===n.type&&n.argument===r||("ForOfStatement"===n.type||"ForInStatement"===n.type)&&n.left===r||"Property"===n.type&&n.value===r&&"ObjectPattern"===n.parent.type&&n.parent.properties.includes(r.parent)})(e,n)))return{node:e.parent,messageId:cD,data:{kind:n.kind}}})},meta:{type:"problem",docs:{description:"Disallow recursive access to `this` within getters and setters.",recommended:"unopinionated"},defaultOptions:[],messages:{[cD]:"Disallow recursive access to `this` within {{kind}}ters."},languages:["js/js"]}},"unicorn/prefer-import-meta-properties":{create:function(e){let{sourceCode:t}=e;e.on("MetaProperty",function*(e){if("MetaProperty"!==e.type||"import"!==e.meta.name||"meta"!==e.property.name)return;let r=e.parent;if(!tc(r,{properties:["url","filename"],computed:!1,optional:!1}))return;let n=r.property.name;if("url"===n){if(ck(r.parent,t)&&r.parent.arguments[0]===r)return void(yield a(r.parent,{reportFilenameNode:!0}));if(te(r.parent,{name:"URL",minimumArguments:1,maximumArguments:2})){var o;let e=r.parent,n=e.parent;if(1===e.arguments.length&&e.arguments[0]===r&&ck(n,t)&&n.arguments[0]===e)return void(yield a(n,{reportFilenameNode:!0}));2===e.arguments.length&&(o=e.arguments[0],o?.type==="Literal"&&("."===o.value||"./"===o.value))&&e.arguments[1]===r&&ck(n,t)&&n.arguments[0]===e&&(yield i(n,"dirname"))}return}function*a(e,{reportFilenameNode:r=!1}={}){let{parent:n}=e;if(cI(n,t)&&n.arguments[0]===e)return void(yield i(n,"dirname"));if(r&&(yield i(e,"filename")),"VariableDeclarator"!==n.type||n.init!==e||"Identifier"!==n.id.type||"VariableDeclaration"!==n.parent.type||"const"!==n.parent.kind)return;let o=ei(t.getScope(n.id),n.id);if(o)for(let e of o.references){if(!e.isReadOnly())continue;let{parent:r}=e.identifier;cI(r,t)&&r.arguments[0]===e.identifier&&(yield i(r,"dirname"))}}function i(e,t){return{node:e,messageId:"dirname"===t?cA:cT,fix:r=>r.replaceText(e,`import.meta.${t}`)}}"filename"===n&&(yield a(r))})},meta:{type:"suggestion",docs:{description:"Prefer `import.meta.{dirname,filename}` over legacy techniques for getting file paths.",recommended:!1},fixable:"code",messages:{[cA]:"Do not construct dirname.",[cT]:"Do not construct filename using `fileURLToPath()`."},languages:["js/js"]}},"unicorn/no-unnecessary-array-flat-depth":{create:e=>{e.on("CallExpression",t=>{if(!(td(t,{method:"flat",argumentsLength:1,optionalCall:!1})&&e0(t.arguments[0],1)))return;let[r]=t.arguments;return{node:r,messageId:cj,fix:t=>ok(t,r,e)}})},meta:{type:"suggestion",docs:{description:"Disallow using `1` as the `depth` argument of `Array#flat()`.",recommended:"unopinionated"},fixable:"code",messages:{[cj]:"Passing `1` as the `depth` argument is unnecessary."},languages:["js/js"]}},"unicorn/no-unnecessary-array-splice-count":{create(e){pO(e,{methods:["splice","toSpliced"],messageId:cF})},meta:{type:"suggestion",docs:{description:"Disallow using `.length` or `Infinity` as the `deleteCount` or `skipCount` argument of `Array#{splice,toSpliced}()`.",recommended:"unopinionated"},fixable:"code",messages:{[cF]:"Passing `{{description}}` as the `{{argumentName}}` argument is unnecessary."},languages:["js/js"]}},"unicorn/no-useless-error-capture-stack-trace":{create:e=>{let t=[],r=[];e.on(["ClassDeclaration","ClassExpression"],e=>{t.push(e),r.push(e)}),e.onExit(["ClassDeclaration","ClassExpression"],()=>{t.pop(),r.pop()}),e.on(["FunctionDeclaration","FunctionExpression"],e=>{r.push(e)}),e.onExit(["FunctionDeclaration","FunctionExpression"],()=>{r.pop()}),e.on("CallExpression",n=>{let o,a=t.at(-1);if(!(a?.superClass&&"Identifier"===a.superClass.type&&i4.includes(a.superClass.name)&&e.sourceCode.isGlobalReference(a.superClass)&&(o=r.at(-1),o&&"MethodDefinition"===o.parent.type&&"constructor"===o.parent.kind&&o.parent.value===o&&a.body.body.includes(o.parent))&&td(n,{object:"Error",method:"captureStackTrace",argumentsLength:2,optionalMember:!1})&&e.sourceCode.isGlobalReference(n.callee.object)))return;let[i,s]=n.arguments;if("ThisExpression"!==i.type||!((e,t,r)=>{if("MetaProperty"===e.type&&"Identifier"===e.meta.type&&"new"===e.meta.name&&"Identifier"===e.property.type&&"target"===e.property.name||tc(e,{property:"constructor",computed:!1,optional:!1})&&"ThisExpression"===e.object.type)return!0;if("Identifier"!==e.type||!t.id)return!1;let n=ei(r.sourceCode.getScope(e),e);return n&&1===n.defs.length&&"ClassName"===n.defs[0].type&&n.defs[0].node===t})(s,a,e))return;let l={node:n,messageId:cB},u="ChainExpression"===n.parent.type?n.parent.parent:n.parent;return"ExpressionStatement"===u.type&&"BlockStatement"===u.parent.type&&(l.fix=e=>e.remove(u)),l})},meta:{type:"suggestion",docs:{description:"Disallow unnecessary `Error.captureStackTrace(…)`.",recommended:"unopinionated"},fixable:"code",messages:{[cB]:"Unnecessary `Error.captureStackTrace(…)` call."},languages:["js/js"]}},"unicorn/prefer-class-fields":{create:e=>{let{sourceCode:t}=e;e.on("ClassBody",r=>{let n=r.body.find(e=>"constructor"===e.kind&&!e.computed&&!e.static&&"MethodDefinition"===e.type&&"FunctionExpression"===e.value.type);if(!n)return;let o=n.value.body.body.find(e=>"EmptyStatement"!==e.type);if(!(o?.type==="ExpressionStatement"&&"AssignmentExpression"===o.expression.type&&"="===o.expression.operator&&"MemberExpression"===o.expression.left.type&&"ThisExpression"===o.expression.left.object.type&&!o.expression.left.computed&&["Identifier","PrivateIdentifier"].includes(o.expression.left.property.type)&&"Literal"===o.expression.right.type))return;let a=o.expression.left.property.name,i=o.expression.right.raw,s=o.expression.left.property.type,l=r.body.find(e=>"PropertyDefinition"===e.type&&!e.computed&&!e.static&&e.key.type===s&&e.key.name===a),u={node:o,messageId:cR};function*p(s){if(yield((e,t,r)=>{let{line:n}=t.getLoc(e).start,o=t.getText(e);return t.lines[n-1].trim()===o?r.removeRange([t.getIndexFromLoc({line:n,column:0}),t.getIndexFromLoc({line:n+1,column:0})]):r.remove(e)})(o,t,s),l){if(l.value)return void(yield s.replaceText(l.value,i));let e=` = ${i}`,r=t.getLastToken(l);return ep(r)?void(yield s.insertTextBefore(r,e)):void(yield s.insertTextAfter(l,`${e};`))}let u=t.getLastToken(r),p=t8(n,e),c=`${p}${a} = ${i};
|
|
26
|
+
${s}${c}${n}`)}for(let e of t)yield l.removeRange(Dt(e,{leading:r,trailing:n,isStart:o},a))}}({ifStatement:e,blocks:t,leading:r,trailing:n,isStart:o},a);!o||function(e,t){for(let r=e;r?.type==="IfStatement";r=r.alternate)if(E4(r.test,t))return!1;return!0}(e,s)&&u.every(e=>"ExpressionStatement"===e.type&&!E4(e,s))?c.fix=i:c.suggest=[{messageId:E9,fix:i}]}return c}let{parse:Dn}=im,Do="prefer-single-replace",Da=new Set(["g","m","s"]),Di=new Map([["\\",String.raw`\\`],["]",String.raw`\]`],["\n",String.raw`\n`],["\r",String.raw`\r`],[" ",String.raw`\t`],["\f",String.raw`\f`],["\v",String.raw`\v`],["\u2028",String.raw`\u2028`],["\u2029",String.raw`\u2029`]]);function Ds(e){if(!td(e,{methods:["replace","replaceAll"],argumentsLength:2,optionalCall:!1,optionalMember:!1,computed:!1}))return;let[t]=e.arguments;if(e1(t)){if("replaceAll"!==e.callee.property.name)return;return 1===t.value.length?t.value:void 0}if(e6(t))return function({pattern:e,flags:t}){let r;if(t.includes("g")){for(let e of t)if(!Da.has(e))return;try{r=Dn(e,t,{namedGroups:!0,lookbehind:!0})}catch{return}return function e(t){return"value"===t.type?String.fromCodePoint(t.codePoint):("alternative"!==t.type||1!==t.body.length)&&("characterClass"!==t.type||t.negative||1!==t.body.length)?void 0:e(t.body[0])}(r)}}(t.regex)}let Dl={configs:{node:{name:"@eslint-sukka/eslint-plugin-sukka-full node preset",plugins:{get sukka(){return Dl}},rules:{"sukka/unicorn/prefer-node-protocol":"error","sukka/unicorn/prefer-import-meta-properties":"error","no-process-exit":"off","sukka/unicorn/no-process-exit":"warn","no-buffer-constructor":"off","sukka/unicorn/no-new-buffer":"error"}},comment:{name:"@eslint-sukka/eslint-plugin-sukka-full comments preset",plugins:{get sukka(){return Dl}},rules:{"sukka/ban-eslint-disable":["error","allow-with-description"]}},recommended:{...u.eslint_plugin_sukka.configs.recommended,plugins:{get sukka(){return Dl}},rules:{...u.eslint_plugin_sukka.configs.recommended.rules,"sukka/prefer-single-boolean-return":"off","sukka/array/no-unneeded-flat-map":"error","sukka/browser/prefer-location-assign":"warn","sukka/jsx/no-template-literal":"error","sukka/jsx/no-unneeded-nested":"error","sukka/string/no-locale-case":"warn","sukka/string/no-simple-template-literal":"error","sukka/unicode/no-bidi":"warn","sukka/unicode/no-invisible":"warn","sukka/no-redundant-variable":"error","sukka/no-single-return":"warn","sukka/prefer-early-return":["error",{maximumStatements:16}],"sukka/prefer-fetch":"error","sukka/prefer-timer-id":"warn"}},recommended_unicorn:{name:"@eslint-sukka/eslint-plugin-sukka-full recommended unicorn preset",plugins:{get sukka(){return Dl}},rules:{"sukka/unicorn/no-lonely-if":"error","sukka/unicorn/no-negated-condition":"warn","sukka/unicorn/catch-error-name":["error",{ignore:[/^(?:e|err|error|\w+Err|\w+Error)[\d_]?$/]}],"sukka/unicorn/custom-error-definition":"error","sukka/unicorn/require-array-join-separator":"warn","sukka/unicorn/no-thenable":"error","sukka/unicorn/no-invalid-remove-event-listener":"error","sukka/unicorn/consistent-function-scoping":"warn","sukka/unicorn/prefer-event-target":"warn","sukka/unicorn/prefer-keyboard-event-key":"warn","sukka/unicorn/prefer-text-content":"warn","sukka/unicorn/no-console-spaces":"warn","sukka/unicorn/no-empty-file":"warn","sukka/unicorn/no-useless-fallback-in-spread":"warn","sukka/unicorn/no-useless-length-check":"warn","sukka/unicorn/no-useless-promise-resolve-reject":"warn","sukka/unicorn/no-zero-fractions":"warn","sukka/unicorn/prefer-export-from":["warn",{checkUsedVariables:!1}],"sukka/unicorn/prefer-native-coercion-functions":"warn","sukka/unicorn/prefer-negative-index":"warn","sukka/unicorn/no-document-cookie":"error","sukka/unicorn/prefer-add-event-listener":"warn","sukka/unicorn/prefer-array-index-of":"warn","sukka/unicorn/prefer-blob-reading-methods":"warn","sukka/unicorn/prefer-date-now":"warn","sukka/unicorn/dom-node-dataset":"warn","sukka/unicorn/prefer-modern-math-apis":"warn","sukka/unicorn/number-literal-case":"error","sukka/unicorn/prefer-number-properties":["warn",{checkInfinity:!1}],"sukka/unicorn/prefer-reflect-apply":"warn","sukka/unicorn/prefer-set-size":"warn","sukka/unicorn/prefer-string-replace-all":"warn","sukka/unicorn/prefer-string-slice":"warn","sukka/unicorn/prefer-string-trim-start-end":"warn","sukka/unicorn/no-unreadable-iife":"warn","sukka/unicorn/throw-new-error":"warn","sukka/unicorn/escape-case":"warn","sukka/unicorn/prefer-unicode-code-point-escapes":"warn","sukka/unicorn/prefer-prototype-methods":"warn","sukka/unicorn/error-message":"error","sukka/unicorn/no-instanceof-builtins":["error",{strategy:"loose"}],"sukka/unicorn/prefer-type-error":"error","sukka/unicorn/consistent-destructuring":"warn","sukka/unicorn/new-for-builtins":"warn","sukka/unicorn/prefer-single-call":"warn","sukka/unicorn/no-static-only-class":"warn","sukka/unicorn/no-unreadable-array-destructuring":"error","sukka/unicorn/no-useless-spread":"error","sukka/unicorn/no-useless-switch-case":"warn","sukka/unicorn/no-useless-undefined":["error",{checkArguments:!1}],"sukka/unicorn/numeric-separators-style":["warn",{onlyIfContainsSeparator:!1,number:{minimumDigits:7,groupLength:3},binary:{minimumDigits:9,groupLength:4},octal:{minimumDigits:9,groupLength:4},hexadecimal:{minimumDigits:5,groupLength:2}}],"sukka/unicorn/prefer-array-find":"warn","sukka/unicorn/prefer-array-flat-map":"warn","sukka/unicorn/prefer-array-flat":"warn","sukka/unicorn/prefer-array-some":"warn","sukka/unicorn/prefer-code-point":"warn","sukka/unicorn/prefer-default-parameters":"warn","sukka/unicorn/prefer-logical-operator-over-ternary":"warn","sukka/unicorn/prefer-optional-catch-binding":"error","sukka/unicorn/prefer-regexp-test":"warn","sukka/unicorn/prefer-set-has":"error","sukka/unicorn/prefer-switch":"warn","sukka/unicorn/require-number-to-fixed-digits-argument":"warn","sukka/unicorn/prefer-string-raw":"warn","sukka/unicorn/no-single-promise-in-promise-methods":"error","sukka/unicorn/no-await-in-promise-methods":"error","sukka/unicorn/no-magic-array-flat-depth":"error","sukka/unicorn/no-object-as-default-parameter":"error","sukka/unicorn/template-indent":["warn",{tags:["outdent","dedent","gql","sql","html","styled","css"],functions:["dedent","stripIndent","strip_indent","stripTags","striptags","strip_tags","stripHtml","stripHTML","strip_html"],selectors:[],comments:["HTML","html","CSS","css","indent"]}],"sukka/unicorn/no-negation-in-equality-check":"error","sukka/unicorn/no-unnecessary-slice-end":"error","sukka/unicorn/consistent-date-clone":"error","sukka/unicorn/no-accessor-recursion":"error","sukka/unicorn/no-unnecessary-array-flat-depth":"error","sukka/unicorn/no-unnecessary-array-splice-count":"error","sukka/unicorn/no-useless-error-capture-stack-trace":"error","sukka/unicorn/prefer-class-fields":"error","sukka/unicorn/prefer-bigint-literals":"error","sukka/unicorn/prefer-classlist-toggle":"warn","sukka/unicorn/require-module-attributes":"error","sukka/unicorn/no-immediate-mutation":"error","sukka/unicorn/no-useless-collection-argument":"error","sukka/unicorn/prefer-response-static-json":"error","sukka/unicorn/consistent-template-literal-escape":"error","sukka/unicorn/no-useless-iterator-to-array":"error","sukka/unicorn/prefer-simple-condition-first":"error","sukka/unicorn/switch-case-break-position":"error","sukka/unicorn/better-dom-traversing":"warn","sukka/unicorn/no-blob-to-file":"error","sukka/unicorn/no-canvas-to-image":"warn","sukka/unicorn/no-confusing-array-splice":"error","sukka/unicorn/no-duplicate-set-values":"error","sukka/unicorn/no-incorrect-query-selector":"error","sukka/unicorn/no-invalid-file-input-accept":"error","sukka/unicorn/no-late-current-target-access":"error","sukka/unicorn/no-unused-array-method-return":"error","sukka/unicorn/prefer-array-last-methods":"warn","sukka/unicorn/prefer-math-abs":"warn","sukka/unicorn/prefer-split-limit":"warn","sukka/unicorn/prefer-queue-microtask":"warn","sukka/unicorn/prefer-string-pad-start-end":"warn","sukka/unicorn/require-css-escape":"error","sukka/unicorn/require-passive-events":"warn","sukka/unicorn/class-reference-in-static-methods":"warn","sukka/unicorn/consistent-optional-chaining":"error","sukka/unicorn/explicit-timer-delay":"warn","sukka/unicorn/no-confusing-array-with":"error","sukka/unicorn/no-duplicate-loops":"warn","sukka/unicorn/no-declarations-before-early-exit":"warn","sukka/unicorn/no-optional-chaining-on-undeclared-variable":"error","sukka/unicorn/no-object-methods-with-collections":"error","sukka/unicorn/no-subtraction-comparison":"warn","sukka/unicorn/no-unnecessary-global-this":"warn","sukka/unicorn/no-useless-else":"error","sukka/unicorn/no-useless-recursion":"error","sukka/unicorn/prefer-add-event-listener-options":"warn","sukka/unicorn/prefer-direct-iteration":"warn","sukka/unicorn/prefer-number-is-safe-integer":"warn","sukka/unicorn/prefer-object-define-properties":"warn","sukka/unicorn/prefer-object-destructuring-defaults":"warn","sukka/unicorn/prefer-single-object-destructuring":"warn","sukka/unicorn/prefer-smaller-scope":"warn","sukka/unicorn/prefer-single-array-predicate":"warn","sukka/unicorn/prefer-url-href":"warn","sukka/unicorn/require-proxy-trap-boolean-return":"error","sukka/unicorn/logical-assignment-operators":"error","sukka/unicorn/no-useless-coercion":"error","sukka/unicorn/no-useless-boolean-cast":"warn","sukka/unicorn/no-useless-continue":"error","sukka/unicorn/no-useless-override":"error","sukka/unicorn/prefer-has-check":"warn","sukka/unicorn/consistent-conditional-object-spread":"error","sukka/unicorn/no-boolean-sort-comparator":"error","sukka/unicorn/no-chained-comparison":"error","sukka/unicorn/no-constant-zero-expression":"error","sukka/unicorn/no-duplicate-logical-operands":"error","sukka/unicorn/no-impossible-length-comparison":"error","sukka/unicorn/no-invalid-character-comparison":"error","sukka/unicorn/no-loop-iterable-mutation":"error","sukka/unicorn/no-selector-as-dom-name":"error","sukka/unicorn/no-array-concat-in-loop":"error","sukka/unicorn/no-array-front-mutation":"warn","sukka/unicorn/no-array-sort-for-min-max":"warn","sukka/unicorn/no-useless-compound-assignment":"warn","sukka/unicorn/no-useless-delete-check":"warn","sukka/unicorn/no-useless-logical-operand":"error","sukka/unicorn/prefer-boolean-return":"warn","sukka/unicorn/prefer-continue":"warn","sukka/unicorn/prefer-flat-math-min-max":"warn","sukka/unicorn/prefer-hoisting-branch-code":"warn","sukka/unicorn/prefer-single-replace":"warn"}},stylistic_unicorn:{name:"@eslint-sukka/eslint-plugin-sukka-full stylistic unicorn preset",plugins:{get sukka(){return Dl}},rules:{"sukka/unicorn/no-nested-ternary":"warn","sukka/unicorn/filename-case":["error",{cases:{kebabCase:!0,snakeCase:!0},ignore:[/fixtures/i,/^_/,/^\./,/rc$/i,/\.(md|json|yaml|toml|yml|ini|conf|jsonc|json5)$/i]}],"sukka/unicorn/no-unnecessary-nested-ternary":"error","sukka/unicorn/no-unreadable-object-destructuring":"error","sukka/unicorn/consistent-compound-words":"warn","sukka/unicorn/default-export-style":"warn"}},recommended_extra_with_typed_lint:{...u.eslint_plugin_sukka.configs.recommended_extra_with_typed_lint,plugins:{get sukka(){return Dl}},rules:{...u.eslint_plugin_sukka.configs.recommended_extra_with_typed_lint.rules,"sukka/string/no-unneeded-to-string":"error","sukka/type/no-force-cast-via-top-type":"error","sukka/type/no-wrapper-type-reference":"error","sukka/no-default-error":"off"}},recommended_react:{...u.eslint_plugin_sukka.configs.recommended_react,plugins:{get sukka(){return Dl}}}},rules:Object.assign(u.eslint_plugin_sukka.rules,{"array/no-unneeded-flat-map":A,"browser/prefer-location-assign":w,"jsx/no-template-literal":I,"jsx/no-unneeded-nested":j,"string/no-locale-case":B,"string/no-simple-template-literal":R,"unicode/no-bidi":q,"unicode/no-invisible":W,"no-redundant-variable":_,"no-single-return":z,"prefer-early-return":G,"prefer-fetch":J,"prefer-timer-id":H,"string/no-unneeded-to-string":Z,"type/no-force-cast-via-top-type":Q,"type/no-wrapper-type-reference":et,"no-default-error":er},Object.fromEntries(Object.entries({"unicorn/catch-error-name":pW,"unicorn/custom-error-definition":{create:e=>{e.on("ClassDeclaration",t=>ce(e,t)),e.on("AssignmentExpression",t=>{if("ClassExpression"===t.right.type)return ce(e,t.right)}),e.on("AssignmentExpression",e=>{if("MemberExpression"===e.left.type&&"Identifier"===e.left.object.type&&"exports"===e.left.object.name){let t=e.right;if("ClassExpression"!==t.type||!pZ(t)||!t.id)return;let r=t.id.name;return e.left.property.name!==r?{node:e.left.property,messageId:p_,fix:t=>t.replaceText(e.left.property,r)}:void 0}})},meta:{type:"problem",docs:{description:"Enforce correct `Error` subclassing.",recommended:!1},fixable:"code",messages:{[p_]:"Exported error name should match error class",[pV]:"Do not pass the error message to `super()` when the class defines a `message` accessor.",[pz]:"Do not assign to `this.message` when the class defines a `message` getter without a setter.",[pK]:"Error constructors should accept `options` as the second parameter.",[pG]:"Error constructors should use `options` as the second parameter.",[pJ]:"Pass the error message to `super()` as the first argument.",[pX]:"Pass `options` to `super()` as the second argument."},languages:["js/js"]}},"unicorn/no-nested-ternary":{create:e=>{e.on("ConditionalExpression",t=>{if([t.test,t.consequent,t.alternate].some(e=>"ConditionalExpression"===e.type))return;let{sourceCode:r}=e,n=r.getAncestors(t).toReversed(),o=n.findIndex(e=>"ConditionalExpression"!==e.type);return 1!==o||eQ(t,e)?o>1?{node:o>2?n[o-3]:t,messageId:oi}:void 0:{node:t,messageId:os,fix:e=>[e.insertTextBefore(t,"("),e.insertTextAfter(t,")")]}})},meta:{type:"suggestion",docs:{description:"Disallow nested ternary expressions.",recommended:!0},fixable:"code",messages:{[oi]:"Do not nest ternary expressions.",[os]:"Nested ternary expression should be parenthesized."},languages:["js/js"]}},"unicorn/prefer-event-target":{create:e=>{e.on("Identifier",t=>{if("EventEmitter"!==t.name||("ClassDeclaration"!==t.parent.type&&"ClassExpression"!==t.parent.type||t.parent.superClass!==t)&&("NewExpression"!==t.parent.type||t.parent.callee!==t))return;let r=e.sourceCode.getScope(t);if(!function(e){if(!e)return!1;let t=function(e,t){let r=e=>e.type===t;for(;e.parent;e=e.parent)if(r(e))return e}(e,"ImportDeclaration");return!!(ou.has(t?.source.value)||"Property"===e.parent.type&&e.parent.value===e&&"Identifier"===e.parent.key.type&&"EventEmitter"===e.parent.key.name&&"ObjectPattern"===e.parent.parent.type&&e.parent.parent.properties.includes(e.parent)&&op(e.parent.parent)&&oc(e.parent.parent.parent.init))||!!(op(e)&&tc(e.parent.init,{property:"EventEmitter",optional:!1,computed:!1})&&oc(e.parent.init.object))}(ei(r,t)?.defs[0]?.name))return{node:t,messageId:ol}})},meta:{type:"suggestion",docs:{description:"Prefer `EventTarget` over `EventEmitter`.",recommended:"unopinionated"},messages:{[ol]:"Prefer `EventTarget` over `EventEmitter`."},languages:["js/js"]}},"unicorn/prefer-keyboard-event-key":{create:e=>{e.on("Identifier",t=>{if(og.has(t.name)){for(let r of oE(e,t))if(r.references?.some(e=>ob(t,e.identifier)))return oD(t,r)}}),e.on("Property",t=>{let r;if("Identifier"===t.key.type&&og.has(t.key.name)&&"Property"===(r=t.key).parent.type&&r.parent.key===r&&"ObjectPattern"===r.parent.parent.type&&!r.parent.computed){for(let r of oE(e,t))if(ov(t.key,r))return oD(t.key,r);for(let r of oE(e,t))if(oS(t.key,r))return oD(t.key,r)}})},meta:{type:"suggestion",docs:{description:"Prefer `KeyboardEvent#key` over deprecated keyboard event properties.",recommended:"unopinionated"},fixable:"code",hasSuggestions:!0,messages:{[om]:"Use `.key` instead of `.{{name}}`.",[of]:"Use `.key` with `{{key}}`."},languages:["js/js"]}},"unicorn/prefer-text-content":{create:e=>{e.on("MemberExpression",t=>{if(!tc(t,{property:"innerText"})||r1(t.object,e))return;let r=t.property;return{node:r,messageId:oC,suggest:[{messageId:oA,fix:e=>e.replaceText(r,"textContent")}]}}),e.on("Identifier",t=>{if("innerText"===t.name&&"Property"===t.parent.type&&t.parent.key===t&&!t.parent.computed&&"init"===t.parent.kind&&"ObjectPattern"===t.parent.parent.type&&t.parent.parent.properties.includes(t.parent)&&!((e,t)=>{if(r1(e,t))return!0;let{parent:r}=e;return"VariableDeclarator"===r.type?r.id===e&&r.init&&r1(r.init,t):"AssignmentExpression"===r.type&&r.left===e&&r1(r.right,t)})(t.parent.parent,e))return{node:t,messageId:oC,suggest:[{messageId:oA,fix:e=>e.replaceText(t,t.parent.shorthand?"textContent: innerText":"textContent")}]}})},meta:{type:"suggestion",docs:{description:"Prefer `.textContent` over `.innerText`.",recommended:"unopinionated"},hasSuggestions:!0,messages:{[oC]:"Prefer `.textContent` over `.innerText`.",[oA]:"Switch to `.textContent`."},languages:["js/js"]}},"unicorn/require-array-join-separator":{create:e=>{e.on("CallExpression",t=>{if(!(td(t,{method:"join",argumentsLength:0,optionalCall:!1})||td(t,{method:"call",argumentsLength:1,optionalCall:!1,optionalMember:!1})&&tb(t.callee.object,{property:"join"}))||0===t.arguments.length&&rX(t.callee.object,e))return;let{sourceCode:r}=e,[n,o]=r.getLastTokens(t,2),a=1===t.arguments.length;return{loc:{start:r.getLoc(n)[a?"end":"start"],end:r.getLoc(o).end},messageId:oz,fix:r=>ow(r,t,"','",e)}})},meta:{type:"suggestion",docs:{description:"Enforce using the separator argument with `Array#join()`.",recommended:"unopinionated"},fixable:"code",messages:{[oz]:"Missing the separator argument."},languages:["js/js"]}},"unicorn/no-thenable":{create:e=>{for(let{selector:t,selectors:r,messageId:n,getNodes:o}of oH)e.on(t??r,function*(t){for(let r of o(t,e))yield{node:r,messageId:n}})},meta:{type:"problem",docs:{description:"Disallow `then` property.",recommended:"unopinionated"},messages:{[oK]:"Do not add `then` to an object.",[oG]:"Do not export `then`.",[oJ]:"Do not add `then` to a class."},languages:["js/js"]}},"unicorn/no-invalid-remove-event-listener":{create:e=>{e.on("CallExpression",t=>{if(!(td(t,{method:"removeEventListener",minimumArguments:2,optionalCall:!1})&&"SpreadElement"!==t.arguments[0].type&&("FunctionExpression"===t.arguments[1].type||"ArrowFunctionExpression"===t.arguments[1].type||td(t.arguments[1],{method:"bind",optionalCall:!1,optionalMember:!1}))))return;let[,r]=t.arguments;return["ArrowFunctionExpression","FunctionExpression"].includes(r.type)?{node:r,loc:eh(r,e.sourceCode),messageId:oZ}:{node:r.callee.property,messageId:oZ}})},meta:{type:"problem",docs:{description:"Prevent calling `EventTarget#removeEventListener()` with the result of an expression.",recommended:"unopinionated"},messages:{[oZ]:"The listener argument should be a function reference."},languages:["js/js"]}},"unicorn/consistent-function-scoping":o9,"unicorn/no-new-buffer":{create:e=>{let{sourceCode:t}=e;e.on("NewExpression",r=>{if(!te(r,{name:"Buffer"}))return;let n=((e,t)=>{if(1!==e.length)return"from";let[r]=e;if("SpreadElement"===r.type)return;if("ArrayExpression"===r.type||"TemplateLiteral"===r.type)return"from";if(nr(r,t))return"alloc";let n=ew(r,t);if(n){let{value:e}=n;if("string"==typeof e||Array.isArray(e))return"from"}})(r.arguments,t.getScope(r));return n?{node:r,messageId:o5,data:{method:n},fix:ae(r,e,n)}:{node:r,messageId:o4,suggest:["from","alloc"].map(t=>({messageId:o7,data:{replacement:t},fix:ae(r,e,t)}))}})},meta:{type:"problem",docs:{description:"Enforce the use of `Buffer.from()` and `Buffer.alloc()` instead of the deprecated `new Buffer()`.",recommended:"unopinionated"},fixable:"code",hasSuggestions:!0,messages:{[o5]:"`new Buffer()` is deprecated, use `Buffer.{{method}}()` instead.",[o4]:"`new Buffer()` is deprecated, use `Buffer.alloc()` or `Buffer.from()` instead.",[o7]:"Switch to `Buffer.{{replacement}}()`."},languages:["js/js"]}},"unicorn/no-console-spaces":{create:e=>{let{sourceCode:t}=e,r=(r,n,o)=>{let[a,i]=t.getRange(r),s="leading"===o?a+1:i-2,l=[s,s+1];return{loc:n7(l,e),messageId:at,data:{method:n,position:o},fix:e=>e.removeRange(l)}};e.on("CallExpression",function*(e){if(!td(e,{object:"console",methods:["log","debug","info","warn","error"],minimumArguments:1,optionalCall:!1,optionalMember:!1}))return;let n=e.callee.property.name,{arguments:o}=e,{length:a}=o;for(let[e,i]of o.entries()){if(!e1(i)&&"TemplateLiteral"!==i.type)continue;let o=t.getText(i).slice(1,-1);0!==e&&ar(o)&&(yield r(i,n,"leading")),e!==a-1&&an(o)&&(yield r(i,n,"trailing"))}})},meta:{type:"suggestion",docs:{description:"Do not use leading/trailing space between `console.log` parameters.",recommended:"unopinionated"},fixable:"code",messages:{[at]:"Do not use {{position}} space between `console.{{method}}` parameters."},languages:["js/js"]}},"unicorn/no-empty-file":aa,"unicorn/no-useless-fallback-in-spread":{create:e=>{e.on("ObjectExpression",t=>{if(ta(t)&&"LogicalExpression"===t.parent.type&&t.parent.right===t&&("||"===t.parent.operator||"??"===t.parent.operator)&&"SpreadElement"===t.parent.parent.type&&t.parent.parent.argument===t.parent&&"ObjectExpression"===t.parent.parent.parent.type&&t.parent.parent.parent.properties.includes(t.parent.parent))return{node:t,messageId:ai,*fix(r,{abort:n}){let{sourceCode:o}=e,a=t.parent;if(o.getCommentsInside(a).length>0)return n();let{left:i}=a,s=eQ(i,e),[,l]=s?eH(i,e):o.getRange(i),[,u]=o.getRange(a);yield r.removeRange([l,u]),(s||"SequenceExpression"!==i.type)&&(yield oT(a,r,e))}}})},meta:{type:"suggestion",docs:{description:"Disallow useless fallback when spreading in object literals.",recommended:"unopinionated"},fixable:"code",messages:{[ai]:"The empty object is useless."},languages:["js/js"]}},"unicorn/no-useless-length-check":{create:e=>{let t=[],r=new Set,n=new Set,o=new Set,a=new Set;e.on("BinaryExpression",e=>{if(!("BinaryExpression"===e.type&&"Literal"===e.right.type&&"0"===e.right.raw&&tc(e.left,{property:"length",optional:!1})&&tE(e.parent)))return;let{operator:t}=e;"==="===t?r.add(e):(">"===t||"!=="===t)&&n.add(e)}),e.on("CallExpression",t=>{td(t,{optionalCall:!1,optionalMember:!1,computed:!1})&&"Identifier"===t.callee.property.type&&!rG(t.callee.object,e)&&("some"===t.callee.property.name?o.add(t):"every"===t.callee.property.name&&a.add(t))}),e.on("LogicalExpression",e=>{tE(e)&&t.push(e)}),e.on("Program:exit",function*(){let i=new Set(t.flatMap(e=>(function(e){let{operator:t}=e;return(function e(t){return[t.left,t.right].flatMap(r=>"LogicalExpression"===r.type&&r.operator===t.operator?e(r):[r])})(e).filter((e,i,s)=>(function({node:e,operator:t,siblings:i}){return"||"===t&&r.has(e)&&i.some(t=>a.has(t)&&tQ(e.left.object,t.callee.object))||"&&"===t&&n.has(e)&&i.some(t=>o.has(t)&&tQ(e.left.object,t.callee.object))})({node:e,operator:t,siblings:[s[i-1],s[i+1]].filter(Boolean)}))})(e))),{sourceCode:s}=e;for(let t of i)yield{loc:{start:s.getLoc(t.left.property).start,end:s.getLoc(t).end},messageId:r.has(t)?"zero":"non-zero",fix(r){let{left:n,right:o}=t.parent,a=eH(n,e),i=eH(o,e),s=[];return n===t?(s[0]=a[0],s[1]=i[0]):(s[0]=a[1],s[1]=i[1]),r.removeRange(s)}}})},meta:{type:"suggestion",docs:{description:"Disallow useless array length check.",recommended:"unopinionated"},fixable:"code",messages:{"non-zero":"The non-empty check is useless as `Array#some()` returns `false` for an empty array.",zero:"The empty check is useless as `Array#every()` returns `true` for an empty array."},languages:["js/js"]}},"unicorn/no-useless-promise-resolve-reject":{create:e=>{e.on("CallExpression",t=>{if(!(td(t,{object:"Promise",methods:["resolve","reject"],optionalCall:!1,optionalMember:!1})&&("ArrowFunctionExpression"===t.parent.type&&t.parent.body===t||"ReturnStatement"===t.parent.type&&t.parent.argument===t||"YieldExpression"===t.parent.type&&!t.parent.delegate&&t.parent.argument===t)))return;let{functionNode:r,isInTryStatement:n}=function(e){let t,r=!1;for(;e;e=e.parent){if(tl(e)){t=e;break}"TryStatement"===e.type&&(r=!0)}return{functionNode:t,isInTryStatement:r}}(t);if(r&&(r.async||function(e){if("CallExpression"===e.parent.type&&"MemberExpression"===e.parent.callee.type&&!e.parent.callee.computed&&"Identifier"===e.parent.callee.property.type){let{callee:{property:t},arguments:r}=e.parent;if(1===r.length&&["then","catch","finally"].includes(t.name)&&r[0]===e||2===r.length&&"then"===t.name&&(r[0]===e||"SpreadElement"!==r[0].type&&r[1]===e))return!0}return!1}(r)))return function(e,t){let{callee:r,parent:n}=e,o=r.property.name;return{node:r,messageId:o,data:{type:"YieldExpression"===n.type?"yield":"return"},fix:t}}(t,function(e,t,r){if(e.arguments.length>1)return;let{callee:n,parent:o,arguments:a}=e,[i]=a;if(i?.type==="SpreadElement")return;let s="reject"===n.property.name,l="YieldExpression"===o.type;if(!s||!t&&(!l||"ExpressionStatement"===o.parent.type))return function(t){let n="ArrowFunctionExpression"===o.type,a=i?r.sourceCode.getText(i):"";if(i?.type==="SequenceExpression"&&(a=`(${a})`),s){if(a||="undefined",a=`throw ${a}`,l)return t.replaceTextRange(eH(o,r),a);if(a+=";",n)return a=`{ ${a} }`,t.replaceTextRange(eH(e,r),a)}else l?a=`yield${a?" ":""}${a}`:"ReturnStatement"===o.type?a=`return${a?" ":""}${a};`:(i?.type==="ObjectExpression"&&(a=`(${a})`),a||="{}");return t.replaceText(n?e:o,a)}}(t,n,e))})},meta:{type:"suggestion",docs:{description:"Disallow returning/yielding `Promise.resolve/reject()` in async functions or promise callbacks",recommended:"unopinionated"},fixable:"code",messages:{resolve:"Prefer `{{type}} value` over `{{type}} Promise.resolve(value)`.",reject:"Prefer `throw error` over `{{type}} Promise.reject(error)`."},languages:["js/js"]}},"unicorn/no-zero-fractions":{create:e=>{e.on("Literal",t=>{if(!e8(t))return;let{raw:r}=t,n=r.match(/^(?<before>[\d_]*)(?<dotAndFractions>\.[\d_]*)(?<after>.*)$/);if(!n)return;let{before:o,dotAndFractions:a,after:i}=n.groups,s=(o+a.replaceAll(/[.0_]+$/g,"")||"0")+i;if(s===r)return;let l="."===a,{sourceCode:u}=e,p=u.getRange(t)[0]+o.length+a.length;return{loc:n7([p-(r.length-s.length),p],e),messageId:l?al:as,*fix(r){let n=s;"MemberExpression"===t.parent.type&&t.parent.object===t&&n0.test(s)&&!eQ(t,e)&&(n=`(${n})`,nW(u.getTokenBefore(t),e,n)&&(n=`;${n}`)),yield r.replaceText(t,n),yield oP(r,t,e)}}})},meta:{type:"suggestion",docs:{description:"Disallow number literals with zero fractions or dangling dots.",recommended:"unopinionated"},fixable:"code",messages:{[as]:"Don't use a zero fraction in the number.",[al]:"Don't use a dangling dot in the number."},languages:["js/js"]}},"unicorn/prefer-export-from":ah,"unicorn/prefer-native-coercion-functions":{create:e=>{e.on(ts,t=>{if(t.async||t.generator||t.returnType?.type==="TSTypeAnnotation"&&"TSTypePredicate"===t.returnType.typeAnnotation.type||0===t.params.length||"Identifier"!==t.params[0].type||("MethodDefinition"===t.parent.type&&("constructor"===t.parent.kind||"set"===t.parent.kind)||"Property"===t.parent.type&&"set"===t.parent.kind)&&t.parent.value===t)return;let r=function(e){if(("ArrowFunctionExpression"===e.type&&"Identifier"===e.body.type&&e.body.name===e.params[0].name||"BlockStatement"===e.body.type&&1===e.body.body.length&&"ReturnStatement"===e.body.body[0].type&&e.body.body[0].argument?.type==="Identifier"&&e.body.body[0].argument.name===e.params[0].name)&&"CallExpression"===e.parent.type&&!e.parent.optional&&e.parent.arguments[0]===e&&"MemberExpression"===e.parent.callee.type&&!e.parent.callee.computed&&!e.parent.callee.optional&&"Identifier"===e.parent.callee.property.type&&aE.has(e.parent.callee.property.name))return{replacementFunction:"Boolean",fix:t=>t.replaceText(e,"Boolean")}}(t)||function(e){let t,r=(t=e.params[0].name,"ArrowFunctionExpression"===e.type&&aD(e.body,t)?e.body:"BlockStatement"===e.body.type&&1===e.body.body.length&&"ReturnStatement"===e.body.body[0].type&&aD(e.body.body[0].argument,t)?e.body.body[0].argument:void 0);if(!r)return;let{name:n}=r.callee,o={replacementFunction:n};return"FunctionDeclaration"===e.type||1!==r.arguments.length||(o.fix=t=>{let r=n;return"Property"===e.parent.type&&e.parent.method&&e.parent.value===e?r=`: ${r}`:"MethodDefinition"===e.parent.type&&(r=` = ${r};`),t.replaceText(e,r)}),o}(t);if(!r)return;let{sourceCode:n}=e,{replacementFunction:o,fix:a}=r;return r={node:t,loc:eh(t,n),messageId:ax,data:{functionNameWithKind:ej(t,n),replacementFunction:o}},!a||1!==t.params.length||n.getCommentsInside(t).length>0||(r.fix=a),r})},meta:{type:"suggestion",docs:{description:"Prefer using `String`, `Number`, `BigInt`, `Boolean`, and `Symbol` directly.",recommended:"unopinionated"},fixable:"code",messages:{[ax]:"{{functionNameWithKind}} is equivalent to `{{replacementFunction}}`. Use `{{replacementFunction}}` directly."},languages:["js/js"]}},"unicorn/no-document-cookie":{create(e){aT.listen({context:e})},meta:{type:"problem",docs:{description:"Do not use `document.cookie` directly.",recommended:"unopinionated"},messages:{[aA]:"Do not use `document.cookie` directly."},languages:["js/js"]}},"unicorn/prefer-add-event-listener":aj,"unicorn/prefer-array-index-of":aN,"unicorn/prefer-blob-reading-methods":{create:e=>{e.on("CallExpression",e=>{if(!td(e,{methods:["readAsText","readAsArrayBuffer"],argumentsLength:1,optionalCall:!1,optionalMember:!1}))return;let t=e.callee.property,r=t.name;return{node:t,messageId:aM,data:{method:r,replacement:"readAsArrayBuffer"===r?"arrayBuffer":"text"}}})},meta:{type:"suggestion",docs:{description:"Prefer `Blob#arrayBuffer()` over `FileReader#readAsArrayBuffer(…)` and `Blob#text()` over `FileReader#readAsText(…)`.",recommended:"unopinionated"},messages:{[aM]:"Prefer `Blob#{{replacement}}()` over `FileReader#{{method}}(blob)`."},languages:["js/js"]}},"unicorn/prefer-date-now":{create:e=>{e.on("CallExpression",e=>{if(td(e,{methods:["getTime","valueOf"],argumentsLength:0,optionalCall:!1,optionalMember:!1})&&aW(e.callee.object)){let t=e.callee.property;return a_(e,{node:t,messageId:aq,data:{method:t.name}})}if(e7(e,{names:["Number","BigInt"],argumentsLength:1,optional:!1})&&aW(e.arguments[0])){let{name:t}=e.callee;return"Number"===t?a_(e,{messageId:aU}):a_(e.arguments[0])}}),e.on("UnaryExpression",t=>{if(("+"===t.operator||"-"===t.operator)&&aW(t.argument))return a_("-"===t.operator?t.argument:t,{},e)}),e.on("AssignmentExpression",e=>{if(("-="===e.operator||"*="===e.operator||"/="===e.operator||"%="===e.operator||"**="===e.operator)&&aW(e.right))return a_(e.right)}),e.on("BinaryExpression",function*(e){if("-"===e.operator||"*"===e.operator||"/"===e.operator||"%"===e.operator||"**"===e.operator)for(let t of[e.left,e.right])aW(t)&&(yield a_(t))})},meta:{type:"suggestion",docs:{description:"Prefer `Date.now()` to get the number of milliseconds since the Unix Epoch.",recommended:"unopinionated"},fixable:"code",messages:{[aO]:"Prefer `Date.now()` over `new Date()`.",[aq]:"Prefer `Date.now()` over `Date#{{method}}()`.",[aU]:"Prefer `Date.now()` over `Number(new Date())`."},languages:["js/js"]}},"unicorn/dom-node-dataset":a0,"unicorn/prefer-modern-math-apis":{create:e=>{let t=[];e.on("CallExpression",t=>{if(!td(t,{object:"Math",method:"sqrt",argumentsLength:1,optionalCall:!1,optionalMember:!1}))return;let r=a5(t.arguments[0]);if(r.some(e=>!("BinaryExpression"===e.type&&("*"===e.operator&&tQ(e.left,e.right)||"**"===e.operator&&e0(e.right,2)))))return;let n=1===r.length?"abs":"hypot",o=new Set(1===r.length?[]:r.map(e=>e.parent));return{node:t.callee.property,messageId:a1,data:{replacement:`Math.${n}(…)`,description:"Math.sqrt(…)"},*fix(a){let{sourceCode:i}=e;for(let r of(yield a.replaceText(t.callee.property,n),o)){let t=i.getTokenAfter(r.left,e=>"Punctuator"===e.type&&"+"===e.value);yield oV(t,",",a,e),yield oT(r,a,e)}for(let t of r)yield a.removeRange([eH(t.left,e)[1],i.getRange(t)[1]])}}}),e.on("BinaryExpression",e=>{t.push(e)}),e.on("Program:exit",function*(){for(let r of t)for(let t of a9){let n=t(r,e);n&&(yield n)}})},meta:{type:"suggestion",docs:{description:"Prefer modern `Math` APIs over legacy patterns.",recommended:"unopinionated"},fixable:"code",messages:{[a1]:"Prefer `{{replacement}}` over `{{description}}`."},languages:["js/js"]}},"unicorn/number-literal-case":ie,"unicorn/prefer-number-properties":is,"unicorn/prefer-reflect-apply":{create:e=>{e.on("CallExpression",t=>{if(!td(t,{optionalCall:!1,optionalMember:!1})||"Literal"===t.callee.object.type||"ArrayExpression"===t.callee.object.type||"ObjectExpression"===t.callee.object.type)return;let{sourceCode:r}=e,n=((e,t)=>{if("apply"===eI(e.callee)&&2===e.arguments.length&&iu(e.arguments[0],e.arguments[1]))return r=>r.replaceText(e,ip(t,e.callee.object,e.arguments[0],e.arguments[1]))})(t,r)||((e,t)=>{if("call"===eI(e.callee)&&"apply"===eI(e.callee.object)&&"prototype"===eI(e.callee.object.object)&&e.callee.object.object.object?.type==="Identifier"&&"Function"===e.callee.object.object.object.name&&3===e.arguments.length&&iu(e.arguments[1],e.arguments[2]))return r=>r.replaceText(e,ip(t,e.arguments[0],e.arguments[1],e.arguments[2]))})(t,r);if(n)return{node:t,messageId:il,fix:n}})},meta:{type:"suggestion",docs:{description:"Prefer `Reflect.apply()` over `Function#apply()`.",recommended:"unopinionated"},fixable:"code",messages:{[il]:"Prefer `Reflect.apply()` over `Function#apply()`."},languages:["js/js"]}},"unicorn/prefer-set-size":{create:e=>{e.on("MemberExpression",t=>{var r;if(!tc(t,{property:"length",optional:!1}))return;let n="ArrayExpression"===(r=t.object).type&&1===r.elements.length&&r.elements[0]?.type==="SpreadElement"?r.elements[0].argument:td(r,{object:"Array",method:"from",argumentsLength:1,optionalCall:!1,optionalMember:!1})?r.arguments[0]:void 0;if(n&&rY(n,e))return{node:t.property,messageId:ic,fix:function(e,t,r){let{sourceCode:n}=e,{object:o,property:a}=t;if(!(n.getCommentsInside(o).length>n.getCommentsInside(r).length))return function*(i){yield i.replaceText(a,"size");let s=n.getText(r);n2(r,e)&&(s=`(${s})`),yield i.replaceText(o,s),"ArrayExpression"===o.type&&(yield oP(i,t,e))}}(e,t,n)}})},meta:{type:"suggestion",docs:{description:"Prefer using `Set#size` instead of `Array#length`.",recommended:"unopinionated"},fixable:"code",messages:{[ic]:"Prefer using `Set#size` instead of `Array#length`."},languages:["js/js"]}},"unicorn/prefer-string-replace-all":{create:e=>{e.on("CallExpression",t=>{let r,n,o=((e,t)=>{let r;if(!td(e,{method:"join",argumentsLength:1,optionalCall:!1,optionalMember:!1})||!td(e.callee.object,{method:"split",argumentsLength:1,optionalCall:!1,optionalMember:!1})||t.sourceCode.getCommentsInside(e).length>0)return;let n=e.callee.object;if(nv(n.callee.object,t))return;let[o]=n.arguments,[a]=e.arguments,i=e3(o);if("string"==typeof i){if(0===i.length)return;r=tF(i)}else if(!(r=(e=>{if(!e6(e)||e.regex.flags.includes("y"))return;let t=iw(e);if(!t||ij(t)||0===iI(t))return;let{pattern:r,flags:n}=e.regex;return`/${r}/${n.includes("g")?n:`g${n}`}`})(o)))return;let s=e3(a);if("string"==typeof s)return`${eZ(n.callee.object,t)}.replaceAll(${r}, ${tF(s.replaceAll("$","$$$$"))})`})(t,e);if(o)return{node:t.callee.property,messageId:iE,fix:e=>e.replaceText(t,o)};if(!td(t,{methods:["replace","replaceAll"],argumentsLength:2,optionalCall:!1})||td(t,{method:"replace",argumentsLength:2,optionalCall:!1,optionalMember:!1})&&e6(r=t.arguments[0])&&r.regex.flags.includes("g")&&!r.regex.flags.includes("y")&&(e=>{if(!e.startsWith("[")||!e.endsWith("]")||e.startsWith("[^"))return;let t=new Set,r=e.slice(1,-1);for(let e=0;e<r.length;e++){let n=r[e],o=!1;if("\\"===n&&(n=r[++e],o=!0,!n)||"-"===n&&!o&&0!==e&&e!==r.length-1||"]"===n&&!o&&0!==e||!iy.has(n))return;t.add(n)}return t})(r.regex.pattern)?.size>=8&&e1(n=t.arguments[1])&&n.value===ig)return;let{arguments:a,callee:{property:i}}=t;if(nv(t.callee.object,e))return;let[s]=a;if(!((e,t)=>{if(e6(e))return e.regex.flags.includes("g");if(te(e,{name:"RegExp"})&&e.arguments[0]?.type!=="SpreadElement"&&e.arguments[1]?.type==="Literal"&&"string"==typeof e.arguments[1].value)return e.arguments[1].value.includes("g");let r=ew(e,t);if(!r)return!1;let{value:n}=r;return"[object RegExp]"===Object.prototype.toString.call(n)&&n.global})(s,e.sourceCode.getScope(s)))return;let l=i.name,u=function(e){if(!e6(e))return;let t=iw(e);if(!t)return;let{flags:r}=e.regex;if(!function(e){if(!e.includes("g"))return!1;for(let t of e)if(iD.has(t))return!1;return!0}(r))return;let n="alternative"===t.type?iT(t.body):iA(t);if(n)return"'"+n+"'"}(s);if("replaceAll"===l){if(!u)return;return{node:s,messageId:ib,data:{replacement:u.length<20?u:"a string literal"},fix:e=>e.replaceText(s,u)}}return{node:i,messageId:ix,*fix(e){yield e.insertTextAfter(i,"All"),u&&(yield e.replaceText(s,u))}}})},meta:{type:"suggestion",docs:{description:"Prefer `String#replaceAll()` over regex searches with the global flag and `String#split().join()`.",recommended:"unopinionated"},fixable:"code",messages:{[ix]:"Prefer `String#replaceAll()` over `String#replace()`.",[ib]:"This pattern can be replaced with {{replacement}}.",[iE]:"Prefer `String#replaceAll()` over `String#split().join()`."},languages:["js/js"]}},"unicorn/prefer-string-slice":{create:e=>{e.on("CallExpression",t=>{if(!td(t,{methods:["substr","substring"]})||nv(t.callee.object,e))return;let r=t.callee.property.name;if(!("substring"===r&&(e=>{if(!td(e,{method:"substring",argumentsLength:2}))return;let[t,r]=e.arguments;if(iF(t)&&iF(r)&&1===Math.abs(t.value-r.value))return t.value<r.value?t:r;let n=(e=>{if("BinaryExpression"===e.type&&"-"===e.operator&&e0(e.right,1))return e.left})(t);return iB(r,t)??(iB(t,r)?r:void 0)??(n&&tQ(n,r)?t:void 0)})(t)))return{node:t,messageId:r,*fix(n,{abort:o}){if(yield n.replaceText(t.callee.property,"slice"),0!==t.arguments.length){if(t.arguments.length>2||t.arguments.some(e=>"SpreadElement"===e.type))return o();yield("substr"===r?function*({node:e,fixer:t,context:r,abort:n}){let o=e.arguments,[a,i]=o;if(!i)return;let{sourceCode:s}=r,l=ew(a,s.getScope(e)),u=eH(i,r);if(l?.value===0){let n=((e,t,r)=>{let n,o,{sourceCode:a}=r;if(!("BinaryExpression"!==e.type||"-"!==e.operator||!(e8(n=e.right)&&Number.isSafeInteger(n.value)&&n.value>0)||!i$(e.left)||!("Identifier"===t.type||e1(t))||!tQ(e.left.object,t)||(o=((e,t)=>{let[r,n]=eH(e,t),o=t.sourceCode.getTokenByRangeStart(r),a=t.sourceCode.getTokenBefore(o);return[t.sourceCode.getRange(a)[1],n]})(e,r),a.getAllComments().some(e=>{let t=a.getRange(e);return t[0]>=o[0]&&t[1]<=o[1]}))))return`-${e.right.raw}`})(i,e.callee.object,r);if(n)return void(yield oI(t,i,n,r));if(e8(i)||i$(i))return;let o=iR(i);return"number"==typeof o?void(yield oI(t,i,String(Math.max(0,o)),r)):(yield t.insertTextBeforeRange(u,"Math.max(0, "),void(yield t.insertTextAfterRange(u,")")))}if(o.every(e=>e8(e))){let e;return void(yield(e=String(a.value+i.value),oI(t,i,e,r)))}return n()}:function*({node:e,fixer:t,context:r,abort:n}){let[o,a]=e.arguments,i=o?iR(o):void 0;if(!a){if(i$(o))return;if(void 0!==i)return void(yield oI(t,o,String(Math.max(0,i)),r));let e=eH(o,r);return yield t.insertTextBeforeRange(e,"Math.max(0, "),void(yield t.insertTextAfterRange(e,")"))}let s=iR(a);if(void 0!==i&&void 0!==s){let e=[Math.max(0,i),Math.max(0,s)];i>s&&e.reverse(),e[0]!==i&&(yield oI(t,o,String(e[0]),r)),e[1]!==s&&(yield oI(t,a,String(e[1]),r));return}if(0===i||0===s){let e=eZ(o,r),n=eZ(a,r);yield oI(t,o,"0",r),yield oI(t,a,`Math.max(0, ${0===i?n:e})`,r);return}return n()})({node:t,fixer:n,context:e,abort:o})}}}})},meta:{type:"suggestion",docs:{description:"Prefer `String#slice()` over `String#substr()` and `String#substring()`.",recommended:"unopinionated"},fixable:"code",messages:{substr:"Prefer `String#slice()` over `String#substr()`.",substring:"Prefer `String#slice()` over `String#substring()`."},languages:["js/js"]}},"unicorn/prefer-string-trim-start-end":{create:e=>{e.on("CallExpression",t=>{if(!td(t,{methods:["trimLeft","trimRight"],argumentsLength:0,optionalCall:!1})||nv(t.callee.object,e))return;let r=t.callee.property,n=r.name,o="trimLeft"===n?"trimStart":"trimEnd";return{node:r,messageId:iP,data:{method:n,replacement:o},fix:e=>e.replaceText(r,o)}})},meta:{type:"suggestion",docs:{description:"Prefer `String#trimStart()` / `String#trimEnd()` over `String#trimLeft()` / `String#trimRight()`.",recommended:"unopinionated"},fixable:"code",messages:{[iP]:"Prefer `String#{{replacement}}()` over `String#{{method}}()`."},languages:["js/js"]}},"unicorn/no-unreadable-iife":{create:e=>{e.on("CallExpression",t=>{if("ArrowFunctionExpression"!==t.callee.type||"BlockStatement"===t.callee.body.type||!eQ(t.callee.body,e))return;let{body:r}=t.callee,n={node:t,loc:n7(eH(r,e),e),messageId:iL};return!function(e,t){let{sourceCode:r}=t,[n,o]=eH(e,t),[a,i]=r.getRange(e);return r.getCommentsInside(e.parent).some(e=>{let[t,s]=r.getRange(e);return t>=n&&s<=o&&(t<a||s>i)})}(r,e)&&(n.suggest=[{messageId:iN,fix:t=>t.replaceTextRange(eH(r,e),`{ return ${e.sourceCode.getText(r)}; }`)}]),n})},meta:{type:"suggestion",docs:{description:"Disallow unreadable IIFEs.",recommended:"unopinionated"},hasSuggestions:!0,messages:{[iL]:"IIFE with parenthesized arrow function body is considered unreadable.",[iN]:"Use a block statement body."},languages:["js/js"]}},"unicorn/throw-new-error":{create:e=>{e.on("CallExpression",t=>{if("Decorator"===t.parent.type)return;let{callee:r}=t;if(!(t.optional||rh(r))&&("Identifier"===r.type&&iO.test(r.name)||"MemberExpression"===r.type&&!r.computed&&"Identifier"===r.property.type&&iO.test(r.property.name))&&!tc(r,{object:"Data",property:"TaggedError",computed:!1}))return{node:t,messageId:iM,fix:r=>oL(t,e,r)}})},meta:{type:"suggestion",docs:{description:"Require `new` when creating an error.",recommended:"unopinionated"},fixable:"code",messages:{[iM]:"Use `new` when creating an error."},languages:["js/js"]}},"unicorn/escape-case":{create:e=>{let t="lowercase"===e.options[0];e.on("Literal",e=>{if(e1(e))return iV({node:e,original:e.raw,lowercase:t})}),e.on("Literal",e=>{if(e6(e))return iV({node:e,original:e.raw,regex:i_,lowercase:t})}),e.on("TemplateElement",r=>{if(!th(r.parent))return iV({node:r,original:r.value.raw,lowercase:t,fix:(t,n)=>o_(r,n,e,t)})})},meta:{type:"suggestion",docs:{description:"Require escape sequences to use uppercase or lowercase values.",recommended:"unopinionated"},fixable:"code",schema:[{enum:["uppercase","lowercase"],description:"The case style for escape sequences."}],defaultOptions:["uppercase"],messages:{[iq]:"Use uppercase characters for the value of the escape sequence.",[iU]:"Use lowercase characters for the value of the escape sequence."},languages:["js/js"]}},"unicorn/prefer-unicode-code-point-escapes":{create:e=>{e.on("Literal",e=>e1(e)?i6(e,e.raw):e6(e)?function(e){let t,{raw:r}=e,{pattern:n,flags:o}=(t=r.lastIndexOf("/"),{pattern:r.slice(1,t),flags:r.slice(t+1)}),{fixed:a,hasReplacement:i}=i8(n,{isRegex:!0,supportsNestedCharacterClasses:o.includes("v")}),s=o.includes("u")||o.includes("v"),l=function(e){for(let t=0;t<e.length;t++)if(void 0!==function(e,t){var r;if(!e.startsWith(iG,t))return;let n=t+iG.length;for(;r=e[n],iJ.test(r);)n++;if(n===t+iG.length||"}"!==e[n])return;let o=Number.parseInt(e.slice(t+iG.length,n),16);if(!(o>1114111))return o}(e,t)&&iZ(e,t))return!0;return!1}(n);if(!i&&(s||!l))return;let u=`/${i?a:n}/${i9(o)}`;return s?{node:e,messageId:iz,fix:t=>t.replaceText(e,u)}:!function(e,t){try{return new RegExp(e,t),!0}catch{return!1}}(i?a:n,i9(o))?{node:e,messageId:iz}:{node:e,messageId:iz,suggest:[{messageId:iK,fix:t=>t.replaceText(e,u)}]}}(e):void 0),e.on("TemplateElement",t=>{if(!th(t.parent))return i6(t,t.value.raw,(r,n)=>o_(t,n,e,r))})},meta:{type:"suggestion",docs:{description:"Prefer Unicode code point escapes over legacy escape sequences.",recommended:"unopinionated"},fixable:"code",hasSuggestions:!0,messages:{[iz]:"Prefer Unicode code point escapes.",[iK]:"Use Unicode code point escapes and add the `u` flag."},languages:["js/js"]}},"unicorn/prefer-prototype-methods":{create:function(e){let{sourceCode:t}=e,r=[];e.on("CallExpression",e=>{r.push(e)}),e.onExit("Program",function*(n){let o=new WeakMap;for(let{node:e,path:r}of new ez(t.getScope(n)).iterateGlobalReferences(Object.fromEntries(i5.map(e=>[e,{[ez.READ]:!0}]))))o.set(e,r);for(let t of r)yield function(e,{context:t,globalReferences:r}){let n;td(e,{object:"Reflect",method:"apply",minimumArguments:1,optionalCall:!1,optionalMember:!1})?n=e.arguments[0]:td(e,{methods:["apply","bind","call"],optionalCall:!1,optionalMember:!1})&&(n=e.callee.object);let{isGlobalReference:o,constructorName:a,methodName:i}=function(e,{context:t,globalReferences:r}){if(!e)return;if(r.has(e))return{isGlobalReference:!0,constructorName:"Object",methodName:r.get(e).at(-1)};if(!tc(e,{optional:!1}))return;let n=e.object;if(to(n)||ta(n))return{constructorName:"ArrayExpression"===n.type?"Array":"Object",methodName:eI(e,t.sourceCode.getScope(e))}}(n,{context:t,globalReferences:r})??{};if(a)return{node:n,messageId:i?"known-method":"unknown-method",data:{constructorName:a,methodName:i},*fix(r){if(o)return void(yield r.replaceText(n,`${a}.prototype.${i}`));if(tc(n)){let o=n.object;yield r.replaceText(o,`${a}.prototype`),("ArrayExpression"===o.type||"ObjectExpression"===o.type)&&(yield oP(r,e,t))}}}}(t,{context:e,globalReferences:o})})},meta:{type:"suggestion",docs:{description:"Prefer borrowing methods from the prototype instead of the instance.",recommended:"unopinionated"},fixable:"code",messages:{"known-method":"Prefer using `{{constructorName}}.prototype.{{methodName}}`.","unknown-method":"Prefer using method from `{{constructorName}}.prototype`."},languages:["js/js"]}},"unicorn/error-message":{create:e=>{e.on(["CallExpression","NewExpression"],t=>{if(!(tt(t,{names:i4,optional:!1})&&e.sourceCode.isGlobalReference(t.callee)))return;let r=t.callee.name,n=sr.has(r)?sr.get(r):0,o=t.arguments;if(o.some((e,t)=>t<=n&&"SpreadElement"===e.type))return;let a=o[n];if(!a)return{node:t,messageId:i7,data:{constructorName:r}};if("ArrayExpression"===a.type||"ObjectExpression"===a.type)return{node:a,messageId:st};let i=ew(a,e.sourceCode.getScope(a));if(!i)return;let{value:s}=i;return"string"!=typeof s?{node:a,messageId:st}:""===s?{node:a,messageId:se}:void 0})},meta:{type:"problem",docs:{description:"Enforce passing a `message` value when creating a built-in error.",recommended:"unopinionated"},messages:{[i7]:"Pass a message to the `{{constructorName}}` constructor.",[se]:"Error message should not be an empty string.",[st]:"Error message should be a string."},languages:["js/js"]}},"unicorn/no-instanceof-builtins":su,"unicorn/prefer-type-error":{create:e=>{e.on("ThrowStatement",e=>{let t;if(!(te(e.argument,{name:"Error"})&&e.parent&&e.parent.body&&1===e.parent.body.length&&e.parent.parent&&"IfStatement"===(t=e.parent.parent).type&&sh(t.test)))return;let r=e.argument.callee;return{node:r,messageId:sp,fix:e=>e.insertTextBefore(r,"Type")}})},meta:{type:"suggestion",docs:{description:"Enforce throwing `TypeError` in type checking conditions.",recommended:"unopinionated"},fixable:"code",messages:{[sp]:"`new Error()` is too unspecific for a type check. Use `new TypeError()` instead."},languages:["js/js"]}},"unicorn/consistent-destructuring":{create:e=>{let{sourceCode:t}=e,r=new Map,n=[],o=[],a=e=>{let r=ry(e.object);if(e.computed||"Identifier"!==e.property.type||!["Identifier","ThisExpression"].includes(r.type))return;let n=t.getScope(e);o.push({propertyName:e.property.name,rootIdentifierName:"Identifier"===r.type?r.name:void 0,rootVariable:"Identifier"===r.type?ei(n,r):void 0,thisScopeBoundary:"ThisExpression"===r.type?sD(r):void 0,start:t.getRange(e)[0],scope:n})},i=e=>{switch(e.type){case"MemberExpression":a(e);break;case"AssignmentPattern":i(e.left);break;case"RestElement":i(e.argument);break;case"ObjectPattern":for(let t of e.properties)i("Property"===t.type?t.value:t.argument);break;case"ArrayPattern":for(let t of e.elements)t&&i(t)}};e.on("AssignmentExpression",e=>{i(e.left)}),e.on(["ForInStatement","ForOfStatement"],e=>{"VariableDeclaration"!==e.left.type&&i(e.left)}),e.on("UpdateExpression",e=>{"MemberExpression"===e.argument.type&&a(e.argument)}),e.on("UnaryExpression",e=>{"delete"===e.operator&&"MemberExpression"===e.argument.type&&a(e.argument)}),e.on("VariableDeclarator",e=>{let n;if(!("ObjectPattern"===e.id.type&&"const"===e.parent.kind&&e.init&&("Identifier"===(n=e.init).type||"ThisExpression"===n.type)))return;let o="Identifier"===e.init.type?e.init:void 0,a={scope:t.getScope(e),object:e.init,rootIdentifierName:o?.name,rootVariable:o&&ei(t.getScope(e),o),thisScopeBoundary:"ThisExpression"===e.init.type?sD(e.init):void 0,objectPattern:e.id},i=t.getText(e.init);r.set(i,[...r.get(i)??[],a])});let s=e=>{let n;if(e.computed||tt(e.parent)&&e.parent.callee===e||"TaggedTemplateExpression"===e.parent.type&&e.parent.tag===e||r3(e))return;let a=ry(e.object),i=r.get(t.getText(a));if(!i)return;let s=t.getScope(e),l="Identifier"===a.type?a:void 0,u=l&&ei(s,l),p="ThisExpression"===a.type?sD(a):void 0,c=t.getText(e.property);for(let r of i.toReversed())if(sC({declaration:r,memberExpressionNode:e,memberScope:s,memberRootIdentifier:l,memberRootVariable:u,memberThisScopeBoundary:p,memberExpressionWrites:o,sourceCode:t})&&(n=sv(r.objectPattern.properties.filter(e=>sS(e)&&"Identifier"===e.value.type),c,s,t)))break;if(!n||((e,t)=>{let r=e,{parent:n}=e;for(;n&&!sw(n);){if(sT(n,r,e,t))return!0;r=n,n=n.parent}return!1})(e,t))return;if("MemberExpression"===e.parent.type)return{node:e,messageId:sx};let d=t.getText(e),m=n.value.name;return{node:e,messageId:sx,suggest:[{messageId:sb,data:{expression:d,property:m},fix:t=>t.replaceText(e,m)}]}};e.on("MemberExpression",e=>{n.push(e)}),e.onExit("Program",function*(){for(let e of n){let t=s(e);t&&(yield t)}})},meta:{type:"suggestion",docs:{description:"Use destructured variables over properties.",recommended:!1},hasSuggestions:!0,messages:{[sx]:"Use destructured variables over properties.",[sb]:"Replace `{{expression}}` with destructured property `{{property}}`."},languages:["js/js"]}},"unicorn/new-for-builtins":{create:e=>{sR.listen({context:e}),s$.listen({context:e}),sP.listen({context:e}),sL.listen({context:e})},meta:{type:"suggestion",docs:{description:"Enforce correct use of `new` for builtin constructors.",recommended:"unopinionated"},fixable:"code",hasSuggestions:!0,messages:{enforce:"Use `new {{name}}()` instead of `{{name}}()`.",disallow:"Use `{{name}}()` instead of `new {{name}}()`.",disallowCallOrNew:"`{{name}}` is not a function or constructor.",[sj]:"Use `String(new Date())` instead of `Date()`.",[sF]:"Switch to `String(new Date())`."},languages:["js/js"]}},"unicorn/prefer-single-call":sW,"unicorn/no-process-exit":{create:e=>{if(0===e.sourceCode.lines[0].indexOf("#!"))return;let t=0,r=!1,n=[],o=e=>td(e,{object:"process",methods:["on","once"],minimumArguments:1,optionalCall:!1,optionalMember:!1});e.on("CallExpression",e=>{tf(e)&&sV(e.arguments[0])&&(r=!0)}),e.on("ImportDeclaration",e=>{"Literal"===e.source.type&&sV(e.source)&&(r=!0)}),e.on("CallExpression",e=>{o(e)&&t++}),e.onExit("CallExpression",e=>{o(e)&&t--}),e.on("CallExpression",e=>{0===t&&td(e,{object:"process",method:"exit",optionalCall:!1,optionalMember:!1})&&n.push(e)}),e.onExit("Program",function*(){if(!r)for(let e of n)yield{node:e,messageId:s_}})},meta:{type:"suggestion",docs:{description:"Disallow `process.exit()`.",recommended:"unopinionated"},messages:{[s_]:"Only use `process.exit()` in CLI apps. Throw an error instead."},languages:["js/js"]}},"unicorn/no-static-only-class":{create:function(e){e.on(["ClassDeclaration","ClassExpression"],t=>{if(!(t.superClass||t.decorators&&t.decorators.length>0||"ClassBody"!==t.body.type||0===t.body.body.length||t.body.body.some(e=>!function(e){let{private:t,static:r,declare:n,readonly:o,accessibility:a,decorators:i,key:s}=e;return!(!s0(e)&&"MethodDefinition"!==e.type||!r||t||"PrivateIdentifier"===s.type||n||o||void 0!==a||Array.isArray(i)&&i.length>0)}(e))))return{node:t,loc:function(e,t){let{sourceCode:r}=t,{body:n}=e,o=r.getTokenBefore(n),{start:a}=r.getLoc(e),{end:i}=r.getLoc(o);return{start:a,end:i}}(t,e),messageId:sZ,fix:function(e,t){let{type:r,id:n,body:o,declare:a,abstract:i,implements:s,parent:l}=e;if(a||i||Array.isArray(s)&&s.length>0||"ClassExpression"===r&&n)return;let u="ClassDeclaration"===e.type&&"ExportDefaultDeclaration"===e.parent.type&&e.parent.declaration===e;if(u&&n)return;let{sourceCode:p}=t;for(let e of o.body)if(s0(e)&&(e.typeAnnotation||e.value&&p.getText(e.value).includes("this")))return;return function*(n){let a=p.getFirstToken(e);if(tw(a,{expected:{type:"Keyword",value:"class"},ruleId:"no-static-only-class"}),u||"ClassExpression"===r)if("ClassExpression"===r&&"ReturnStatement"===l.type&&p.getLoc(o).start.line!==p.getLoc(l).start.line&&p.text.slice(p.getRange(a)[1],p.getRange(o)[0]).trim()){yield n.replaceText(a,"{");let e=p.getFirstToken(o);yield n.remove(e)}else yield n.replaceText(a,""),yield oB(a,t,n);else yield n.replaceText(a,"const"),yield n.insertTextBefore(o,"= "),yield n.insertTextAfter(o,";");for(let e of o.body)yield function*(e,t,r){let{sourceCode:n}=t,o=n.getFirstToken(e);tw(o,{expected:{type:"Keyword",value:"static"},ruleId:"no-static-only-class"}),yield r.remove(o),yield oB(o,t,r);let a=s0(e)?n.getLastToken(e):n.getTokenAfter(e),i=ep(a);if(s0(e)){let{key:t,value:o}=e;if(o){let e=n.getTokenAfter(t,sQ);yield r.replaceText(e,":")}else i?yield r.insertTextBefore(a,": undefined"):yield r.insertTextAfter(e,": undefined")}yield i?r.replaceText(a,","):r.insertTextAfter(e,",")}(e,t,n)}}(t,e)}})},meta:{type:"suggestion",docs:{description:"Disallow classes that only have static members.",recommended:"unopinionated"},fixable:"code",messages:{[sZ]:"Use an object instead of a class with only static members."},languages:["js/js"]}},"unicorn/no-unreadable-array-destructuring":s3,"unicorn/no-useless-spread":{create:e=>{let{sourceCode:t}=e;e.on(["ArrayExpression","ObjectExpression"],r=>{if(!("SpreadElement"===r.parent.type&&r.parent.argument===r&&("ObjectExpression"===r.type&&"ObjectExpression"===r.parent.parent.type&&r.parent.parent.properties.includes(r.parent)||"ArrayExpression"===r.type&&("ArrayExpression"===r.parent.parent.type&&r.parent.parent.elements.includes(r.parent)||tt(r.parent.parent)&&r.parent.parent.arguments.includes(r.parent)))))return;let n=r.parent,o=t.getFirstToken(n),a=n.parent.type,i={node:o,messageId:s8,data:{argumentType:"ArrayExpression"===r.type?"array":"object",parentDescription:li[a]}};return"NewExpression"===a&&la(r)&&te(n.parent,{names:lr,argumentsLength:1,allowSpreadElement:!0})?i:{...i,*fix(i){let s;yield i.remove(o),yield oT(r,i,e);let l=t.getFirstToken(r);yield i.remove(l);let[u,p]=t.getLastTokens(r,2);if(yield i.remove(p),eu(u)&&(yield i.remove(u)),to(r)||ta(r)){let e=t.getTokenAfter(n);eu(e)&&(yield i.remove(e))}if("CallExpression"===a||"NewExpression"===a)for(let[e,n]of(s=t.getFirstToken(r),r.elements.map((e,n,o)=>{if(n===o.length-1){let e=t.getLastToken(r,{skip:1});return eu(e)?e:void 0}let a=t.getTokenAfter(e||s,eu);return s=a,a})).entries())null===r.elements[e]&&(yield i.insertTextBefore(n,"undefined"))}}}),e.on("ObjectExpression",r=>{if(!("ObjectExpression"===r.type&&r.properties.length>0&&r.properties.every(e=>"SpreadElement"===e.type&&"ObjectExpression"!==e.argument.type)))return;let n=r.parent;if(!td(n,{object:"Object",method:"assign",minimumArguments:2,optionalMember:!1,optionalCall:!1}))return;let o=n.arguments.indexOf(r),a=n.arguments.slice(0,o).some(e=>"SpreadElement"!==e.type);if(o<=0||!a)return;let i={node:t.getFirstToken(r.properties[0]),messageId:s7};return t.getCommentsInside(r).length>0?i:{...i,suggest:[{messageId:lt,fix:t=>t.replaceText(r,r.properties.map(t=>eZ(t.argument,e)).join(", "))}]}}),e.on("NewExpression",e=>{if(te(e,{names:lr,argumentsLength:1,allowSpreadElement:!0})&&"SpreadElement"===e.arguments[0].type&&"ArrayExpression"!==e.arguments[0].argument.type)return{node:e.arguments[0],messageId:s4,data:{constructorName:`new ${e.callee.name}(…)`}}}),e.on("ArrayExpression",t=>{if(!la(t))return;let{parent:r}=t;if(!("ForOfStatement"===r.type&&r.right===t||"YieldExpression"===r.type&&r.delegate&&r.argument===t||(te(r,{names:lr,argumentsLength:1})||te(r,{names:rE,minimumArguments:1})||td(r,{object:"Promise",methods:["all","allSettled","any","race"],argumentsLength:1,optionalCall:!1,optionalMember:!1})||td(r,{objects:["Array",...rE],method:"from",argumentsLength:1,optionalCall:!1,optionalMember:!1})||td(r,{object:"Object",method:"fromEntries",argumentsLength:1,optionalCall:!1,optionalMember:!1}))&&r.arguments[0]===t))return;let n="",o=s6;switch(r.type){case"ForOfStatement":o=s9;break;case"YieldExpression":o=s5;break;case"NewExpression":n=`new ${r.callee.name}(…)`;break;case"CallExpression":n=`${r.callee.object.name}.${r.callee.property.name}(…)`}return{node:t,messageId:o,data:{parentDescription:n},fix:r=>ls(r,t,e)}}),e.on("ArrayExpression",t=>{if(!la(t))return;let r=t.elements[0].argument,n=!!td(r,{methods:lo,optionalCall:!1,optionalMember:!1})&&rK(r.callee.object,e)&&rK(r,e);if(!n&&!(!rG(r,e)&&(td(r,{methods:ln,optionalCall:!1,optionalMember:!1})?!ll(r,e):td(r,{method:"concat",optionalCall:!1,optionalMember:!1})?!("Identifier"===r.callee.object.type&&"Iterator"===r.callee.object.name||ll(r,e)):td(r,{method:"split",optionalCall:!1,optionalMember:!1})||td(r,{object:"Object",methods:["keys","values"],argumentsLength:1,optionalCall:!1,optionalMember:!1})||"AwaitExpression"===r.type&&td(r.argument,{object:"Promise",methods:["all","allSettled"],argumentsLength:1,optionalCall:!1,optionalMember:!1})||td(r,{object:"Array",methods:["from","of"],optionalCall:!1,optionalMember:!1})||te(r,{name:"Array"}))))return;let o={node:t,messageId:le};return te(r,{name:"Array"})||td(r,{method:"slice",optionalCall:!1,optionalMember:!1})&&!n?o:Object.assign(o,{fix:r=>ls(r,t,e)})})},meta:{type:"suggestion",docs:{description:"Disallow unnecessary spread.",recommended:"unopinionated"},fixable:"code",hasSuggestions:!0,messages:{[s8]:"Spread an {{argumentType}} literal in {{parentDescription}} is unnecessary.",[s6]:"`{{parentDescription}}` accepts an iterable as an argument, it's unnecessary to convert to an array.",[s9]:"`for…of` can iterate over an iterable, it's unnecessary to convert to an array.",[s5]:"`yield*` can delegate to an iterable, it's unnecessary to convert to an array.",[s4]:"`{{constructorName}}` accepts a single iterable argument, spreading is misleading.",[s7]:"`Object.assign(…)` source object with only spread properties is unnecessary.",[le]:"Unnecessarily cloning an array.",[lt]:"Remove the object literal wrapper."},languages:["js/js"]}},"unicorn/no-useless-switch-case":{create:e=>{let t=ru(e.physicalFilename);e.on("SwitchStatement",function*(r){let{cases:n}=r;if(!(n.length<2)&&null===n.at(-1).test)for(let r=n.length-2;r>=0;r--){let o=n[r];if(!lc(o))break;t&&ld(o)||(yield{node:o,loc:function(e,t){let{sourceCode:r}=t,n=e.test||r.getFirstToken(e),o=r.getTokenAfter(n,ec);return{start:r.getLoc(e).start,end:r.getLoc(o).end}}(o,e),messageId:lu,suggest:[{messageId:lp,fix:e=>e.remove(o)}]})}})},meta:{type:"suggestion",docs:{description:"Disallow useless case in switch statements.",recommended:"unopinionated"},hasSuggestions:!0,messages:{[lu]:"Useless case in switch statement.",[lp]:"Remove this case."},languages:["js/js"]}},"unicorn/no-useless-undefined":lB,"unicorn/numeric-separators-style":lL,"unicorn/prefer-array-find":l3,"unicorn/prefer-array-flat-map":{create:e=>{e.on("CallExpression",t=>{if(!(td(t,{method:"flat",optionalCall:!1,optionalMember:!1})&&(0===t.arguments.length||1===t.arguments.length&&"Literal"===t.arguments[0].type&&"1"===t.arguments[0].raw)&&td(t.callee.object,{method:"map",optionalCall:!1})))return;let r=t.callee.object;if(ty(r.callee.object,l5)||rX(r.callee.object,e))return;let{sourceCode:n}=e,o=r.callee.property,a=t4(e,t,[r])||t.typeArguments||t.typeParameters||r.typeArguments||r.typeParameters?void 0:function*(r){yield oO(r,t,e),yield r.replaceText(o,"flatMap")};return{node:t,loc:{start:n.getLoc(o).start,end:n.getLoc(t).end},messageId:l8,fix:a}}),e.on("CallExpression",t=>{if(!td(t,{method:"flatMap",argumentsLength:1,optionalCall:!1,optionalMember:!1,computed:!1})||t.typeArguments||t.typeParameters)return;let r=t.callee.object;if(!td(r,{method:"filter",argumentsLength:1,optionalCall:!1,optionalMember:!1,computed:!1})||r.typeArguments||r.typeParameters||rh(r.callee.object)||rG(r.callee.object,e))return;let{sourceCode:n}=e;if(n.getCommentsInside(t).length>0)return;let[o]=r.arguments,[a]=t.arguments;if(!l7(o)||!l7(a))return;let[i]=o.params,[s]=a.params;if(!nB(i,s))return;let l=function(e,t){if(eQ(e,t))return eZ(e,t);let r=t.sourceCode.getText(e);return n2(e,t)?`(${r})`:r}(r.callee.object,e),u=n.getText(i),p=function(e,t){if(eQ(e,t))return eZ(e,t);let r=t.sourceCode.getText(e);return l4.has(e.type)?`(${r})`:r}(o.body,e),c=function(e,t){if(eQ(e,t))return eZ(e,t);let r=t.sourceCode.getText(e);return nQ(e)?`(${r})`:r}(a.body,e);return{node:t.callee.property,messageId:l6,suggest:[{messageId:l9,fix:e=>e.replaceText(t,`${l}.flatMap(${u} => ${p} ? ${c} : [])`)}]}})},meta:{type:"suggestion",docs:{description:"Prefer `.flatMap(…)` over `.map(…).flat()` and `.filter(…).flatMap(…)`.",recommended:"unopinionated"},fixable:"code",hasSuggestions:!0,messages:{[l8]:"Prefer `.flatMap(…)` over `.map(…).flat()`.",[l6]:"Prefer a single `.flatMap(…)` over `.filter(…).flatMap(…)`.",[l9]:"Replace `.filter(…).flatMap(…)` with a single `.flatMap(…)`."},languages:["js/js"]}},"unicorn/prefer-array-flat":ul,"unicorn/prefer-array-some":ud,"unicorn/prefer-code-point":{create:e=>{e.on("CallExpression",e=>{if(td(e,{method:"charCodeAt",optionalCall:!1}))return um(e.callee.property,"codePointAt")}),e.on("MemberExpression",e=>{if(tc(e,{object:"String",property:"fromCharCode",optional:!1}))return um(e.property,"fromCodePoint")})},meta:{type:"suggestion",docs:{description:"Prefer `String#codePointAt(…)` over `String#charCodeAt(…)` and `String.fromCodePoint(…)` over `String.fromCharCode(…)`.",recommended:"unopinionated"},hasSuggestions:!0,messages:{"error/charCodeAt":"Prefer `String#codePointAt()` over `String#charCodeAt()`.","error/fromCharCode":"Prefer `String.fromCodePoint()` over `String.fromCharCode()`.","suggestion/codePointAt":"Use `String#codePointAt()`.","suggestion/fromCodePoint":"Use `String.fromCodePoint()`."},languages:["js/js"]}},"unicorn/prefer-default-parameters":{create:e=>{let{sourceCode:t}=e,r=[],n=(e,n,o,a)=>{let i,s=r.at(-1);if(!s||!n||!o||"Identifier"!==n.type||"LogicalExpression"!==o.type||"||"!==o.operator&&"??"!==o.operator||"Identifier"!==o.left.type||"Literal"!==o.right.type)return;let{name:l}=n,{left:{name:u},right:{raw:p}}=o;if(a&&l!==u)return;let c=ei(t.getScope(e),u);if(!c)return;let{references:d}=c,{params:m}=s,f=m.find(e=>"Identifier"===e.type&&e.name===u);if(((e,t,r)=>{for(let n of t.body.body){if(n===r)break;if(uh(e,n))return!0}return!1})(t,s,e)||a&&d[0].identifier!==n||!a&&d.length>1||(i=m.at(-1),!f||f!==i))return;let g=((e,t)=>{if("ArrowFunctionExpression"!==t.type||t.params.length>1)return!1;let[r]=t.params,n=e.getTokenBefore(r),o=e.getTokenAfter(r);return!o||!n||"("!==n.value||")"!==o.value})(t,s)?`(${l} = ${p})`:`${l} = ${p}`;return{node:e,messageId:uf,suggest:[{messageId:ug,fix:r=>[r.replaceText(f,g),((e,t,r)=>{let{line:n}=t.getLoc(r).start,{column:o}=t.getLoc(r).end,a=t.getText(r),i=t.lines[n-1];if(i.trim()===a)return e.removeRange([t.getIndexFromLoc({line:n,column:0}),t.getIndexFromLoc({line:n+1,column:0})]);if(" "===i[o]){let[n,o]=t.getRange(r);return e.removeRange([n,o+1])}return e.remove(r)})(r,t,e)]}]}};e.on(ts,e=>{r.push(e)}),e.onExit(ts,()=>{r.pop()}),e.on("AssignmentExpression",e=>{if("ExpressionStatement"===e.parent.type&&e.parent.expression===e)return n(e.parent,e.left,e.right,!0)}),e.on("VariableDeclarator",e=>{if("VariableDeclaration"===e.parent.type&&e.parent.declarations[0]===e)return n(e.parent,e.id,e.init,!1)})},meta:{type:"suggestion",docs:{description:"Prefer default parameters over reassignment.",recommended:"unopinionated"},hasSuggestions:!0,messages:{[uf]:"Prefer default parameters over reassignment.",[ug]:"Replace reassignment with default parameter."},languages:["js/js"]}},"unicorn/prefer-logical-operator-over-ternary":{create:e=>{let{sourceCode:t}=e;e.on("ConditionalExpression",r=>{let{test:n,consequent:o,alternate:a}=r,i=function(e,t){let{test:r,consequent:n,alternate:o}=e,a=function(e,t){let r=uw(e);if(r?.kind==="nullish")return r;if("LogicalExpression"!==e.type)return;let n=uw(e.left),o=uw(e.right);if(n&&o&&uC(n.reference,o.reference,t)){if("||"===e.operator&&n.isTrueWhenNullish&&o.isTrueWhenNullish&&uk(n,o))return{reference:n.reference,isTrueWhenNullish:!0};if("&&"===e.operator&&!n.isTrueWhenNullish&&!o.isTrueWhenNullish&&uk(n,o))return{reference:n.reference,isTrueWhenNullish:!1}}}(r,t.sourceCode);if(!a||t.sourceCode.getCommentsInside(e).length>0)return;let{reference:i}=a;if(a.isTrueWhenNullish&&uC(i,o,t.sourceCode))return uA({context:t,conditionalExpression:e,left:o,right:n,operators:["??"]});if(!a.isTrueWhenNullish&&uC(i,n,t.sourceCode))return uA({context:t,conditionalExpression:e,left:n,right:o,operators:["??"]});let s=a.isTrueWhenNullish?n:o,l=a.isTrueWhenNullish?o:n;if(!tx(s)||!tc(l)||l.optional||!tQ(ry(i),ry(l.object))||function(e){let t=e,{parent:r}=t;for(;rg(r)&&r.expression===t;)r=(t=r).parent;return"UnaryExpression"===r.type&&"delete"===r.operator&&r.argument===t||"CallExpression"===r.type&&r.callee===t||"TaggedTemplateExpression"===r.type&&r.tag===t}(e))return;let u=function(e,t){let{sourceCode:r}=t,n=ri(e,t);if(re(t,n))return;let[o,a]=r.getRange(e),[i,s]=n;return r.text.slice(o,i)+(e.computed?"?.[":"?.")+r.text.slice(s,a)}(l,t);if(u)return{node:e,messageId:ub,suggest:[{messageId:uD,fix(r){let n=u;return nW(t.sourceCode.getTokenBefore(e),t,n)&&(n=`;${n}`),r.replaceText(e,n)}}]}}(r,e);return i||(uC(n,o,t)?uA({context:e,conditionalExpression:r,left:n,right:a}):"UnaryExpression"===n.type&&"!"===n.operator&&n.prefix&&uC(n.argument,a,t)?uA({context:e,conditionalExpression:r,left:n.argument,right:o}):void 0)})},meta:{type:"suggestion",docs:{description:"Prefer using a logical operator over a ternary.",recommended:"unopinionated"},hasSuggestions:!0,messages:{[ux]:"Prefer using a logical operator over a ternary.",[ub]:"Prefer using optional chaining over a ternary.",[uE]:"Switch to `{{operator}}` operator.",[uD]:"Switch to optional chaining."},languages:["js/js"]}},"unicorn/prefer-optional-catch-binding":{create:e=>{e.on("CatchClause",t=>{let r=t.param;if(!r)return;let{sourceCode:n}=e;if(n.getDeclaredVariables(r.parent).some(e=>e.references.length>0))return;let{type:o,name:a,parent:i}=r,s=n.getCommentsInside(r).length>0;return{node:r,messageId:"Identifier"===o?uI:uj,data:{name:a},fix:s?void 0:function*(e){let t=n.getTokenBefore(r);tw(t,{test:ed,expected:"(",ruleId:"prefer-optional-catch-binding"});let o=n.getTokenAfter(r);tw(o,{test:em,expected:")",ruleId:"prefer-optional-catch-binding"}),yield e.remove(t),yield e.remove(r),yield e.remove(o);let[,a]=n.getRange(o),[s]=n.getRange(i.body),l=n.text.slice(a,s),u=l.length-l.trimStart().length;0!==u&&(yield e.removeRange([a,a+u]))}}})},meta:{type:"suggestion",docs:{description:"Prefer omitting the `catch` binding parameter.",recommended:"unopinionated"},fixable:"code",messages:{[uI]:"Remove unused catch binding `{{name}}`.",[uj]:"Remove unused catch binding."},languages:["js/js"]}},"unicorn/prefer-regexp-test":u9,"unicorn/prefer-set-has":pc,"unicorn/prefer-string-raw":{create:e=>{e.on("Literal",t=>{if(!e1(t)||function(e){let{parent:t}=e,{type:r}=t;return tr(t)||["Property","PropertyDefinition","MethodDefinition","AccessorProperty"].includes(r)&&!t.computed&&t.key===e||["TSAbstractPropertyDefinition","TSAbstractMethodDefinition","TSAbstractAccessorProperty","TSPropertySignature"].includes(r)&&t.key===e||["ImportDeclaration","ExportNamedDeclaration","ExportAllDeclaration"].includes(r)&&t.source===e||"ImportAttribute"===r&&(t.key===e||t.value===e)||"ImportSpecifier"===r&&t.imported===e||"ExportSpecifier"===r&&(t.local===e||t.exported===e)||"ExportAllDeclaration"===r&&t.exported===e||"JSXAttribute"===r&&t.value===e||"TSEnumMember"===r&&(t.initializer===e||t.id===e)||"TSModuleDeclaration"===r&&t.id===e||"TSExternalModuleReference"===r&&t.expression===e||"TSLiteralType"===r&&t.literal===e||"TSImportType"===r&&t.source===e}(t)||pd(t))return;let{sourceCode:r}=e,{raw:n}=t;if("\\"===n.at(-2)||!n.includes("\\\\")||n.includes("`")||n.includes("${")||r.getLoc(t).start.line!==r.getLoc(t).end.line)return;let o=pg(n.slice(1,-1),n.charAt(0));if(o===t.value)return{node:t,messageId:pm,*fix(r){yield oP(r,t,e),yield r.replaceText(t,`String.raw\`${o}\``)}}}),e.on("TemplateLiteral",t=>{if(!("TaggedTemplateExpression"===t.parent.type&&t.parent.quasi===t||t.quasis.every(({value:{cooked:e,raw:t}})=>e===t)||t.quasis.some(({value:{cooked:e,raw:t}})=>"\\"===e.at(-1)||pg(t)!==e)||pd(t)))return{node:t,messageId:pm,*fix(r){for(let n of(yield oP(r,t,e),yield r.insertTextBefore(t,"String.raw"),t.quasis)){let{cooked:t,raw:o}=n.value;t!==o&&(yield o_(n,t,e,r))}}}}),e.on("TaggedTemplateExpression",t=>{let{quasi:r,tag:n,parent:o}=t,{sourceCode:a}=e;if(!tc(n,{object:"String",property:"raw",optional:!1})||!a.isGlobalReference(n.object)||r.quasis.some(e=>e.value.raw.includes("\\")))return;let i=a.getText(r),s=r.expressions.length>0||/\r?\n/.test(i)?i:`'${i.slice(1,-1).replaceAll("'",()=>String.raw`\'`)}'`;return{node:n,messageId:pf,*fix(r){let n=a.getTokenBefore(t);nW(n,e,s)&&(yield r.insertTextBefore(t,";")),"ReturnStatement"!==o.type&&"ThrowStatement"!==o.type||nF(n,t.quasi,e)||eQ(t,e)||(yield oF(r,o,e)),"YieldExpression"!==o.type||o.delegate||o.argument!==t||nF(n,t.quasi,e)||eQ(t,e)||(yield r.insertTextBefore(t,"("),yield r.insertTextAfter(t,")")),yield r.replaceText(t.quasi,s),yield oT(t.tag,r,e),yield r.remove(t.tag)}}})},meta:{type:"suggestion",docs:{description:"Prefer using the `String.raw` tag to avoid escaping `\\`.",recommended:"unopinionated"},fixable:"code",messages:{[pm]:"`String.raw` should be used to avoid escaping `\\`.",[pf]:"Using `String.raw` is unnecessary as the string does not contain any `\\`."},languages:["js/js"]}},"unicorn/prefer-switch":pS,"unicorn/require-number-to-fixed-digits-argument":{create:e=>{e.on("CallExpression",t=>{if(!td(t,{method:"toFixed",argumentsLength:0,optionalCall:!1})||"NewExpression"===t.callee.object.type)return;let{sourceCode:r}=e,[n,o]=r.getLastTokens(t,2);return{loc:{start:r.getLoc(n).start,end:r.getLoc(o).end},messageId:pv,fix:r=>ow(r,t,"0",e)}})},meta:{type:"suggestion",docs:{description:"Enforce using the digits argument with `Number#toFixed()`.",recommended:"unopinionated"},fixable:"code",messages:{[pv]:"Missing the digits argument."},languages:["js/js"]}},"unicorn/template-indent":{create:e=>{let{sourceCode:t}=e,r={...e.options[0]},n=(e=>{let t=new Set,r=[e.ast];for(;r.length>0;){let n=r.pop();if(n){if("TemplateLiteral"===n.type){let{start:{line:r},end:{line:o}}=e.getLoc(n);for(let e=r+1;e<=o;e++)t.add(e)}for(let t of e.visitorKeys[n.type]??[]){let e=n[t];Array.isArray(e)?r.push(...e):r.push(e)}}}return t})(t);r.comments=r.comments.map(e=>e.toLowerCase());let o=new WeakSet,a=a=>{let i;if("TemplateLiteral"!==a.type||o.has(a))return;o.add(a);let s="__PLACEHOLDER__"+Math.random(),l=a.quasis.map(e=>t.getText(e).slice(1,e.tail?-1:-2)).join(s),u=l.match(/\r?\n/);if(!u)return;let p=u[0],c=t.getLoc(a),d=t.lines[c.start.line-1].match(/^(\s*)\S/),m=d?d[1]:"";i="string"==typeof r.indent?r.indent:"number"==typeof r.indent?" ".repeat(r.indent):((e,t,r,n)=>{if(""===r){let r;return pk(pj(e.lines,t)).indent||pk(pC(r=pj(n.split(/\r?\n/)))).indent||pk(r).indent||" "}return r.startsWith(" ")?" ":" "})(t,n,m,l);let f=pC(l).replaceAll(RegExp(`^${p}|${p}[ ]*$`,"g"),""),g=p+function(e,t=1,r={}){let{indent:n=" ",includeEmptyLines:o=!1}=r;if("string"!=typeof e)throw TypeError(`Expected \`input\` to be a \`string\`, got \`${typeof e}\``);if("number"!=typeof t)throw TypeError(`Expected \`count\` to be a \`number\`, got \`${typeof t}\``);if(t<0)throw RangeError(`Expected \`count\` to be at least 0, got \`${t}\``);if("string"!=typeof n)throw TypeError(`Expected \`options.indent\` to be a \`string\`, got \`${typeof n}\``);return 0===t?e:e.replace(o?/^/gm:/^(?!\s*$)/gm,n.repeat(t))}(f,1,{indent:m+i})+p+m;if(g!==l)return{node:a,messageId:pI,fix:t=>g.split(s).map((r,n)=>o_(a.quasis[n],r,e,t))}};e.on("TemplateLiteral",e=>{if((e=>{if(r.comments.length>0){let n=t.getTokenBefore(e,{includeComments:!0});if(n?.type==="Block"&&r.comments.includes(n.value.trim().toLowerCase()))return!0}return!!(pd(e)||r.tags.length>0&&th(e,r.tags))||!!(r.functions.length>0&&"CallExpression"===e.parent.type&&e.parent.arguments.includes(e)&&ty(e.parent.callee,r.functions))})(e))return a(e)}),e.on(r.selectors,e=>a(e))},meta:{type:"suggestion",docs:{description:"Fix whitespace-insensitive template indentation.",recommended:!0},fixable:"code",schema:pF,defaultOptions:[{tags:["outdent","dedent","gql","sql","html","styled"],functions:["dedent","stripIndent"],selectors:[],comments:["HTML","indent"]}],messages:{[pI]:"Templates should be properly indented."},languages:["js/js"]}},"unicorn/no-single-promise-in-promise-methods":{create:e=>{e.on("CallExpression",t=>{if(!(td(t,{object:"Promise",methods:sJ,optionalMember:!1,optionalCall:!1,argumentsLength:1})&&"ArrayExpression"===t.arguments[0].type&&1===t.arguments[0].elements.length&&t.arguments[0].elements[0]&&"SpreadElement"!==t.arguments[0].elements[0].type))return;let r=t.callee.property.name,n={node:t.arguments[0],messageId:sz,data:{method:r}},{sourceCode:o}=e;if("AwaitExpression"===t.parent.type&&t.parent.argument===t&&("all"!==r||ti(t.parent.parent)))return n.fix=r=>r.replaceText(t,sX(t,e)),n;return"all"===r?(n.fix=((e,t)=>{let{sourceCode:r}=t;if(sY(r,e))return;let n=e.parent;if("AwaitExpression"!==n.type||n.argument!==e)return;let o=(e=>{let{parent:t}=e;return"VariableDeclarator"===t.type&&t.init===e&&sH(t.id)?t.id:"AssignmentExpression"===t.type&&t.right===e&&sH(t.left)&&ti(t.parent)?t.left:void 0})(n);if(o){if(sY(r,o))return;return function*(n){yield n.replaceText(o,r.getText(o.elements[0])),yield n.replaceText(e,sX(e,t))}}let a=n.parent;if("MemberExpression"===a.type&&a.computed&&e0(a.property,0)&&a.object===n&&("VariableDeclarator"===a.parent.type&&a.parent.init===a||"AssignmentExpression"===a.parent.type&&a.parent.right===a)&&!sY(r,a))return r=>r.replaceText(a,`await ${sX(e,t)}`)})(t,e),n):(n.suggest=[{messageId:sK,fix:r=>{let[n]=t.arguments[0].elements,o=eZ(n,e);return eQ(n,e)||"Identifier"===n.type||"MemberExpression"===n.type||(o=`(${o})`),nW(e.sourceCode.getTokenBefore(t),e,o)&&(o=`;${o}`),r.replaceText(t,o)}},{messageId:sG,fix:function*(e){let r=t.callee.property;yield e.replaceText(r,"resolve");let[n]=t.arguments,a=o.getFirstToken(n),[i,s]=o.getLastTokens(n,2);yield e.remove(a),yield e.remove(s),eu(i)&&(yield e.remove(i))}}],n)})},meta:{type:"suggestion",docs:{description:"Disallow passing single-element arrays to `Promise` methods.",recommended:"unopinionated"},fixable:"code",hasSuggestions:!0,messages:{[sz]:"Wrapping single-element array with `Promise.{{method}}()` is unnecessary.",[sK]:"Use the value directly.",[sG]:"Switch to `Promise.resolve(…)`."},languages:["js/js"]}},"unicorn/no-await-in-promise-methods":{create:e=>{e.on("CallExpression",function*(t){if(td(t,{object:"Promise",methods:p$,optionalMember:!1,optionalCall:!1,argumentsLength:1})&&"ArrayExpression"===t.arguments[0].type)for(let r of t.arguments[0].elements)r?.type==="AwaitExpression"&&(yield{node:r,messageId:pB,data:{method:t.callee.property.name},suggest:[{messageId:pR,*fix(t){let n=e.sourceCode.getFirstToken(r);yield t.remove(n),yield oB(n,e,t)}}]})})},meta:{type:"suggestion",docs:{description:"Disallow using `await` in `Promise` method parameters.",recommended:"unopinionated"},hasSuggestions:!0,messages:{[pB]:"Promise in `Promise.{{method}}()` should not be awaited.",[pR]:"Remove `await`."},languages:["js/js"]}},"unicorn/no-negation-in-equality-check":{create:e=>{e.on("BinaryExpression",t=>{let{operator:r,left:n}=t;if(!("BinaryExpression"===t.type&&pN.has(t.operator)&&pM(n)&&!pM(n.argument)))return;let{sourceCode:o}=e,a=o.getFirstToken(n),i=`${r.startsWith("!")?"=":"!"}${r.slice(1)}`;return{node:a,messageId:pP,suggest:[{messageId:pL,data:{operator:i},*fix(s){yield oP(s,t,e);let l=o.getTokenAfter(a),{parent:u}=t;("ReturnStatement"===u.type||"ThrowStatement"===u.type)&&!eQ(t,e)&&(nF(o.getFirstToken(u),l,e)||(yield oF(s,u,e))),yield s.remove(a),nW(o.getTokenBefore(a),e,l.value)&&(yield s.insertTextAfter(a,";"));let p=o.getTokenAfter(n,e=>"Punctuator"===e.type&&e.value===r);yield s.replaceText(p,i)}}]}})},meta:{type:"problem",docs:{description:"Disallow negated expression in equality check.",recommended:"unopinionated"},hasSuggestions:!0,messages:{[pP]:"Negated expression is not allowed in equality check.",[pL]:"Switch to '{{operator}}' check."},languages:["js/js"]}},"unicorn/no-unnecessary-slice-end":{create(e){pO(e,{methods:["slice"],messageId:pq})},meta:{type:"suggestion",docs:{description:"Disallow using `.length` or `Infinity` as the `end` argument of `{Array,String,TypedArray}#slice()`.",recommended:"unopinionated"},fixable:"code",messages:{[pq]:"Passing `{{description}}` as the `end` argument is unnecessary."},languages:["js/js"]}},"unicorn/no-lonely-if":{create:e=>{e.on("IfStatement",t=>{if(cr(t)&&("BlockStatement"===t.parent.type&&1===t.parent.body.length&&t.parent.body[0]===t&&cr(t.parent.parent)&&t.parent.parent.consequent===t.parent||cr(t.parent)&&t.parent.consequent===t))return{node:t,messageId:ct,fix:function(e,t){let{sourceCode:r}=t;return n=>{var o,a;let i=("BlockStatement"===e.parent.type?e.parent:e).parent,s={...i,...cn(i,r)},l={...e,...cn(e,r)},u=cs(s,r),p=cl(s,t,r),c=ci(ca(cs(l,r)),cl(l,t,r)),d=function(e,t,r,n){let o=[...n.getRange(e)];if("BlockStatement"===t.type)return o;let a=n.getLastToken(t);if(ey(a)){let t=n.getTokenAfter(e);t&&nW(a,r,t.value)&&(o[1]=n.getRange(t)[0])}return o}(i,l.consequent,t,r),m={outerConditionGap:s.openingBraceToken?ca(co(s.closingParenthesisToken,s.openingBraceToken,r)):"",outerLeadingContent:s.openingBraceToken?ca(co(s.openingBraceToken,l.ifToken,r)):ca(co(s.closingParenthesisToken,l.ifToken,r)),outerTrailingContent:s.openingBraceToken?ca(co(l,s.closingBraceToken,r)):""},f=(o=m.outerConditionGap,a=m.outerLeadingContent,o.trimStart().startsWith("//")?{leadingStatementText:ca(a).trimStart(),conditionSuffixText:o}:{leadingStatementText:ca(ci(o,a)).trimStart(),conditionSuffixText:""}),{leadingStatementText:g}=f,y=function({outerIfStatement:e,inner:t,replacementRange:r,sourceCode:n,consequentTextPieces:o,outerConditionGapTextPieces:a}){let{outerTrailingContent:i}=o,{conditionSuffixText:s}=a;if("BlockStatement"===t.consequent.type){let e=co(t.closingParenthesisToken,t.openingBraceToken,n),r=co(t.openingBraceToken,t.closingBraceToken,n);return`${s}${e}{${r}${i}}`}let l=co(t.closingParenthesisToken,t.consequent,n),u=`${s}${l}${((e,t)=>{let[r,n]=t.getRange(e);return t.text.slice(r,n)})(t.consequent,n)}${i}`;return`${u}${((e,t,r)=>{let[,n]=r.getRange(e);if(t[1]===n)return"";let o=r.text.slice(n,t[1]);return""===o.trim()?o.includes("\n")?`;${o}`:";":`;${o}`})(e,r,n)}`}({outerIfStatement:i,inner:l,replacementRange:d,sourceCode:r,consequentTextPieces:m,outerConditionGapTextPieces:f});return n.replaceTextRange(d,`${g}if${u}(${p} && ${c})${y}`)}}(t,e)}})},meta:{type:"suggestion",docs:{description:"Disallow `if` statements as the only statement in `if` blocks without `else`.",recommended:"unopinionated"},fixable:"code",messages:{[ct]:"Unexpected `if` as the only statement in a `if` block without `else`."},languages:["js/js"]}},"unicorn/no-magic-array-flat-depth":{create:e=>{e.on("CallExpression",t=>{if(!td(t,{method:"flat",argumentsLength:1,optionalCall:!1}))return;let[r]=t.arguments;if(!e8(r)||1===r.value)return;let{sourceCode:n}=e,{openingParenthesisToken:o,closingParenthesisToken:a}=tX(t,e);if(!n.commentsExistBetween(o,a))return{node:r,messageId:cu}})},meta:{type:"suggestion",docs:{description:"Disallow a magic number as the `depth` argument in `Array#flat(…).`",recommended:"unopinionated"},messages:{[cu]:"Magic number as depth is not allowed."},languages:["js/js"]}},"unicorn/no-negated-condition":{create:e=>{e.on(["IfStatement","ConditionalExpression"],t=>{if("IfStatement"===t.type&&(!t.alternate||"IfStatement"===t.alternate.type))return;let{test:r}=t;if("UnaryExpression"===r.type&&"!"===r.operator||"BinaryExpression"===r.type&&("!="===r.operator||"!=="===r.operator))return{node:r,messageId:cp,*fix(n){if(yield function*(e,t,r){let{sourceCode:n}=r,{test:o}=t;if("UnaryExpression"===o.type){let a=n.getFirstToken(o);"IfStatement"===t.type&&(yield oT(o.argument,e,r)),yield e.remove(a);return}let a=n.getTokenAfter(o.left,e=>"Punctuator"===e.type&&e.value===o.operator);yield e.replaceText(a,"="+a.value.slice(1))}(n,t,e),yield function*(e,t,r){let n="IfStatement"===t.type,[o,a]=[t.consequent,t.alternate].map(e=>{let t=eH(e,r),o=r.sourceCode.text.slice(...t);return n&&"BlockStatement"!==e.type&&(o=`{${o}}`),{range:t,text:o}});if(o.text===a.text)return;let{sourceCode:i}=r;yield e.replaceTextRange(i.getRange(o),a.text),yield e.replaceTextRange(i.getRange(a),o.text)}(n,t,e),"ConditionalExpression"!==t.type||"UnaryExpression"!==r.type)return;yield oP(n,t,e);let{sourceCode:o}=e,{parent:a}=t,[i,s]=o.getFirstTokens(r,2);"ReturnStatement"!==a.type&&"ThrowStatement"!==a.type||a.argument!==t||nF(i,s,e)||eQ(t,e)||eQ(r,e)?nW(o.getTokenBefore(t),e,s.value)&&(yield n.insertTextBefore(t,";")):yield oF(n,a,e)}}})},meta:{type:"suggestion",docs:{description:"Disallow negated conditions.",recommended:"unopinionated"},fixable:"code",messages:{[cp]:"Unexpected negated condition."},languages:["js/js"]}},"unicorn/no-object-as-default-parameter":{create:e=>{e.on("AssignmentPattern",e=>{if(!("ObjectExpression"===e.right.type&&e.right.properties.length>0&&tl(e.parent)&&e.parent.params.includes(e)))return;let{left:t,right:r}=e;return"Identifier"===t.type?{node:t,messageId:cc,data:{parameter:t.name}}:{node:r,messageId:cd}})},meta:{type:"problem",docs:{description:"Disallow the use of objects as default parameters.",recommended:"unopinionated"},messages:{[cc]:"Do not use an object literal as default for parameter `{{parameter}}`.",[cd]:"Do not use an object literal as default."},languages:["js/js"]}},"unicorn/prefer-negative-index":{create:e=>{e.on("CallExpression",t=>{if("MemberExpression"!==t.callee.type)return;let r=function(e){let{callee:t,arguments:r}=e,n=t.property.name,o=t.object,a=r;if(cf.has(n))return{method:n,target:o,argumentsNodes:a};if("call"!==n&&"apply"!==n||(n=cg(t.object),!cf.has(n)))return;let i="apply"===t.property.name,{supportObjects:s}=cf.get(n),l=t.object.object;if(to(l)||"slice"===n&&e0(l,"")||"prototype"===cg(l)&&"Identifier"===l.object.type&&s.has(l.object.name)){if([o]=r,i){let[,e]=r;if(!e||"ArrayExpression"!==e.type)return;a=e.elements}else a=r.slice(1);return{method:n,target:o,argumentsNodes:a}}}(t);if(!r)return;let{method:n,target:o,argumentsNodes:a}=r,{argumentsIndexes:i}=cf.get(n),s=i.map(e=>(function e(t,r){let n;if(!t)return;let{type:o,operator:a,left:i,right:s}=t=ry(t);if("BinaryExpression"!==o||"-"!==a||!(e8(n=ry(s))&&n.value>0))return;let l=ry(i);return"MemberExpression"===l.type&&!l.computed&&!l.optional&&"Identifier"===l.property.type&&"length"===l.property.name&&ly(l.object,r)?i:e(i,r)})(a[e],o)).filter(Boolean);if(0!==s.length)return{node:t,messageId:cm,data:{method:n},*fix(t){for(let r of s)yield function(e,t,r){let[n,o]=eH(e,r);return t.removeRange([n,o+r.sourceCode.text.slice(o).match(/\S|$/).index])}(r,t,e)}}})},meta:{type:"suggestion",docs:{description:"Prefer negative index over `.length - index` when possible.",recommended:"unopinionated"},fixable:"code",messages:{[cm]:"Prefer negative index over length minus index for `{{method}}`."},languages:["js/js"]}},"unicorn/prefer-node-protocol":{create:e=>{e.on("Literal",t=>{if(!(["ImportDeclaration","ExportNamedDeclaration","ExportAllDeclaration","ImportExpression","TSImportType"].includes(t.parent.type)&&t.parent.source===t||(td(t.parent,{object:"process",method:"getBuiltinModule",argumentsLength:1,optionalCall:!1,optionalMember:!1})||tf(t.parent))&&t.parent.arguments[0]===t))return;let{value:r}=t;if(!("string"==typeof r&&!r.startsWith(cb)&&ch(r)&&ch(`${cb}${r}`)))return;let n=e.sourceCode.getRange(t)[0]+1;return{node:t,messageId:cx,data:{moduleName:r},fix:e=>e.insertTextAfterRange([n,n],cb)}})},meta:{type:"suggestion",docs:{description:"Prefer using the `node:` protocol when importing Node.js builtin modules.",recommended:"unopinionated"},fixable:"code",messages:{[cx]:"Prefer `node:{{moduleName}}` over `{{moduleName}}`."},languages:["js/js"]}},"unicorn/consistent-date-clone":{create:e=>{e.on("NewExpression",t=>{if(!te(t,{name:"Date",argumentsLength:1}))return;let[r]=t.arguments;if(!td(r,{method:"getTime",argumentsLength:0,optionalCall:!1,optionalMember:!1}))return;let{sourceCode:n}=e;return{node:r,loc:{start:n.getLoc(r.callee.property).start,end:n.getLoc(r).end},messageId:cE,fix:t=>oO(t,r,e)}})},meta:{type:"suggestion",docs:{description:"Prefer passing `Date` directly to the constructor when cloning.",recommended:"unopinionated"},fixable:"code",messages:{[cE]:"Unnecessary `.getTime()` call."},languages:["js/js"]}},"unicorn/no-accessor-recursion":{create:e=>{let{sourceCode:t}=e;e.on("ThisExpression",e=>{let r=((e,t)=>{for(let r=e.getScope(t);r;r=r.upper){if("class"===r.type)return;if("function"===r.type&&"ArrowFunctionExpression"!==r.block.type)return r}})(t,e);if(!r)return;let n=r.block.parent;if(["Property","MethodDefinition"].includes(n?.type)&&!n.computed&&["set","get"].includes(n.kind)&&cS(n.key)&&("get"===n.kind&&(cC(e,n)||"VariableDeclarator"===e.parent.type&&e.parent.init===e&&"ObjectPattern"===e.parent.id.type&&e.parent.id.properties.some(e=>"Property"===e.type&&!e.computed&&cv(e.key,n.key)))||"set"===n.kind&&((e,t)=>{if(!cC(e,t))return!1;let r=e.parent,{parent:n}=r;return("AssignmentExpression"===n.type||"AssignmentPattern"===n.type)&&n.left===r||"UpdateExpression"===n.type&&n.argument===r||"ArrayPattern"===n.type&&n.elements.includes(r)||"RestElement"===n.type&&n.argument===r||("ForOfStatement"===n.type||"ForInStatement"===n.type)&&n.left===r||"Property"===n.type&&n.value===r&&"ObjectPattern"===n.parent.type&&n.parent.properties.includes(r.parent)})(e,n)))return{node:e.parent,messageId:cD,data:{kind:n.kind}}})},meta:{type:"problem",docs:{description:"Disallow recursive access to `this` within getters and setters.",recommended:"unopinionated"},defaultOptions:[],messages:{[cD]:"Disallow recursive access to `this` within {{kind}}ters."},languages:["js/js"]}},"unicorn/prefer-import-meta-properties":{create:function(e){let{sourceCode:t}=e;e.on("MetaProperty",function*(e){if("MetaProperty"!==e.type||"import"!==e.meta.name||"meta"!==e.property.name)return;let r=e.parent;if(!tc(r,{properties:["url","filename"],computed:!1,optional:!1}))return;let n=r.property.name;if("url"===n){if(ck(r.parent,t)&&r.parent.arguments[0]===r)return void(yield a(r.parent,{reportFilenameNode:!0}));if(te(r.parent,{name:"URL",minimumArguments:1,maximumArguments:2})){var o;let e=r.parent,n=e.parent;if(1===e.arguments.length&&e.arguments[0]===r&&ck(n,t)&&n.arguments[0]===e)return void(yield a(n,{reportFilenameNode:!0}));2===e.arguments.length&&(o=e.arguments[0],o?.type==="Literal"&&("."===o.value||"./"===o.value))&&e.arguments[1]===r&&ck(n,t)&&n.arguments[0]===e&&(yield i(n,"dirname"))}return}function*a(e,{reportFilenameNode:r=!1}={}){let{parent:n}=e;if(cI(n,t)&&n.arguments[0]===e)return void(yield i(n,"dirname"));if(r&&(yield i(e,"filename")),"VariableDeclarator"!==n.type||n.init!==e||"Identifier"!==n.id.type||"VariableDeclaration"!==n.parent.type||"const"!==n.parent.kind)return;let o=ei(t.getScope(n.id),n.id);if(o)for(let e of o.references){if(!e.isReadOnly())continue;let{parent:r}=e.identifier;cI(r,t)&&r.arguments[0]===e.identifier&&(yield i(r,"dirname"))}}function i(e,t){return{node:e,messageId:"dirname"===t?cA:cT,fix:r=>r.replaceText(e,`import.meta.${t}`)}}"filename"===n&&(yield a(r))})},meta:{type:"suggestion",docs:{description:"Prefer `import.meta.{dirname,filename}` over legacy techniques for getting file paths.",recommended:!1},fixable:"code",messages:{[cA]:"Do not construct dirname.",[cT]:"Do not construct filename using `fileURLToPath()`."},languages:["js/js"]}},"unicorn/no-unnecessary-array-flat-depth":{create:e=>{e.on("CallExpression",t=>{if(!(td(t,{method:"flat",argumentsLength:1,optionalCall:!1})&&e0(t.arguments[0],1)))return;let[r]=t.arguments;return{node:r,messageId:cj,fix:t=>ok(t,r,e)}})},meta:{type:"suggestion",docs:{description:"Disallow using `1` as the `depth` argument of `Array#flat()`.",recommended:"unopinionated"},fixable:"code",messages:{[cj]:"Passing `1` as the `depth` argument is unnecessary."},languages:["js/js"]}},"unicorn/no-unnecessary-array-splice-count":{create(e){pO(e,{methods:["splice","toSpliced"],messageId:cF})},meta:{type:"suggestion",docs:{description:"Disallow using `.length` or `Infinity` as the `deleteCount` or `skipCount` argument of `Array#{splice,toSpliced}()`.",recommended:"unopinionated"},fixable:"code",messages:{[cF]:"Passing `{{description}}` as the `{{argumentName}}` argument is unnecessary."},languages:["js/js"]}},"unicorn/no-useless-error-capture-stack-trace":{create:e=>{let t=[],r=[];e.on(["ClassDeclaration","ClassExpression"],e=>{t.push(e),r.push(e)}),e.onExit(["ClassDeclaration","ClassExpression"],()=>{t.pop(),r.pop()}),e.on(["FunctionDeclaration","FunctionExpression"],e=>{r.push(e)}),e.onExit(["FunctionDeclaration","FunctionExpression"],()=>{r.pop()}),e.on("CallExpression",n=>{let o,a=t.at(-1);if(!(a?.superClass&&"Identifier"===a.superClass.type&&i4.includes(a.superClass.name)&&e.sourceCode.isGlobalReference(a.superClass)&&(o=r.at(-1),o&&"MethodDefinition"===o.parent.type&&"constructor"===o.parent.kind&&o.parent.value===o&&a.body.body.includes(o.parent))&&td(n,{object:"Error",method:"captureStackTrace",argumentsLength:2,optionalMember:!1})&&e.sourceCode.isGlobalReference(n.callee.object)))return;let[i,s]=n.arguments;if("ThisExpression"!==i.type||!((e,t,r)=>{if("MetaProperty"===e.type&&"Identifier"===e.meta.type&&"new"===e.meta.name&&"Identifier"===e.property.type&&"target"===e.property.name||tc(e,{property:"constructor",computed:!1,optional:!1})&&"ThisExpression"===e.object.type)return!0;if("Identifier"!==e.type||!t.id)return!1;let n=ei(r.sourceCode.getScope(e),e);return n&&1===n.defs.length&&"ClassName"===n.defs[0].type&&n.defs[0].node===t})(s,a,e))return;let l={node:n,messageId:cB},u="ChainExpression"===n.parent.type?n.parent.parent:n.parent;return"ExpressionStatement"===u.type&&"BlockStatement"===u.parent.type&&(l.fix=e=>e.remove(u)),l})},meta:{type:"suggestion",docs:{description:"Disallow unnecessary `Error.captureStackTrace(…)`.",recommended:"unopinionated"},fixable:"code",messages:{[cB]:"Unnecessary `Error.captureStackTrace(…)` call."},languages:["js/js"]}},"unicorn/prefer-class-fields":{create:e=>{let{sourceCode:t}=e;e.on("ClassBody",r=>{let n=r.body.find(e=>"constructor"===e.kind&&!e.computed&&!e.static&&"MethodDefinition"===e.type&&"FunctionExpression"===e.value.type);if(!n)return;let o=n.value.body.body.find(e=>"EmptyStatement"!==e.type);if(!(o?.type==="ExpressionStatement"&&"AssignmentExpression"===o.expression.type&&"="===o.expression.operator&&"MemberExpression"===o.expression.left.type&&"ThisExpression"===o.expression.left.object.type&&!o.expression.left.computed&&["Identifier","PrivateIdentifier"].includes(o.expression.left.property.type)&&"Literal"===o.expression.right.type))return;let a=o.expression.left.property.name,i=o.expression.right.raw,s=o.expression.left.property.type,l=r.body.find(e=>"PropertyDefinition"===e.type&&!e.computed&&!e.static&&e.key.type===s&&e.key.name===a),u={node:o,messageId:cR};function*p(s){if(yield((e,t,r)=>{let{line:n}=t.getLoc(e).start,o=t.getText(e);return t.lines[n-1].trim()===o?r.removeRange([t.getIndexFromLoc({line:n,column:0}),t.getIndexFromLoc({line:n+1,column:0})]):r.remove(e)})(o,t,s),l){if(l.value)return void(yield s.replaceText(l.value,i));let e=` = ${i}`,r=t.getLastToken(l);return ep(r)?void(yield s.insertTextBefore(r,e)):void(yield s.insertTextAfter(l,`${e};`))}let u=t.getLastToken(r),p=t8(n,e),c=`${p}${a} = ${i};
|
|
27
27
|
`;"\n"!==t.getText()[t.getRange(u)[0]-1]&&(c=`
|
|
28
28
|
${c}`);let d=r.body.at(-1);"PropertyDefinition"===d.type&&";"!==t.getLastToken(d).value&&(c=`;${c}`),yield s.insertTextBefore(u,c)}return l?.value?u.suggest=[{messageId:c$,fix:p}]:u.fix=p,u})},meta:{type:"suggestion",docs:{description:"Prefer class field declarations over `this` assignments in constructors.",recommended:"unopinionated"},fixable:"code",hasSuggestions:!0,messages:{[cR]:"Prefer class field declaration over `this` assignment in constructor for static values.",[c$]:"Encountered same-named class field declaration and `this` assignment in constructor. Replace the class field declaration with the value from `this` assignment."},languages:["js/js"]}},"unicorn/prefer-bigint-literals":{create:e=>{e.on("CallExpression",t=>{if(!e7(t,{name:"BigInt",argumentsLength:1,optional:!1}))return;let[r]=t.arguments,n=function(e){let t,r;if(e1(e)){let t,r=e.raw.slice(1,-1);try{t=BigInt(r)}catch{return}let n=0n===t?"0":r.trim();return n.startsWith("+")&&(n=n.slice(1).trim()),{shouldUseSuggestion:r.includes("+"),text:`${n}n`,bigint:t}}let n=!1,o=!1;for(;"UnaryExpression"===e.type&&e.prefix;)if("+"===e.operator)n=!0,e=e.argument;else{if("-"!==e.operator)return;o=!o,e=e.argument}let{value:a,raw:i}=e;if(Number.isInteger(a)){try{t=BigInt(a)}catch{return}return(e=>{let t=e.raw.replaceAll("_","").toLowerCase();if(t.includes("."))return!1;let{value:r}=e;for(let{prefix:e,base:n}of[{prefix:"0b",base:2},{prefix:"0o",base:8},{prefix:"0x",base:16}])if(t.startsWith(e))return t.slice(2)===r.toString(n);return!t.includes("e")&&t===String(r)})(e)?r=`${i}n`:(r=`${t}n`,n=!0),o&&0n!==t&&(r=`-${r}`,t=-t),{shouldUseSuggestion:n,text:r,bigint:t}}}(r);if(!n)return;let o={node:t,messageId:cP},{shouldUseSuggestion:a,text:i,bigint:s}=n,l=r=>{let n=i;return!eQ(t,e)&&s<0n&&(n=`(${n})`,nW(e.sourceCode.getTokenBefore(t),e,n)&&(n=`;${n}`)),r.replaceText(t,n)};return a||e.sourceCode.getCommentsInside(t).length>0?o.suggest=[{messageId:cL,data:{replacement:i.length<20?`\`${i}\``:"a bigint literal"},fix:l}]:o.fix=l,o})},meta:{type:"suggestion",docs:{description:"Prefer `BigInt` literals over the constructor.",recommended:"unopinionated"},fixable:"code",hasSuggestions:!0,messages:{[cP]:"Prefer using bigint literal over `BigInt(…)`.",[cL]:"Replace with {{replacement}}."},languages:["js/js"]}},"unicorn/prefer-classlist-toggle":{create:e=>{let{sourceCode:t}=e;e.on(["IfStatement","ConditionalExpression"],r=>{let n=[r.consequent,r.alternate].map(e=>{if(e)return"BlockStatement"===e.type&&1===e.body.length&&(e=e.body[0]),"ExpressionStatement"===e.type&&(e=e.expression),"ChainExpression"===e.type&&(e=e.expression),e});if(n.some(e=>!cW(e,["add","remove"])))return;let[o,a]=n;if(o.callee.property.name!==a.callee.property.name&&c_(o,a))return cq(r,function*(n){let i=eZ(o.callee.object.object,e),s=eZ(o.arguments[0],e),l="ConditionalExpression"===r.type,u="remove"===o.callee.property.name,p=r.test,c=cV(p,u,o),d=c?"":cU(p,e,u),m=o.callee.object.optional||a.callee.object.optional||c?.callee.object.optional,f=`${i}${m?"?":""}.classList.toggle(${s}${d?`, ${d}`:""})`;l||(f+=";"),nW(t.getTokenBefore(r),e,f)&&(f=`;${f}`),yield n.replaceText(r,f),l&&(yield oP(n,r,e))})}),e.on("ConditionalExpression",t=>{let r=[t.consequent,t.alternate];if(!(r.every(e=>e1(e)&&("add"===e.value||"remove"===e.value))&&r[0].value!==r[1].value&&"MemberExpression"===t.parent.type&&t.parent.computed&&!t.parent.optional&&t.parent.property===t&&cO(t.parent.object)&&e7(t.parent.parent,{optional:!1,argumentsLength:1})&&t.parent.parent.callee===t.parent))return;let n=t.parent,o=n.parent;return cq(o,function*(r){let a="remove"===t.consequent.value,i=t.test,s=cV(i,a,o)?"":cU(i,e,a);s&&(yield r.insertTextAfter(o.arguments[0],`, ${s}`)),yield oN(r,n,e,".toggle")},t)})},meta:{type:"suggestion",docs:{description:"Prefer using `Element#classList.toggle()` to toggle class names.",recommended:"unopinionated"},fixable:"code",hasSuggestions:!0,messages:{[cN]:"Prefer using `Element#classList.toggle()` to toggle class names.",[cM]:"Replace with `Element#classList.toggle()`."},languages:["js/js"]}},"unicorn/require-module-attributes":{create:e=>{let{sourceCode:t}=e;e.on(["ImportDeclaration","ExportNamedDeclaration","ExportAllDeclaration"],e=>{let{source:r,attributes:n}=e;if(!r||Array.isArray(n)&&n.length>0)return;let o=t.getTokenAfter(r);if(o?.type!=="Keyword"||"with"!==o.value)return;let a=t.getTokenAfter(o),i=t.getTokenAfter(a);return{node:e,loc:{start:t.getLoc(a).start,end:t.getLoc(i).end},messageId:cz,data:{type:"ImportDeclaration"===e.type?"import statement":"export statement"},fix:e=>[o,i,a].map(t=>e.remove(t))}}),e.on("ImportExpression",r=>{let{options:n}=r;if(n?.type!=="ObjectExpression")return;let o=n.properties.find(e=>"Property"===e.type&&!e.method&&!e.shorthand&&!e.computed&&"init"===e.kind&&("Identifier"===e.key.type&&"with"===e.key.name||"Literal"===e.key.type&&"with"===e.key.value)&&ta(e.value)),a=0===n.properties.length||o&&1===n.properties.length?n:o;if(!a)return;let i="Property"===a.type;return{node:o?.value??a,messageId:cz,data:{type:"import expression"},fix:r=>i?function*(e,t,r){let{sourceCode:n}=r;for(let r of n.getTokens(t))yield e.remove(r);let o=n.getTokenAfter(t);if(eu(o))yield e.remove(o);else{let{properties:r}=t.parent;if(r.length>1&&r.at(-1)===t){let r=n.getTokenBefore(t);yield e.remove(r)}}}(r,a,e):[t.getTokenBefore(a,eu),...t.getTokens(a),...eY(a,e)].map(e=>r.remove(e))}})},meta:{type:"suggestion",docs:{description:"Require non-empty module attributes for imports and exports",recommended:"unopinionated"},fixable:"code",messages:{[cz]:"{{type}} with empty attribute list is not allowed."},languages:["js/js"]}},"unicorn/no-immediate-mutation":{create:e=>{for(let t of c3)e.on(["VariableDeclarator","AssignmentExpression"],r=>(function(e,t,{testValue:r,getProblematicNode:n,getProblem:o,getFix:a}){let i,s="AssignmentExpression"===t.type,[l,u]=(s?["left","right"]:["id","init"]).map(e=>t[e]);if(!("Identifier"===l.type&&r(u)))return;let p=t.parent;if(!(s&&"="===t.operator&&"ExpressionStatement"===p.type&&p.expression===t||!s&&"VariableDeclaration"===(i=t.parent).type&&i.declarations.at(-1)===t))return;let c=on(p,e);if(c?.type!=="ExpressionStatement")return;let d="VariableDeclarator"===t.type?e.sourceCode.getDeclaredVariables(t).find(e=>1===e.defs.length&&e.defs[0].name===t.id):ei(e.sourceCode.getScope(t),t.left.name);if(!d)return;let m={context:e,variable:d,variableNode:l,valueNode:u,statement:p,nextExpressionStatement:c,assignType:s?"assignment":"declaration",getFix:a},f=n(m);if(f)return o(f,m)})(e,r,t))},meta:{type:"suggestion",docs:{description:"Disallow immediate mutation after variable assignment.",recommended:!0},fixable:"code",hasSuggestions:!0,messages:{[cK]:"Immediate mutation on {{objectType}} is not allowed.",[cG]:"{{operation}} the elements to the {{assignType}}.",[cJ]:"Move this property to the {{assignType}}.",[cX]:"{{description}} the {{assignType}}.",[cY]:"Move the element to the {{assignType}}.",[cH]:"Move the entry to the {{assignType}}."},languages:["js/js"]}},"unicorn/no-useless-collection-argument":{create:e=>{e.on("NewExpression",t=>{var r;let n;if(!te(t,{names:["Set","Map","WeakSet","WeakMap"],argumentsLength:1}))return;let[o]=t.arguments,a="LogicalExpression"===o.type&&"??"===o.operator,i=a?o.right:o,s=to(r=i)?"empty array":e0(r,"")?"empty string":e9(r)?"`null`":tx(r)?"`undefined`":void 0;if(!s)return;let l=!1;if(a)n=function*(t){let{sourceCode:r}=e,n=i.parent,{left:o}=n,a=eQ(o,e),[,s]=a?eH(o,e):r.getRange(o),[,l]=r.getRange(n);yield t.removeRange([s,l]),(a||"SequenceExpression"!==o.type)&&(yield oT(n,t,e))};else e.sourceCode.getCommentsInside(i).length>0&&(l=!0),n=t=>ok(t,i,e);let u={node:i,messageId:c8,data:{description:s}};return l?u.suggest=[{messageId:c6,fix:n}]:u.fix=n,u})},meta:{type:"suggestion",docs:{description:"Disallow useless values or fallbacks in `Set`, `Map`, `WeakSet`, or `WeakMap`.",recommended:"unopinionated"},fixable:"code",hasSuggestions:!0,messages:{[c8]:"The {{description}} is useless.",[c6]:"Remove the {{description}}"},languages:["js/js"]}},"unicorn/prefer-response-static-json":{create:e=>{e.on("NewExpression",t=>{if(!te(t,{name:"Response",minimumArguments:1}))return;let[r]=t.arguments;if(td(r,{object:"JSON",method:"stringify",argumentsLength:1,optionalCall:!1,optionalMember:!1}))return{node:r.callee,messageId:c9,*fix(n){yield n.insertTextAfter(t.callee,".json"),yield oR(t,e,n);let[o]=r.arguments,a=eH(r,e),i=eH(o,e);yield n.removeRange([a[0],i[0]]),yield n.removeRange([i[1],a[1]]),!eQ(t,e)&&eQ(t.callee,e)&&nW(e.sourceCode.getTokenBefore(t),e,"(")&&(yield n.insertTextBefore(t,";"))}}})},meta:{type:"suggestion",docs:{description:"Prefer `Response.json()` over `new Response(JSON.stringify())`.",recommended:"unopinionated"},fixable:"code",messages:{[c9]:"Prefer using `Response.json(…)` over `JSON.stringify()`."},languages:["js/js"]}},"unicorn/filename-case":{create:e=>{let t=e.physicalFilename;if("<input>"===t||"<text>"===t)return;let r=e.options[0]||{},n=function(e){if(e.case)return[e.case];if(e.cases){let t=Object.keys(e.cases).filter(t=>e.cases[t]);return t.length>0?t:["kebabCase"]}return["kebabCase"]}(r),o=(r.ignore||[]).map(e=>c.isRegExp(e)?e:RegExp(e,"u")),a=!1!==r.multipleFileExtensions,i=!1!==r.checkDirectories,s=n.map(e=>dv[e].fn);e.on(rp,r=>{if("Document"!==r.type||r.parent?.type!=="Program")return(()=>{var r;let l,u,p=(r=e.cwd,""===(l=d.relative(r,d.resolve(r,t)))||".."===l||l.startsWith(`..${d.sep}`)||d.isAbsolute(l)?[d.basename(t)]:l.split(d.sep).filter(e=>"."!==e)),{basename:c,filename:m,middle:f,extension:g}=function(e,{multipleFileExtensions:t}){let r=d.extname(e),n=d.basename(e,r),o={basename:n+r,filename:n,middle:"",extension:r};if(t){let[e]=n.split(".");Object.assign(o,{filename:e,middle:n.slice(e.length)})}return o}(p.at(-1),{multipleFileExtensions:a});if(p.some(e=>o.some(t=>t.test(e))))return;if(i)for(let e of p.slice(0,-1)){let t=function(e,t,r){let n,{leading:o,words:a}=dw(e);if(e.startsWith("$")||dC(a,r))return;let i=dA(a,r,{leading:o,trailing:""});return{loc:{column:0,line:1},messageId:dm,data:{directory:e,chosenCases:dk(t),renamedDirectories:(n=i.map(e=>`\`${e}\``),dh.format(n))}}}(e,n,s);if(t)return t}if(dy.has(c))return;let{leading:y,words:h}=dw(m);if(m.startsWith("$")||dC(h,s))return g!==g.toLowerCase()?{loc:{column:0,line:1},messageId:df,data:{filename:m+f+g.toLowerCase(),extension:g}}:void 0;let x=dA(h,s,{leading:y,trailing:f+g.toLowerCase()});return{loc:{column:0,line:1},messageId:dd,data:{chosenCases:dk(n),renamedFilenames:(u=x.map(e=>`\`${e}\``),dh.format(u))}}})()})},meta:{type:"suggestion",docs:{description:"Enforce a case style for filenames and directory names.",recommended:!0},schema:dI,defaultOptions:[],messages:{[dd]:"Filename is not in {{chosenCases}}. Rename it to {{renamedFilenames}}.",[dm]:"Directory name `{{directory}}` is not in {{chosenCases}}. Rename it to {{renamedDirectories}}.",[df]:"File extension `{{extension}}` is not in lowercase. Rename it to `{{filename}}`."},languages:["*"]}},"unicorn/consistent-template-literal-escape":{create:e=>{e.on("TemplateElement",t=>{if(th(t.parent))return;let{raw:r}=t.value,n=r.replaceAll(/(?<=(?:^|[^\\])(?:\\\\)*)\\?\$\\{/g,"\\${");if(r!==n)return{node:t,messageId:dj,fix:r=>o_(t,n,e,r)}})},meta:{type:"suggestion",docs:{description:"Enforce consistent style for escaping `${` in template literals.",recommended:!0},fixable:"code",messages:{[dj]:"Use `\\${` instead of `$\\{` to escape in template literals."},languages:["js/js"]}},"unicorn/no-useless-iterator-to-array":{create:e=>{e.on("NewExpression",t=>{if(!(te(t,{names:["Map","WeakMap","Set","WeakSet"],argumentsLength:1})||te(t,{names:rE,minimumArguments:1}))||!dq(t.arguments[0]))return;let r=t.arguments[0];return{node:r.callee.property,messageId:dF,data:{description:`new ${t.callee.name}(…)`},fix:t=>oO(t,r,e)}}),e.on("CallExpression",t=>{if((td(t,{objects:["Array",...rE],method:"from",minimumArguments:1,optionalCall:!1,optionalMember:!1})||td(t,{object:"Object",method:"fromEntries",minimumArguments:1,optionalCall:!1,optionalMember:!1}))&&dq(t.arguments[0])){let r=t.arguments[0];return{node:r.callee.property,messageId:dF,data:{description:`${t.callee.object.name}.${t.callee.property.name}(…)`},fix:t=>oO(t,r,e)}}if(td(t,{object:"Promise",methods:["all","allSettled","any","race"],argumentsLength:1,optionalCall:!1,optionalMember:!1})&&dq(t.arguments[0])){let r=t.arguments[0];return{node:r.callee.property,messageId:dF,data:{description:`${t.callee.object.name}.${t.callee.property.name}(…)`},suggest:[{messageId:dL,fix:t=>oO(t,r,e)}]}}if((td(t,{methods:dM,maximumArguments:1,optionalCall:!1,optionalMember:!1})||td(t,{method:dO,argumentsLength:2,optionalCall:!1,optionalMember:!1}))&&dq(t.callee.object)){let r=t.arguments[0],n=t.callee.property.name===dO;if(r&&("ArrowFunctionExpression"===r.type||"FunctionExpression"===r.type)&&r.params.length>(n?3:2))return;let o=t.callee.object;return{node:o.callee.property,messageId:dP,data:{method:t.callee.property.name},suggest:[{messageId:dN,data:{method:t.callee.property.name},fix:t=>oO(t,o,e)}]}}}),e.on("ForOfStatement",t=>{if(dq(t.right))return{node:t.right.callee.property,messageId:dB,fix:r=>oO(r,t.right,e)}}),e.on("YieldExpression",t=>{if(t.delegate&&dq(t.argument))return{node:t.argument.callee.property,messageId:dR,fix:r=>oO(r,t.argument,e)}}),e.on("SpreadElement",t=>{if(!dq(t.argument))return;let{parent:r}=t;if("ArrayExpression"===r.type||"CallExpression"===r.type||"NewExpression"===r.type)return{node:t.argument.callee.property,messageId:d$,fix:r=>oO(r,t.argument,e)}})},meta:{type:"suggestion",docs:{description:"Disallow unnecessary `.toArray()` on iterators.",recommended:"unopinionated"},fixable:"code",hasSuggestions:!0,messages:{[dF]:"`{{description}}` accepts an iterable, `.toArray()` is unnecessary.",[dB]:"`for…of` can iterate over an iterable, `.toArray()` is unnecessary.",[dR]:"`yield*` can delegate to an iterable, `.toArray()` is unnecessary.",[d$]:"Spread works on iterables, `.toArray()` is unnecessary.",[dP]:"`Iterator` has a `.{{method}}()` method, `.toArray()` is unnecessary.",[dL]:"Remove `.toArray()`.",[dN]:"Remove `.toArray()` and use `Iterator#{{method}}()`."},languages:["js/js"]}},"unicorn/prefer-simple-condition-first":{create:e=>{let{sourceCode:t}=e;e.on("LogicalExpression",r=>{if("&&"!==r.operator&&"||"!==r.operator||!dV(r.right)||dV(r.left)||"ConditionalExpression"!==r.left.type||!function e(t){let{parent:r}=t;return!!r&&("IfStatement"===r.type&&r.test===t||"WhileStatement"===r.type&&r.test===t||"DoWhileStatement"===r.type&&r.test===t||"ForStatement"===r.type&&r.test===t||"ConditionalExpression"===r.type&&r.test===t||"UnaryExpression"===r.type&&"!"===r.operator||"LogicalExpression"===r.type&&e(r))}(r)||function e(t){if(!t||"object"!=typeof t)return!1;if(dz.has(t.type)||"MemberExpression"===t.type||"BinaryExpression"===t.type&&("in"===t.operator||"instanceof"===t.operator))return!0;for(let[r,n]of Object.entries(t))if("parent"!==r){if(Array.isArray(n)){if(n.some(t=>e(t)))return!0}else if(n&&"string"==typeof n.type&&e(n))return!0}return!1}(r.left)||function e(t){if(!t||"object"!=typeof t)return!1;if("CallExpression"===t.type||"NewExpression"===t.type)return!0;for(let[r,n]of Object.entries(t))if("parent"!==r){if(Array.isArray(n)){if(n.some(t=>e(t)))return!0}else if(n&&"string"==typeof n.type&&e(n))return!0}return!1}(r.left))return;let n=dK(r.right,e,{operator:r.operator,property:"left"}),o=dK(r.left,e,{operator:r.operator,property:"right"}),a=t.getTokensBetween(r.left,r.right,{includeComments:!0}).some(e=>eg(e))?void 0:t=>t.replaceTextRange([eH(r.left,e)[0],eH(r.right,e)[1]],`${n} ${r.operator} ${o}`);return"LogicalExpression"===r.left.type&&r.left.operator===r.operator?{node:r,loc:t.getLoc(r.right),messageId:dU,data:{operator:r.operator},...a&&{suggest:[{messageId:dW,fix:a}]}}:{node:r,loc:t.getLoc(r.right),messageId:dU,data:{operator:r.operator},...a&&{fix:a}}})},meta:{type:"suggestion",docs:{description:"Prefer simple conditions first in logical expressions.",recommended:"unopinionated"},fixable:"code",hasSuggestions:!0,messages:{[dU]:"Prefer simple condition first in `{{operator}}` expression.",[dW]:"Swap conditions."},languages:["js/js"]}},"unicorn/switch-case-break-position":{create:e=>{let{sourceCode:t}=e;e.on("SwitchCase",r=>{let{consequent:n}=r;if(n.length<2)return;let o=n.at(-1);if(!dJ.has(o.type))return;let a=n.slice(0,-1);if(1!==a.length||"BlockStatement"!==a[0].type)return;let i=a[0];if(0===i.body.length)return;let s=function(e){switch(e.type){case"BreakStatement":return"break";case"ReturnStatement":return"return";case"ContinueStatement":return"continue";case"ThrowStatement":return"throw"}}(o);return{node:o,loc:t.getLoc(o),messageId:dG,data:{keyword:s},..."ReturnStatement"!==o.type&&"ThrowStatement"!==o.type&&{*fix(r){let n=t.getLastToken(i);if(t.getTokensBetween(n,o,{includeComments:!0}).some(e=>eg(e)))return;let a=t.getLoc(i);if(a.start.line===a.end.line||t7(e,o))return;let s=i.body.at(-1),l=t.getText(o),u=t8(s,e),p=t.getTokenBefore(n,{includeComments:!0});yield r.insertTextAfter(p,`
|
|
29
29
|
${u}${l}`);let c=t.getRange(n)[1],d=t.getRange(o)[1];yield r.removeRange([c,d])}}}})},meta:{type:"layout",docs:{description:"Enforce consistent `break`/`return`/`continue`/`throw` position in `case` clauses.",recommended:!0},fixable:"code",messages:{[dG]:"Move `{{keyword}}` inside the block statement."},languages:["js/js"]}},"unicorn/better-dom-traversing":{create:e=>{e.on("MemberExpression",t=>{let r,n=(e=>{if(d6(e)){if(d8(e.object,"childNodes"))return"childNodes";if(d8(e.object,"children"))return"children"}})(t);if(!n||nT(t.object.object)||"children"===n&&d8(r=t.object,"children")&&("Identifier"===r.object.type&&"props"===r.object.name||tc(r.object,{property:"props",optional:!1,computed:!1}))||t.parent?.type==="MemberExpression"&&t.parent.object===t&&d8(t.parent,"children")&&d6(t.parent.parent))return;let o=t.property.value;return"childNodes"===n&&0===o?{node:t,messageId:dX,suggest:d5(t,"firstChild",d0,e)}:"children"===n&&0===o?{node:t,messageId:dY,suggest:d5(t,"firstElementChild",d1,e)}:"children"===n?{node:t,messageId:dH}:void 0}),e.on("MemberExpression",e=>{if(!(!d4(e)||!d4(e.object)||!(!d4(e.parent)||e.parent.object!==e)||nT((e=>{for(;d4(e);)e=e.object;return e})(e))))return{node:e,messageId:dZ}}),e.on("CallExpression",t=>{if(!me(t)||t.parent?.type==="MemberExpression"&&t.parent.object===t&&t.parent.parent?.callee===t.parent&&me(t.parent.parent)&&d7(t.parent.parent.arguments[0])||(e=>{for(;e.parent?.type==="MemberExpression"&&e.parent.object===e||e.parent?.type==="CallExpression"&&e.parent.callee===e;)e=e.parent;return e.parent?.type==="ChainExpression"})(t))return;let r=(e=>{let t=[];for(;me(e);){let[r]=e.arguments;if(!d7(r))break;t.push(e),e=e.callee.object}if(t.length<2||"ChainExpression"===e.type||nT(e))return;let r=[];for(let e of t)r.unshift(e3(e.arguments[0]));return{root:e,selectors:r,quoteNode:t.at(-1).arguments[0]}})(t);if(r)return{node:t,messageId:dQ,suggest:((e,t,r)=>{let n,o,{sourceCode:a}=r;if(d9(e,a)||!t.selectors.every(e=>!e.includes(",")&&!e.includes(":scope")))return;let i=eZ(t.root,r),s=`${"Identifier"===(n=t.root).type&&"document"===n.name||"MemberExpression"===n.type&&!n.computed&&"Identifier"===n.object.type&&["globalThis","window"].includes(n.object.name)&&"Identifier"===n.property.type&&"document"===n.property.name?"":":scope "}${t.selectors.join(" ")}`,l=`${i}.querySelector(${tF(s,"Literal"===(o=t.quoteNode).type&&o.raw.startsWith('"')?'"':"'")})`;return[{messageId:d2,fix:t=>t.replaceText(e,l)}]})(t,r,e)}})},meta:{type:"suggestion",docs:{description:"Prefer better DOM traversal APIs.",recommended:"unopinionated"},hasSuggestions:!0,messages:{[dX]:"Prefer `.firstChild` over `.childNodes[0]`.",[dY]:"Prefer `.firstElementChild` over `.children[0]`.",[dH]:"Consider `.querySelector()` over positional child traversal.",[dZ]:"Consider `.closest()` over chaining `.parentElement`.",[dQ]:"Consider merging chained `.querySelector()` calls.",[d0]:"Switch to `.firstChild`.",[d1]:"Switch to `.firstElementChild`.",[d2]:"Merge the `.querySelector()` calls."},languages:["js/js"]}},"unicorn/consistent-compound-words":{create:e=>{let t=(({checkProperties:e=!1,checkVariables:t=!0,checkDefaultAndNamespaceImports:r="internal",checkShorthandImports:n="internal",checkShorthandProperties:o=!1,extendDefaultReplacements:a=!0,replacements:i={},allowList:s={}}={})=>{let l=new Map(Object.entries(a?{...ms,...i}:i).filter(([,e])=>!1!==e));return{checkProperties:e,checkVariables:t,checkDefaultAndNamespaceImports:r,checkShorthandImports:n,checkShorthandProperties:o,replacements:l,replacementRegExp:l.size>0?(e=>{let t=[],r=[];for(let n of e.keys())t.push(mu(n)),r.push(mu(oo(n)));return RegExp(`(?:^(?:${t.join("|")})|(?:${r.join("|")}))${mp}`,"gv")})(l):void 0,allowList:new Set(Object.keys(s))}})(e.options[0]),r=new WeakMap,n=new WeakMap,o=(e,t)=>t.every(t=>{let r=n.get(t);return!r||!r.has(e)}),a=e=>{if((e=>{if(1!==e.defs.length)return!1;let[t]=e.defs;return"ClassName"===t.type})(e)){if("class"===e.scope.type){let[t]=e.defs,n=r.get(t.name);return n?i({name:e.name,scope:e.scope,defs:e.defs,identifiers:e.identifiers,references:[...e.references,...n.references]}):i(e)}let[t]=e.defs;return void r.set(t.name,e)}return i(e)},i=r=>{var a;if(0===r.defs.length)return;let i=mc(r.name,t);if(!i)return;let[s]=r.defs;if(!(!("ImportDefaultSpecifier"===(a=s.name).parent.type&&a.parent.local===a||"ImportNamespaceSpecifier"===a.parent.type&&a.parent.local===a||"ImportSpecifier"===a.parent.type&&a.parent.local===a&&"Identifier"===a.parent.imported.type&&"default"===a.parent.imported.name||"VariableDeclarator"===a.parent.type&&a.parent.id===a&&tf(a.parent.init))||t.checkDefaultAndNamespaceImports&&("internal"!==t.checkDefaultAndNamespaceImports||mn(s)))||!(!nP(s.name,e)||t.checkShorthandImports&&("internal"!==t.checkShorthandImports||mn(s)))||!t.checkShorthandProperties&&nM(s.name))return;let l=[...r.references.map(e=>e.from),r.scope],u=mi(i)?tG(i,l,o):void 0,p=md(s.name,u??i);if(u&&rd(r).every(e=>!("VariableDeclarator"===e.parent.type&&e.parent.id===e?"VariableDeclaration"===e.parent.parent.type&&"ExportNamedDeclaration"===e.parent.parent.parent.type:!!mt.has(e.parent.type)&&e.parent.id===e&&"ExportNamedDeclaration"===e.parent.parent.type)&&"JSXIdentifier"!==e.type)&&r.references.every(e=>!e.vueUsedInTemplate)){for(let e of l)n.has(e)||n.set(e,new Set),n.get(e).add(u);p.suggest=[{messageId:ma,data:{replacement:u},fix:t=>oW(r,u,e,t)}]}e.report(p)},s=e=>{for(let t of e.variables)a(t)},l=r=>{if(!t.checkProperties||"__proto__"===r.name)return;let n=mc(r.name,t);if(!n||"ExportSpecifier"===r.parent.type||(t.checkVariables||("TSParameterProperty"===r.parent.type?r.parent.parameter!==r:"AssignmentPattern"!==r.parent.type||r.parent.left!==r||"TSParameterProperty"!==r.parent.parent.type||r.parent.parent.parameter!==r.parent))&&!("MemberExpression"===r.parent.type&&r.parent.property===r&&!r.parent.computed&&("AssignmentExpression"===r.parent.parent.type&&r.parent.parent.left===r.parent||"UpdateExpression"===r.parent.parent.type&&r.parent.parent.argument===r.parent)||"Property"===r.parent.type&&r.parent.key===r&&!r.parent.computed&&!r.parent.shorthand&&"ObjectExpression"===r.parent.parent.type||"ExportSpecifier"===r.parent.type&&r.parent.exported===r&&r.parent.local!==r||mr.has(r.parent.type)&&r.parent.key===r&&!r.parent.computed))return;let o=md(r,n);e.report(o)};e.on("Identifier",l),e.on("PrivateIdentifier",l),e.on("Program:exit",r=>{if(t.checkVariables)for(let t of tM(e.sourceCode.getScope(r)))s(t)})},meta:{type:"suggestion",docs:{description:"Enforce consistent spelling of compound words in identifiers.",recommended:"unopinionated"},hasSuggestions:!0,schema:mm,defaultOptions:[{}],messages:{[mo]:"Prefer `{{replacement}}` over `{{name}}`.",[ma]:"Rename to `{{replacement}}`."},languages:["js/js"]}},"unicorn/no-blob-to-file":{create:e=>{e.on("VariableDeclarator",t=>(function(e,t){let{sourceCode:r}=t,{id:n,init:o}=e;if("Identifier"!==n.type||"VariableDeclaration"!==e.parent.type||"const"!==e.parent.kind||1!==e.parent.declarations.length||"Program"!==e.parent.parent.type&&"BlockStatement"!==e.parent.parent.type)return;let a=function(e,t){if(!te(e,{name:"File",minimumArguments:2,maximumArguments:2})||!my(e.callee,t))return;let[r]=e.arguments,[,n]=e.arguments;if("ArrayExpression"!==r.type||1!==r.elements.length||r.elements[0]?.type==="SpreadElement"||void 0===e3(n))return;let[o]=r.elements;if(function(e,t,r){let n=mh(e,r);if(!n||r.sourceCode.getRange(n)[0]>r.sourceCode.getRange(t)[0])return!1;let o=n.init;return(te(o,{name:"Blob",maximumArguments:1})||te(o,{name:"File",minimumArguments:2,maximumArguments:2}))&&my(o.callee,r)}(o,e,t))return o}(o,t);if(!a)return;let i=ei(r.getScope(n),n);if(!i)return;let s=rd(i).filter(e=>e!==n);if(1!==s.length)return;let[l]=s,u=function(e,t){let r,{parent:n}=e;return td(n,{object:"URL",method:"createObjectURL",argumentsLength:1,optionalCall:!1,optionalMember:!1})&&n.arguments[0]===e&&my(n.callee.object,t)?{call:n,kind:"blobArgument"}:td(n,{methods:["append","set"],minimumArguments:2,maximumArguments:3,optionalCall:!1,optionalMember:!1})&&n.arguments[1]===e&&(r=mh(n.callee.object,t)?.init,te(r,{name:"FormData",argumentsLength:0})&&my(r.callee,t))?{call:n,kind:"formData"}:void 0}(l,t);if(!u)return;let p=function(e){let[,t]=e.arguments;return t}(o);if(!(!function(e,t,r){if("Identifier"!==e.type)return!0;let{sourceCode:n}=r;return ei(n.getScope(e),e)===ei(n.getScope(t),e)}(a,l,t)||function(e,t){let{sourceCode:r}=t;return r.getCommentsInside(e).length>0||r.getCommentsBefore(e).some(t=>r.getLoc(t).end.line===r.getLoc(e).start.line||r.getLoc(t).end.line===r.getLoc(e).start.line-1)||t7(t,e)}(e.parent,t))&&("formData"!==u.kind||2!==u.call.arguments.length||p))return{node:o,messageId:mf,suggest:[{messageId:mg,*fix(n){yield oq(e.parent,t,n),yield n.replaceText(l,r.getText(a)),"formData"===u.kind&&2===u.call.arguments.length&&(yield n.insertTextAfter(l,`, ${r.getText(p)}`))}}]}})(t,e))},meta:{type:"suggestion",docs:{description:"Disallow unnecessary `Blob` to `File` conversion.",recommended:"unopinionated"},hasSuggestions:!0,messages:{[mf]:"Use the original `Blob` instead of converting it to a `File`.",[mg]:"Replace the `File` with the original `Blob`."},languages:["js/js"]}},"unicorn/no-canvas-to-image":{create:e=>{let{sourceCode:t}=e;e.on("CallExpression",e=>{var r,n,o;if(!td(e,{method:"drawImage",minimumArguments:1,optionalCall:!1,optionalMember:!1}))return;let[a]=e.arguments;if("SpreadElement"!==a.type&&(r=mE(a,t),r?.type==="CallExpression"&&!r.optional&&"Identifier"===r.callee.type&&"loadImage"===r.callee.name&&r.arguments.length>0&&"SpreadElement"!==r.arguments[0].type&&td(n=r.arguments[0],{method:"toDataURL",optionalCall:!1,optionalMember:!1})&&("Identifier"===(o=n.callee.object).type?mD(o.name):"MemberExpression"===o.type&&!o.computed&&"Identifier"===o.property.type&&mD(o.property.name))))return{node:a,messageId:mx}}),e.on("CallExpression",e=>{if(!td(e,{method:"putImageData",minimumArguments:1,optionalCall:!1,optionalMember:!1}))return;let[r]=e.arguments;if("SpreadElement"!==r.type&&td(mE(r,t),{method:"getImageData",optionalCall:!1,optionalMember:!1}))return{node:r,messageId:mx}})},meta:{type:"suggestion",docs:{description:"Prefer drawing canvases directly instead of converting them to images.",recommended:"unopinionated"},messages:{[mx]:"Prefer drawing the canvas directly with `drawImage()`."},languages:["js/js"]}},"unicorn/no-confusing-array-splice":{create:e=>{e.on("CallExpression",t=>{if(!td(t,{methods:["splice","toSpliced"],argumentsLength:3,optionalCall:!1,optionalMember:!1}))return;let r=function([e,t]){let r=function(e){let t=n1(e);if("number"==typeof t)return Math.max(Math.trunc(t),0)}(t);return 1===r?mS:-1===Math.trunc(n1(e))&&0===r?mv:void 0}(t.arguments);if(!r)return;let n={node:t.callee.property,messageId:r,data:{method:t.callee.property.name}},o=function(e,t,r){let{sourceCode:n}=r,{object:o,property:a}=e.callee,[i,,s]=e.arguments,l=a.name,u=eZ(o,r),p=n.getText(i),c=n.getText(s);if(t===mS){if(mw(e,n))return;if("toSpliced"===l){var d,m;if(0>Math.trunc(n1(i))||(d=i,m=o,d=ry(d),m=ry(m),"MemberExpression"===d.type&&!d.optional&&!d.computed&&"Identifier"===d.property.type&&"length"===d.property.name&&ly(d.object,m)))return;return{messageId:mC,fix:t=>t.replaceText(e,`${u}.with(${p}, ${c})`)}}return"ExpressionStatement"===e.parent.type&&mT(o)&&(n1(i)??0)>=0?{messageId:mC,fix:t=>t.replaceText(e,`${u}[${p}] = ${c}`)}:void 0}if(t===mv&&mT(o)&&!mw(i,n))return{messageId:mA,fix:e=>e.replaceText(i,`Math.max(${u}.length - 1, 0)`)}}(t,r,e);return o&&(n.suggest=[o]),n})},meta:{type:"suggestion",docs:{description:"Disallow confusing uses of `Array#{splice,toSpliced}()`.",recommended:!0},hasSuggestions:!0,messages:{[mS]:"Prefer a direct element replacement instead of `{{method}}()`.",[mv]:"Avoid using `{{method}}()` to insert at `-1`.",[mC]:"Use direct element replacement.",[mA]:"Resolve the insertion index explicitly."},languages:["js/js"]}},"unicorn/no-duplicate-set-values":{create:e=>{let{sourceCode:t}=e;e.on("NewExpression",r=>{if(!te(r,{name:"Set",argumentsLength:1}))return;let[n]=r.arguments;if("ArrayExpression"===n.type)return t3(n.elements,e).map(e=>({node:e??n,messageId:mk,data:{value:e?t.getText(e):"undefined"}}))})},meta:{type:"suggestion",docs:{description:"Disallow duplicate values in `Set` constructor array literals.",recommended:!0},messages:{[mk]:"Remove duplicate value `{{value}}` from the Set."},languages:["js/js"]}},"unicorn/no-incorrect-query-selector":{create:e=>{let{sourceCode:t}=e;e.on("MemberExpression",r=>{if(!mL(r)||mM(r))return;let n=r.object;if(!mO(r,n,t,e))return mW(r,n,e)}),e.on("CallExpression",r=>{let n;if(mN(r)){if(mM(r))return;let n=r.callee.object;if(mO(r,n,t,e))return;return mW(r,n,e)}let o=mU(r,e);if(o)return o;if(mP(r)&&!(mL(n=r.parent)||mN(n)||"MemberExpression"===r.parent.type&&r.parent.object===r&&mN(r.parent.parent))){let e;if(e=e3(r.arguments[0]),/^#[\-A-Z_a-z][\w\-]*$/v.test(e))return{node:r.callee.property,messageId:mj}}}),e.on("BinaryExpression",r=>((e,t)=>{let{sourceCode:r}=t;if(mV(e,mP,r))return{node:e,messageId:mB}})(r,e)??((e,t)=>{let r=mV(e,m$,t);if(r&&("==="===e.operator||"!=="===e.operator)&&tx(r.value))return{node:e,messageId:mR}})(r,t)),e.on("Identifier",t=>mU(t,e))},meta:{type:"suggestion",docs:{description:"Disallow incorrect `querySelector()` and `querySelectorAll()` usage.",recommended:!0},fixable:"code",schema:[],messages:{[mI]:"Prefer `.querySelector()` when only the first match is used.",[mj]:"Prefer `.querySelector()` for a simple ID selector.",[mF]:"Check `.length` instead of the `NodeList` object itself.",[mB]:"Check `.length` instead of comparing the `NodeList` object with `null` or `undefined`.",[mR]:"Compare the result of `.querySelector()` with `null` instead of `undefined`."},languages:["js/js"]}},"unicorn/no-invalid-file-input-accept":{create:e=>{e.on("JSXOpeningElement",t=>{if("input"!==mQ(t.name))return;let r=((e,t)=>{if(t?.value){if(e1(t.value))return t.value.value;if("JSXExpressionContainer"===t.value.type)return m1(e,t.value.expression)}})(e,m0(t,"type"));if(r?.toLowerCase()!=="file")return;let n=m0(t,"accept");if(!n)return;let o=((e,t)=>{if(!t.value)return{node:t,missing:!0};if(e1(t.value))return{node:t.value,value:t.value.value,fixable:!0};if("JSXExpressionContainer"!==t.value.type)return{node:t.value,dynamic:!0};let r=m1(e,t.value.expression);return void 0===r?{node:t.value,dynamic:!0}:{node:t.value,value:r,fixable:!1}})(e,n);return m4({valueInfo:o,fix:t=>r=>{let n;return n=o.node,r.replaceTextRange([e.sourceCode.getRange(n)[0]+1,e.sourceCode.getRange(n)[1]-1],t)}})}),e.on("Tag",t=>{if("input"!==t.name.toLowerCase())return;let r=m5(e,t,"type")?.value;if(r?.toLowerCase()!=="file")return;let n=((e,t,r)=>{let n=m5(e,t,r);if(!n)return;let o=t.attributes.find(e=>"Attribute"===e.type&&e.key?.value?.toLowerCase()===r);return n.missing?{node:o??t,missing:!0}:o?.value?.parts?.length>0?{node:o.value,dynamic:!0}:mY.test(n.value)?void 0:{node:o?.value??t,value:n.value,fixable:!0,valueRange:n.valueRange,isReplacementFixable:e=>n.isQuoted||!/\s/v.test(e)}})(e,t,"accept");if(n)return m4({valueInfo:n,fix:e=>t=>t.replaceTextRange(n.valueRange,e)})})},meta:{type:"problem",docs:{description:"Disallow invalid `accept` values on file inputs.",recommended:!1},fixable:"code",messages:{[mz]:"Invalid file input `accept` value: {{reason}}",[mK]:"The file input `accept` value must be static.",[mG]:"Prefer `{{replacement}}` as the file input `accept` value."},languages:["js/js","html/html"]}},"unicorn/no-late-current-target-access":{create:e=>{let{sourceCode:t}=e,r=new Set,n=e=>{let t=fr(e);t&&r.add(t)},o=(e,t)=>{switch(e.type){case"ForStatement":return[e.test,e.update,e.body].includes(t);case"ForInStatement":case"ForOfStatement":return t!==e.right;case"DoWhileStatement":case"WhileStatement":return!0;default:return!1}};e.onExit("AwaitExpression",n),e.onExit("YieldExpression",n),e.onExit("ForOfStatement",e=>{e.await&&n(e)}),e.on("MemberExpression",e=>{if("Identifier"!==e.object.type||!tc(e,{property:"currentTarget"})||!ft.test(e.object.name))return;let n=ei(t.getScope(e.object),e.object),a=n?.defs.find(({type:e})=>"Parameter"===e);if(!a)return;let i=a.node,s=fr(e)!==i;if(s||r.has(i)||((e,r)=>{for(let n=e,a=e.parent;a&&a!==r;n=a,a=a.parent)if(o(a,n)&&tk(a,t.visitorKeys))return!0;return!1})(e,i))return{node:e,messageId:s?fe:m7,data:{name:e.object.name}}})},meta:{type:"problem",docs:{description:"Disallow accessing `event.currentTarget` after the synchronous event dispatch has finished.",recommended:!0},messages:{[m7]:"`{{name}}.currentTarget` is `null` after the handler suspends. It is only set during synchronous event dispatch; save it to a variable beforehand.",[fe]:"`{{name}}.currentTarget` is `null` inside this nested function. It is only set during synchronous event dispatch; save it to a variable in the outer function."},languages:["js/js"]}},"unicorn/no-unnecessary-nested-ternary":{create:e=>{let{sourceCode:t}=e;e.on("ConditionalExpression",r=>{let{test:n,consequent:o,alternate:a}=r;return"ConditionalExpression"===o.type&&fo(o.alternate,a,t)?fs(e,r,{left:n,operator:"&&",right:o.test,consequent:o.consequent,alternate:o.alternate}):"ConditionalExpression"===a.type&&fo(o,a.consequent,t)?fs(e,r,{left:n,operator:"||",right:a.test,consequent:o,alternate:a.alternate}):void 0})},meta:{type:"suggestion",docs:{description:"Disallow unnecessary nested ternary expressions.",recommended:"unopinionated"},fixable:"code",schema:[],messages:{[fn]:"Do not use unnecessary nested ternary expressions."},languages:["js/js"]}},"unicorn/no-unused-array-method-return":{create:e=>{e.on("CallExpression",t=>{var r,n;let o,a,i="MemberExpression"===t.callee.type?eI(r=t.callee,e.sourceCode.getScope(r)):void 0;if(!(!fu.has(i)||!(e=>{for(;;){if(nO(e))return!0;let{parent:t}=e;if("ForStatement"===t.type&&(t.init===e||t.update===e))return!0;if("ChainExpression"!==t.type&&"AwaitExpression"!==t.type&&"TSAsExpression"!==t.type&&"TSTypeAssertion"!==t.type&&"TSNonNullExpression"!==t.type&&"TSSatisfiesExpression"!==t.type)return!1;e=t}})(t)||(n=function e(t,r,n=new Set){if(!t||t===fc||n.has(t))return t;if(n.add(t),"Identifier"===t.type){let o=function(e,t){let r=function(e,t){if("Identifier"===e.type)return ei(t.sourceCode.getScope(e),e)}(e,t);if(!r)return;if(1!==r.defs.length||function(e,t,r){if(!e)return!1;let[n]=r.sourceCode.getRange(t);return e.references.some(e=>!e.init&&e.isWrite()&&r.sourceCode.getRange(e.identifier)[0]<n)}(r,e,t))return fc;let[n]=r.defs;return"Variable"===n.type&&"VariableDeclarator"===n.node.type&&"Identifier"===n.node.id.type&&n.node.id.name===e.name&&n.node.init&&"VariableDeclaration"===n.parent.type?n.node.init:fc}(t,r);return o===fc?o:void 0===o?t:e(o,r,n)}if(["ChainExpression","TSNonNullExpression","TSSatisfiesExpression"].includes(t.type))return e(t.expression,r,n);if("MemberExpression"===t.type)return fc;if("TSAsExpression"===t.type||"TSTypeAssertion"===t.type){let{typeAnnotation:e}=t;return"TSTypeOperator"===e.type&&"readonly"===e.operator&&(e=e.typeAnnotation),"TSArrayType"===e.type||"TSTypeReference"===e.type&&"Identifier"===e.typeName.type&&("Array"===e.typeName.name||"ReadonlyArray"===e.typeName.name)?t:fc}return t}(n=t.callee.object,e))===fc||((e,t)=>fm(e,"undefined",t)||"ObjectExpression"===e.type||"Literal"===e.type||"TemplateLiteral"===e.type||"ArrowFunctionExpression"===e.type||"FunctionExpression"===e.type||"ClassExpression"===e.type||"NewExpression"===e.type&&"Identifier"===e.callee.type&&!fm(e.callee,"Array",t)||"CallExpression"===e.type&&"Identifier"===e.callee.type&&fd.has(e.callee.name)&&t.sourceCode.isGlobalReference(e.callee))(n,e)||"Identifier"===(o=n).type&&fp.test(o.name)&&!("ArrayExpression"===(a=n).type||("CallExpression"===a.type||"NewExpression"===a.type)&&fm(a.callee,"Array",e))))return{node:t.callee.property,messageId:fl,data:{method:i}}})},meta:{type:"suggestion",docs:{description:"Disallow ignoring the return value of selected array methods.",recommended:"unopinionated"},messages:{[fl]:"Do not ignore the return value of `.{{method}}(…)`."},languages:["js/js"]}},"unicorn/prefer-array-last-methods":{create:e=>{let{sourceCode:t}=e;e.on("CallExpression",r=>{if(!td(r,{methods:fy.keys().toArray(),optionalCall:!1,optionalMember:!1}))return;let n=r.callee.object;if(!td(n,{methods:fh,argumentsLength:0,optionalCall:!1,optionalMember:!1}))return;let o=r.callee.property.name,a=fy.get(o),i={method:o,replacement:a,reversingMethod:n.callee.property.name},s={node:r.callee.property,messageId:ff,data:i};return 0===t.getCommentsInside(r).length&&(s.suggest=[{messageId:fg,data:i,*fix(t){yield t.replaceText(r.callee.property,a),yield oO(t,n,e)}}]),s})},meta:{type:"suggestion",docs:{description:"Prefer last-oriented array methods over `Array#reverse()` or `Array#toReversed()` followed by a method.",recommended:"unopinionated"},hasSuggestions:!0,messages:{[ff]:"Prefer `Array#{{replacement}}()` over `Array#{{reversingMethod}}().{{method}}()`.",[fg]:"Replace `.{{reversingMethod}}().{{method}}()` with `.{{replacement}}()`."},languages:["js/js"]}},"unicorn/prefer-math-abs":{create:e=>{e.on("ConditionalExpression",t=>{let r=function(e,t){let r=function(e,t){if(!("BinaryExpression"!==e.type||!fb.has(e.operator)||fA(e.left,t)||fA(e.right,t))){if(e0(e.right,0))return{value:e.left,operator:e.operator};if(e0(e.left,0))return{value:e.right,operator:fE[e.operator]}}}(e.test,t);if(!r)return;let{value:n,operator:o}=r,{consequent:a,alternate:i}=e;if(("<"===o||"<="===o)&&fT(a,n)&&tQ(i,n)||(">"===o||">="===o)&&tQ(a,n)&&fT(i,n))return n}(t,e);if(!r)return;let n=fF(r)?function*(n){yield oP(n,t,e),yield n.replaceText(t,`Math.abs(${fI(r,e)})`)}:void 0;return fj(t,e,n)}),e.on("LogicalExpression",t=>{let r=function(e,t){if("||"!==e.operator)return;let r=fw(e.left,t),n=fk(e.right,t);if(r&&n&&tQ(r.value,n.value)&&fD[r.operator]===n.operator&&fT(n.negativeThreshold,r.threshold))return{value:r.value,threshold:r.threshold,operator:r.operator};let o=fw(e.right,t),a=fk(e.left,t);if(o&&a&&tQ(o.value,a.value)&&fD[o.operator]===a.operator&&fT(a.negativeThreshold,o.threshold))return{value:o.value,threshold:o.threshold,operator:o.operator}}(t,e);if(!r)return;let{value:n,threshold:o,operator:a}=r,i=fF(n)&&fF(o)?function*(r){yield oP(r,t,e),yield r.replaceText(t,`Math.abs(${fI(n,e)}) ${a} ${eZ(o,e)}`)}:void 0;return fj(t,e,i)})},meta:{type:"suggestion",docs:{description:"Prefer `Math.abs()` over manual absolute value expressions and symmetric range checks.",recommended:"unopinionated"},fixable:"code",messages:{[fx]:"Prefer `Math.abs()` to simplify this expression."},languages:["js/js"]}},"unicorn/prefer-split-limit":{create:e=>{let{sourceCode:t}=e;e.on("MemberExpression",r=>{if(!r.computed||!f$(r.object)||r3(r))return;let n=fR(r.property,t);if(void 0!==n)return fP(r,r.object,n,e)}),e.on("CallExpression",r=>{if(!td(r,{method:"at",argumentsLength:1}))return;let{object:n}=r.callee;if(!tc(r.callee)||!f$(n))return;let o=fR(r.arguments[0],t);if(void 0!==o)return fP(r,n,o,e)})},meta:{type:"suggestion",docs:{description:"Prefer `String#split()` with a limit.",recommended:"unopinionated"},fixable:"code",messages:{[fB]:"Prefer `String#split()` with a limit."},languages:["js/js"]}},"unicorn/prefer-queue-microtask":fN,"unicorn/prefer-string-pad-start-end":{create:e=>{e.on("BinaryExpression",t=>((e,t)=>{if("+"!==e.operator)return;let r=fG(e.left,t);if(r&&tQ(e.right,r.targetNode)&&!fU(e.right,t)){let n=fz({targetNode:e.right,targetLengthNode:r.targetLengthNode,paddingNode:r.paddingNode});return fX({node:e,method:"padStart",replacement:n&&fJ({method:"padStart",targetNode:e.right,...r},t),context:t,canFix:n})}let n=fG(e.right,t);if(n&&tQ(e.left,n.targetNode)&&!fU(e.left,t)){let r=fz({targetNode:e.left,targetLengthNode:n.targetLengthNode,paddingNode:n.paddingNode});return fX({node:e,method:"padEnd",replacement:r&&fJ({method:"padEnd",targetNode:e.left,...n},t),context:t,canFix:r})}})(t,e)),e.on("CallExpression",t=>((e,t)=>{if(!td(e,{method:"slice",minimumArguments:1,maximumArguments:2,optionalCall:!1,optionalMember:!1})||"BinaryExpression"!==e.callee.object.type||"+"!==e.callee.object.operator)return;let{object:r}=e.callee,[n,o]=e.arguments,a=fK(r.left,t),i=(e=>{if(e?.type==="UnaryExpression"&&"-"===e.operator)return e.argument})(n);if(1===e.arguments.length&&a&&i&&f_(a.widthNode)&&tQ(a.widthNode,i)&&"Identifier"===r.right.type&&!fU(r.right,t)){let n=fV(a.paddingNode);return fY({node:e,method:"padStart",replacement:fJ({method:"padStart",targetNode:r.right,targetLengthNode:a.widthNode,...a},t),context:t,canSuggest:n})}let s=fK(r.right,t);if(2===e.arguments.length&&s&&f_(n)&&0===n.value&&f_(s.widthNode)&&tQ(s.widthNode,o)&&"Identifier"===r.left.type&&!fU(r.left,t)){let n=fV(s.paddingNode);return fY({node:e,method:"padEnd",replacement:fJ({method:"padEnd",targetNode:r.left,targetLengthNode:s.widthNode,...s},t),context:t,canSuggest:n})}})(t,e))},meta:{type:"suggestion",docs:{description:"Prefer `String#padStart()` and `String#padEnd()` over manual string padding.",recommended:"unopinionated"},fixable:"code",hasSuggestions:!0,messages:{[fM]:"Prefer `String#{{method}}()` over manual string padding.",[fO]:"Replace with `String#{{method}}()`."},languages:["js/js"]}},"unicorn/require-css-escape":f3,"unicorn/require-passive-events":{create:e=>{e.on("CallExpression",t=>{if(!td(t,{method:"addEventListener",minimumArguments:2,maximumArguments:3,optionalCall:!1,optionalMember:!1}))return;let[r,n,o]=t.arguments;if(!e1(r)||!f6.has(r.value)||"ArrowFunctionExpression"!==n.type&&"FunctionExpression"!==n.type||!((e,t)=>{let r;if(r=t.sourceCode,"FunctionExpression"===e.type&&tM(r.getScope(e)).some(t=>((e,t)=>{let r=e.block;for(;r&&r!==t;){if("FunctionDeclaration"===r.type||"FunctionExpression"===r.type)return!1;r=r.parent}return r===t})(t,e)&&t.references.some(({identifier:e})=>"arguments"===e.name)))return!1;let[n]=e.params;if(!n)return!0;if("Identifier"!==n.type)return!1;let o=t.sourceCode.getDeclaredVariables(e).find(e=>e.defs[0]?.name===n);if(!o)return!1;for(let{identifier:e}of o.references)if(f5(e)||!f4(e))return!1;return!0})(n,e))return;let a=((e,t,r)=>{if(!r){let r;return{fix:(r=t.arguments[1],t=>t.insertTextAfterRange(eH(r,e),", {passive: true}"))}}if(e2(r,!0)||e2(r,!1))return{fix:e=>e.replaceText(r,e2(r,!0)?"{capture: true, passive: true}":"{passive: true}")};if("ObjectExpression"!==r.type||r.properties.some(e=>"SpreadElement"===e.type||e.computed))return;let n=r.properties.findLast(e=>"Property"===e.type&&"passive"===(e=>{if(!e.computed){if("Identifier"===e.key.type)return e.key.name;if(e1(e.key))return e.key.value}})(e));if(!n)return{fix:((e,t)=>{let r=e.properties.at(-1);if(!r)return!1;let n=t.getLastToken(e);return t.getTokensBetween(r,n,{includeComments:!0}).some(e=>"Block"===e.type||"Line"===e.type)})(r,e.sourceCode)?void 0:t=>{let{sourceCode:n}=e;if(0===r.properties.length)return t.replaceText(r,"{passive: true}");let o=r.properties.at(-1);if(n.getLoc(r).start.line===n.getLoc(r).end.line)return t.insertTextAfter(o,", passive: true");let a=n.getTokenAfter(o),i=t8(o,e);return","===a.value?t.insertTextAfter(a,`
|
|
@@ -33,4 +33,4 @@ ${yP(r,r.getRange(t)[0])}${e}`:""}let i=a.split("\n");if(i[0]?.trim()===""&&i.sh
|
|
|
33
33
|
${i.map(e=>""===e.trim()?"":e.startsWith(u)?`${l}${e.slice(u.length)}`:`${l}${e.trimStart()}`).join("\n")}`})(r,e,t);let n=yP(t,t.getRange(e)[0]);return`
|
|
34
34
|
${n}${t.getText(r)}`})(n,r))}}})},meta:{type:"suggestion",docs:{description:"Disallow `else` after a statement that exits.",recommended:!0},fixable:"code",messages:{[yB]:"Unexpected `else` after a statement that exits."},languages:["js/js"]}},"unicorn/no-useless-recursion":{create:e=>{let{sourceCode:t}=e;e.on("ReturnStatement",e=>{if(((e,t)=>{var r;let n,{argument:o}=e;if(o?.type!=="CallExpression"||o.optional||"Identifier"!==o.callee.type)return!1;let a=(e=>{for(;e;e=e.parent)if(tl(e))return e})(e);return!!(a?.id&&!a.generator&&!((e,t)=>{for(;e&&e!==t;e=e.parent)if("TryStatement"===e.type)return!0;return!1})(e,a)&&!((e,t)=>{for(;e&&e!==t;e=e.parent){if(yq(e))return!0;if(e.parent?.type!=="BlockStatement")continue;let t=e.parent.body.indexOf(e);if(e.parent.body.slice(0,t).some(e=>yO(e)))return!0}return!1})(e,a)&&o.callee.name===a.id.name&&(r=o.callee,n=ei(t.getScope(r),r),n?.identifiers.includes(a.id)))})(e,t))return{node:e.argument.callee,messageId:yN}})},meta:{type:"suggestion",docs:{description:"Disallow simple recursive function calls that can be replaced with a loop.",recommended:!0},messages:{[yN]:"Use a loop instead of this recursive function call."},languages:["js/js"]}},"unicorn/prefer-add-event-listener-options":{create:e=>{e.on("CallExpression",e=>{if(!td(e,{method:"addEventListener",argumentsLength:3,optionalCall:!1,optionalMember:!1}))return;let t=e.arguments[2];if(!e2(t))return;let r=`{capture: ${t.value}}`;return{node:t,messageId:yU,data:{value:String(t.value),replacement:r},fix:e=>e.replaceText(t,r)}})},meta:{type:"suggestion",docs:{description:"Prefer an options object over a boolean in `.addEventListener()`.",recommended:"unopinionated"},fixable:"code",messages:{[yU]:"Prefer `{{replacement}}` over `{{value}}`."},languages:["js/js"]}},"unicorn/prefer-direct-iteration":{create:e=>{e.on("CallExpression",t=>{if(!td(t,{methods:["entries","keys","values"],argumentsLength:0,optionalCall:!1,optionalMember:!1})||!(e=>{let{parent:t}=e;if("ForOfStatement"===t.type&&t.right===e||"YieldExpression"===t.type&&t.delegate&&t.argument===e||"SpreadElement"===t.type&&t.argument===e&&(e=>{let{parent:t}=e;return yH.has(t.type)})(t))return!0;if("NewExpression"===t.type)return 1===t.arguments.length&&t.arguments[0]===e&&(te(t,{names:yX,argumentsLength:1})||te(t,{names:rE,argumentsLength:1}));if("CallExpression"===t.type)return t.arguments[0]===e&&(td(t,{object:"Array",method:"from",minimumArguments:1,optionalCall:!1,optionalMember:!1})||yQ(t,["from"])||td(t,{object:"Object",method:"fromEntries",minimumArguments:1,optionalCall:!1,optionalMember:!1})||td(t,{object:"Promise",methods:yY,argumentsLength:1,optionalCall:!1,optionalMember:!1}));return!1})(t))return;let r=t.callee.property.name;if(((e,t)=>{if(!t?.size)return!1;for(let r of t){let t=yJ.get(r);if(!t?.includes(e))return!1}return!0})(r,y8(t.callee.object,e)))return{node:t.callee.property,messageId:yW,data:{method:r},fix:((e,t)=>{if(!(t.sourceCode.getCommentsInside(e).length>0))return r=>oO(r,e,t)})(t,e)}})},meta:{type:"suggestion",docs:{description:"Prefer direct iteration over default iterator method calls.",recommended:"unopinionated"},fixable:"code",messages:{[yW]:"Prefer direct iteration instead of `.{{method}}()`."},languages:["js/js"]}},"unicorn/prefer-number-is-safe-integer":{create:e=>{let{sourceCode:t}=e,r=(e,r)=>{let n,o={node:e,messageId:y5};return n=t.getRange(r),t.getCommentsInside(e).some(e=>{let r=t.getRange(e);return r[0]<n[0]||r[1]>n[1]})||(o.suggest=[{messageId:y4,fix:n=>{let o;return n.replaceText(e,`Number.isSafeInteger(${(o=t.getText(r),"SequenceExpression"===r.type?`(${o})`:o)})`)}}]),o};e.on("CallExpression",e=>{if(td(e,{object:"Number",method:"isInteger",optionalCall:!1,optionalMember:!1,computed:!1})&&t.isGlobalReference(e.callee.object))return{node:e.callee.property,messageId:y6,suggest:[{messageId:y9,fix:t=>t.replaceText(e.callee.property,"isSafeInteger")}]};let n=(e=>{if(td(e,{objects:y7,methods:["isInteger","isSafeInteger"],argumentsLength:1,optionalCall:!1,optionalMember:!1,computed:!1}))return e.arguments[0]})(e);if(n&&ht(e,t))return r(e,n)}),e.on("BinaryExpression",e=>{let n=(e=>{if("==="===e.operator){if(e0(e.right,0))return hr(e.left);if(e0(e.left,0))return hr(e.right)}})(e)??((e,t)=>{if("==="!==e.operator)return;let r=hn(e.left,t);if(r&&tQ(r,e.right))return r;let n=hn(e.right,t);if(n&&tQ(n,e.left))return n})(e,t);if(n&&ht(e,t))return r(e,n)})},meta:{type:"suggestion",docs:{description:"Prefer `Number.isSafeInteger()` over integer checks.",recommended:!0},hasSuggestions:!0,messages:{[y6]:"Prefer `Number.isSafeInteger()` over `Number.isInteger()`.",[y9]:"Replace `Number.isInteger()` with `Number.isSafeInteger()`.",[y5]:"Prefer `Number.isSafeInteger()` over this integer check.",[y4]:"Replace this integer check with `Number.isSafeInteger()`."},languages:["js/js"]}},"unicorn/prefer-object-define-properties":{create:e=>{let{sourceCode:t}=e;e.on("ExpressionStatement",r=>{let n=hi(r);if(!n)return;let o=hi(or(r,e));if(o&&tQ(o.arguments[0],n.arguments[0]))return;let a=[r],i=[n],s=on(r,e);for(;;){let t=hi(s);if(!t||!tQ(n.arguments[0],t.arguments[0]))break;a.push(s),i.push(t),s=on(s,e)}if(i.length<2)return;let l={node:n.callee.property,messageId:ha},u=[t.getRange(a[0])[0],t.getRange(a.at(-1))[1]];return function(e,t){let r=new Set,n=[];for(let o of e){let e=o.arguments[1],a=function(e,t){let r=ew(e,t.getScope(e));if(r)return"symbol"==typeof r.value?r.value:String(r.value)}(e,t);if(void 0===a){if(n.some(t=>tQ(t,e)))return!0;n.push(e);continue}if(r.has(a))return!0;r.add(a)}return!1}(i,t)||t.getAllComments().some(e=>{let[r,n]=t.getRange(e);return r>=u[0]&&n<=u[1]})||(l.fix=function(e,t,r){let{sourceCode:n}=r,o=e[0],a=e.at(-1),i=t8(o,r),s=`${i} `,l=n.getText(t[0].arguments[0]),u=t.map(e=>{let t=function(e,t){let r=t.getText(e);if("Literal"===e.type){if("string"==typeof e.value)return"__proto__"===e.value?`[${r}]`:ho(e.value)?e.value:r;if("number"==typeof e.value)return r}return`[${r}]`}(e.arguments[1],n),r=n.getText(e.arguments[2]).replaceAll("\n","\n ");return`${s}${t}: ${r},`}).join("\n");return e=>e.replaceTextRange([n.getRange(o)[0],n.getRange(a)[1]],`Object.defineProperties(${l}, {
|
|
35
35
|
${u}
|
|
36
|
-
${i}});`)}(a,i,e)),l})},meta:{type:"suggestion",docs:{description:"Prefer `Object.defineProperties()` over multiple `Object.defineProperty()` calls.",recommended:"unopinionated"},fixable:"code",schema:[],messages:{[ha]:"Prefer `Object.defineProperties()` over multiple `Object.defineProperty()` calls."},languages:["js/js"]}},"unicorn/prefer-object-destructuring-defaults":{create:e=>{e.on("VariableDeclarator",t=>{let{id:r,init:n}=t;if("ObjectPattern"!==r.type||n?.type!=="ObjectExpression"||0!==e.sourceCode.getCommentsInside(t).length)return;let o=((e,t)=>{if(e.typeAnnotation)return;let r=[];for(let n of e.properties){if(!(hc(n)&&"Identifier"===n.value.type))return;let e=eI(n,t.sourceCode.getScope(n));if(null===e||hu.has(e))return;r.push({node:n,name:e})}return r})(r,e),a=((e,t)=>{let{properties:r}=e,n=r.at(-1);if(n?.type!=="SpreadElement"||eP(n.argument,t.sourceCode,hp))return;let o=new Map;for(let e of r.slice(0,-1)){if(!hc(e)||eP(e.value,t.sourceCode,hp))return;let r=eI(e,t.sourceCode.getScope(e));if(null===r||o.has(r))return;o.set(r,e)}return{defaultProperties:o,spreadElement:n}})(n,e);if(!o||0===o.length||!a)return;let{defaultProperties:i,spreadElement:s}=a;if(o.length!==i.size)return;let l=new Set(o.map(e=>e.node.value.name)),u=[];for(let t of o){let r=i.get(t.name);if(!r||hd(r.value,l,e))return;u.push(hm(t,r,e))}return{node:t,messageId:hs,suggest:[{messageId:hl,fix:r=>r.replaceText(t,`{${u.join(", ")}} = {${e.sourceCode.getText(s)}}`)}]}})},meta:{type:"suggestion",docs:{description:"Prefer object destructuring defaults over default object literals with spread.",recommended:!0},hasSuggestions:!0,schema:[],messages:{[hs]:"Prefer object destructuring defaults over default object literals with spread.",[hl]:"Use object destructuring defaults."},languages:["js/js"]}},"unicorn/prefer-single-object-destructuring":{create:e=>{let{sourceCode:t}=e;e.on("Program",e=>hh(t,e.body)),e.on(["BlockStatement","StaticBlock"],e=>hh(t,e.body)),e.on("SwitchCase",e=>hh(t,e.consequent))},meta:{type:"suggestion",docs:{description:"Prefer a single object destructuring declaration per local const source.",recommended:!0},fixable:"code",schema:[],messages:{[hf]:"Prefer a single object destructuring declaration from `{{source}}`."},languages:["js/js"]}},"unicorn/prefer-smaller-scope":{create:e=>{let{sourceCode:t}=e;e.on("VariableDeclaration",e=>(function(e,t){if(!(e.parent&&("Program"===e.parent.type||"BlockStatement"===e.parent.type)&&"let"===e.kind&&1===e.declarations.length&&"Identifier"===e.declarations[0].id.type&&!e.declarations[0].init))return;let[r]=e.declarations,[n]=t.getDeclaredVariables(r),o=n.references.filter(e=>!e.init),a=o.filter(e=>e.isWrite());if(1!==a.length||o.every(e=>!e.isRead()))return;let i=function(e){let{identifier:t}=e,r=t.parent;if("AssignmentExpression"!==r.type||"="!==r.operator||r.left!==t||"ExpressionStatement"!==r.parent.type)return;let n=r.parent,o=n.parent;if("BlockStatement"===o.type)return{assignmentExpression:r,assignmentStatement:n,block:o}}(a[0]);if(!i)return;let{assignmentExpression:s,assignmentStatement:l,block:u}=i,[,p]=t.getRange(e),[c,d]=t.getRange(l);if(!hE(u,e.parent)||function e(t,r){if("WithStatement"===t.type||"CallExpression"===t.type&&"Identifier"===t.callee.type&&"eval"===t.callee.name)return!0;for(let n of r[t.type]??[]){let o=t[n];if(Array.isArray(o)){if(o.some(t=>t&&e(t,r)))return!0}else if(o&&e(o,r))return!0}return!1}(e.parent,t.visitorKeys)||c<p||o.some(e=>!hE(e.identifier,u))||o.some(e=>e.isRead()&&t.getRange(e.identifier)[0]<d))return;let m={node:r.id,messageId:hx,data:{name:r.id.name}};return r.id.typeAnnotation||hS(t,s)&&"SequenceExpression"===s.right.type||t.getCommentsInside(e).length>0||t.getCommentsInside(l).length>0||hD(t,e,"before")||hD(t,e,"after")||hD(t,l,"before")||hD(t,l,"after")||(m.fix=function({sourceCode:e,declaration:t,assignmentExpression:r,assignmentStatement:n,name:o}){return function*(a){yield oq(t,{sourceCode:e},a);let i=`const ${o} = `;if(hS(e,r))return void(yield a.replaceText(n,`${i}${e.getText(r.right)};`));let[s]=e.getRange(r),[l]=e.getRange(r.right);yield a.replaceTextRange([s,l],i)}}({sourceCode:t,declaration:e,assignmentExpression:s,assignmentStatement:l,name:r.id.name})),m})(e,t))},meta:{type:"suggestion",docs:{description:"Prefer declaring variables in the smallest possible scope.",recommended:!0},fixable:"code",schema:[],messages:{[hx]:"Move `{{name}}` into the block where it is used."},languages:["js/js"]}},"unicorn/prefer-single-array-predicate":{create:e=>{e.on("LogicalExpression",t=>{if("LogicalExpression"===t.parent.type&&t.parent.operator===t.operator)return;let r=hA.get(t.operator);if(!r||e.sourceCode.getCommentsInside(t).length>0)return;let n=(function e(t,r){return"LogicalExpression"!==t.type||t.operator!==r?[t]:[...e(t.left,r),...e(t.right,r)]})(t,t.operator).map(t=>(function(e,t,r){if(!td(e,{method:t,argumentsLength:1,optionalCall:!1,optionalMember:!1})||e.typeArguments||e.typeParameters)return;let{object:n}=e.callee;if(rG(n,r))return;let o=function(e){if("ArrowFunctionExpression"===e.type&&!e.async&&!e.returnType&&!e.typeParameters&&1===e.params.length&&"Identifier"===e.params[0].type&&"BlockStatement"!==e.body.type)return{parameter:e.params[0],body:e.body}}(e.arguments[0]);if(o){var a;let t;return{node:e,object:n,callback:{...o,parameterText:(a=o.parameter,t=r.sourceCode.getText(a),a.typeAnnotation||a.optional?`(${t})`:t)}}}})(t,r,e));if(!(n.length<2||n.includes(void 0)||n.some(e=>{let t;return t=n[0],!tQ(t.object,e.object)||t.callback.parameterText!==e.callback.parameterText})))return{node:t,messageId:hv,data:{method:r},suggest:[{messageId:hC,data:{method:r},fix:r=>r.replaceText(t,function(e,t,r){let{sourceCode:n}=r,[o]=e,{callback:a}=o,i=e.map(({callback:e})=>(function(e,t,r){var n,o;if(eQ(e,r))return eZ(e,r);let a=r.sourceCode.getText(e);return(n=e,o=t,"LogicalExpression"===n.type?n.operator!==o&&("||"!==o||"&&"!==n.operator):hT.has(n.type))?`(${a})`:a})(e.body,t,r)).join(` ${t} `);return`${n.getText(o.node.callee)}(${a.parameterText} => ${i})`}(n,t.operator,e))}]}})},meta:{type:"suggestion",docs:{description:"Prefer a single `Array#some()` or `Array#every()` with a combined predicate.",recommended:"unopinionated"},hasSuggestions:!0,messages:{[hv]:"Prefer a single `Array#{{method}}()` with a combined predicate.",[hC]:"Merge predicates into one `Array#{{method}}()` call."},languages:["js/js"]}},"unicorn/prefer-url-href":{create:e=>{e.on("CallExpression",t=>{if(td(t,{method:"toString",argumentsLength:0,optionalCall:!1,optionalMember:!1,computed:!1})&&"url"===hz(t.callee.object,e)){let r={node:t.callee.property,messageId:hw};return hG(t,e)&&!eQ(t.callee,e)&&hK(t.callee.object,e)&&(r.fix=r=>r.replaceTextRange([e.sourceCode.getRange(t.callee.property)[0],e.sourceCode.getRange(t)[1]],"href")),r}if(!(e7(t,{name:"String",argumentsLength:1,optional:!1})&&nR(t.callee,e)))return;let[r]=t.arguments;if("url"!==hz(r,e))return;let n={node:t.callee,messageId:hw};return hG(t,e)&&hK(r,e)&&(n.fix=n=>{let o,a,i;return n.replaceText(t,(o=eZ(r,e),a=!eQ(r,e)&&n2(r,e)?`(${o})`:o,i=`${a}.href`,(nW(e.sourceCode.getTokenBefore(r.parent),e,i)?";":"")+i))}),n})},meta:{type:"suggestion",docs:{description:"Prefer `URL#href` over stringifying a `URL`.",recommended:"unopinionated"},fixable:"code",messages:{[hw]:"Prefer `URL#href` over stringifying a `URL`."},languages:["js/js"]}},"unicorn/require-proxy-trap-boolean-return":{create:e=>{let{sourceCode:t}=e,r=new WeakMap,n=[];function*o(e){let n;if(!(te(n=e,{name:"Proxy",argumentsLength:2})||td(n,{object:"Proxy",method:"revocable",argumentsLength:2,optionalCall:!1,optionalMember:!1,computed:!1})))return;let o=e.arguments[1];if("ObjectExpression"===o.type)for(let e of o.properties){let n=h2(e,t);if(!n)continue;let o=h3(n,t,r);o&&(yield o)}}e.on("onCodePathStart",()=>{n.push(new Set)}),e.on("onCodePathEnd",()=>{n.pop()}),e.on("onCodePathSegmentStart",e=>{n.at(-1).add(e)}),e.on("onCodePathSegmentEnd",e=>{n.at(-1).delete(e)}),e.on("onUnreachableCodePathSegmentStart",e=>{n.at(-1).add(e)}),e.on("onUnreachableCodePathSegmentEnd",e=>{n.at(-1).delete(e)}),e.onExit("BlockStatement",e=>{if(!(hY.has(e.parent?.type)&&e.parent.body===e))return;let t=[...n.at(-1)].every(e=>!e.reachable);r.set(e.parent,t)}),e.onExit("CallExpression",o),e.onExit("NewExpression",o)},meta:{type:"problem",docs:{description:"Require boolean-returning Proxy traps to return booleans.",recommended:"unopinionated"},fixable:"code",messages:{[hJ]:"Proxy trap `{{name}}` should return a boolean."},languages:["js/js"]}},"unicorn/logical-assignment-operators":h7,"unicorn/no-useless-coercion":{create:e=>{let{sourceCode:t}=e,r=(r,n,o,a)=>({node:r,messageId:xe,data:{description:o,type:a},*fix(o,{abort:a}){if(t.getCommentsInside(r).length>0)return a();yield oj(o,r,n,e)}});e.on("CallExpression",t=>{if(t.optional||"Identifier"!==t.callee.type||1!==t.arguments.length||"SpreadElement"===t.arguments[0].type)return;let{name:n}=t.callee,o=xt.get(n);if(!o||!nR(t.callee,e))return;let[a]=t.arguments;if(o.isType(a,e))return r(t,a,`\`${n}()\``,o.type)}),e.on("UnaryExpression",e=>{if("+"===e.operator&&nr(e.argument,t.getScope(e.argument)))return r(e,e.argument,"`+`","number")}),e.on("BinaryExpression",t=>{let n;if("+"!==t.operator)return;let{left:o,right:a}=t;if(xr(a)&&nC(o,e))n=o;else{if(!(xr(o)&&nC(a,e)))return;n=a}return r(t,n,"Concatenation with `''`","string")}),e.on("CallExpression",t=>{let{callee:n}=t;if(!t.optional&&!(t.arguments.length>0)&&"MemberExpression"===n.type&&!n.optional&&!n.computed&&"Identifier"===n.property.type&&"toString"===n.property.name&&nC(n.object,e))return r(t,n.object,"`.toString()`","string")})},meta:{type:"suggestion",docs:{description:"Disallow useless type coercions of values that are already of the target type.",recommended:"unopinionated"},fixable:"code",messages:{[xe]:"{{description}} is unnecessary because the value is already a {{type}}."},languages:["js/js"]}},"unicorn/no-useless-boolean-cast":{create:e=>{let{sourceCode:t}=e;e.on("CallExpression",r=>{if(!td(r,{methods:xo,minimumArguments:1,maximumArguments:2,optionalCall:!1,optionalMember:!1}))return;let[n]=r.arguments;if(!tl(n))return;let o=function(e){if(!e.async&&!e.generator&&!e.returnType){if("ArrowFunctionExpression"===e.type&&"BlockStatement"!==e.body.type)return e.body;if("BlockStatement"===e.body.type&&1===e.body.body.length&&"ReturnStatement"===e.body.body[0].type)return e.body.body[0].argument}}(n);if(!tC(o,e)||t.getCommentsInside(o).length>0)return;let[a]=o.arguments;if(!(n.params[0]?.type==="Identifier"&&nB(n.params[0],a)))return{node:o,messageId:xn,data:{method:r.callee.property.name},fix(e){let r,i=t.getText(a);return"ArrowFunctionExpression"===n.type&&n.body===o&&(r=i,"SequenceExpression"===a.type||r.trimStart().startsWith("{"))&&(i=`(${i})`),e.replaceText(o,i)}}})},meta:{type:"suggestion",docs:{description:"Disallow unnecessary `Boolean()` casts in array predicate callbacks.",recommended:"unopinionated"},fixable:"code",messages:{[xn]:"`Boolean()` is unnecessary in `Array#{{method}}()` callbacks."},languages:["js/js"]}},"unicorn/no-useless-continue":{create:e=>{e.on("ContinueStatement",t=>{if(!t.label&&(e=>{if("BlockStatement"!==e.parent.type)return!1;let t=e;for(;;){let{parent:e}=t;if("BlockStatement"===e.type){if(e.body.at(-1)!==t)return!1;t=e;continue}if("IfStatement"===e.type&&(e.consequent===t||e.alternate===t)){t=e;continue}return tp(e)&&e.body===t}})(t))return{node:t,messageId:xa,fix:r=>oq(t,e,r)}})},meta:{type:"suggestion",docs:{description:"Disallow useless `continue` statements.",recommended:"unopinionated"},fixable:"code",messages:{[xa]:"Unnecessary `continue` statement."},languages:["js/js"]}},"unicorn/no-useless-override":{create:e=>{let{sourceCode:t}=e;e.on("MethodDefinition",r=>{let n;if("method"!==r.kind||r.accessibility||r.optional||r.decorators?.length>0||r.value.params.some(e=>e.decorators?.length>0))return;let{value:o}=r;if("FunctionExpression"!==o.type||!o.body||o.generator||!r.parent.parent.superClass)return;let a=function(e,t){let r,n,o,{value:a}=e;if(1!==a.body.body.length)return;let[i]=a.body.body;if("ReturnStatement"===i.type?r=i.argument:"ExpressionStatement"===i.type&&(r=i.expression),r?.type!=="CallExpression"||r.optional)return;let{callee:s}=r;if("MemberExpression"!==s.type||s.optional||"Super"!==s.object.type)return;let l=t.getScope(r),u=eI(e,l);if("string"==typeof u&&eI(s,l)===u&&(n=r.arguments,o=a.params,n.length===o.length&&o.every((e,t)=>{let r=n[t];return"Identifier"===e.type?"Identifier"===r.type&&r.name===e.name:"RestElement"===e.type&&"Identifier"===e.argument.type&&"SpreadElement"===r.type&&"Identifier"===r.argument.type&&r.argument.name===e.argument.name})))return{callExpression:r,name:u,isReturned:"ReturnStatement"===i.type}}(r,t);if(!a)return;let{callExpression:i,name:s,isReturned:l}=a;if(n=t.getScope(r),!r.parent.body.some(e=>e!==r&&"MethodDefinition"===e.type&&"method"===e.kind&&e.static===r.static&&null===e.value.body&&eI(e,n)===s)){if(l){let t;if(o.async&&(void 0===(t=xl(i,e))||!0!==function e(t,r){let n;if(n=t=r.getNonNullableType(t),!rD.has(n.intrinsicName)){if(t.isUnion()){let n=t.types.map(t=>e(t,r));return!!n.every(Boolean)||!n.every(e=>!1===e)&&void 0}return void 0!==r.getPromisedTypeOfPromise(t)}}(t.type,t.checker)))return}else{let t;if(o.async||!(void 0!==(t=xl(i,e))&&xs(t.type)))return}return{node:r.key,messageId:xi,data:{superCall:t.getText(i.callee)},*fix(n,{abort:o}){if(t.getCommentsInside(r).length>0)return o();yield oV(r,"",n,e)}}}})},meta:{type:"suggestion",docs:{description:"Disallow useless overrides of class methods.",recommended:"unopinionated"},fixable:"code",messages:{[xi]:"Useless override; this method only forwards to `{{superCall}}(…)`."},languages:["js/js"]}},"unicorn/prefer-has-check":{create:e=>{e.on("CallExpression",t=>((e,t)=>{if(!td(e,{method:"get",argumentsLength:1,computed:!1,optionalCall:!1,optionalMember:!1,allowSpreadElement:!1}))return;let r=(e=>{let t=(e=>{for(;xS.has(e.parent?.type)&&e.parent.expression===e;)e=e.parent;return e})(e),{parent:r}=t;if(r?.type==="BinaryExpression"&&["!==","===","!=","=="].includes(r.operator)){if(r.left===t)return{node:r,operator:r.operator,value:r.right};if(r.right===t)return{node:r,operator:r.operator,value:r.left}}})(e);if(r){let n,o;if(t.sourceCode.getCommentsInside(e).length>0)return;let a=((e,t,r)=>{let n=xN(e.callee.object,r);if(!n)return;let o="!="===t.operator||"=="===t.operator;if("null-sentinel"===n.kind)return o&&xI(t.value,r)?{missingType:"undefined"}:{missingType:"null"};if("map"===n.kind){if(xI(t.value,r)&&xV(e.callee.object,r,o?"not-nullish":"not-undefined"))return{missingType:"undefined"};if(xz(t.value)&&o&&xV(e.callee.object,r,"not-nullish"))return{missingType:"nullish"}}})(e,r,t);if(!a||(n=r.value,o=a.missingType,"undefined"===o?!xI(n,t):!xz(n)))return;return{node:e.callee.property,messageId:xu,fix:((e,t,r)=>{var n;let o;if(r.sourceCode.getCommentsInside(t.node).length>r.sourceCode.getCommentsInside(e).length)return;let a=`${(({operator:e})=>"!=="===e||"!="===e)(t)?"":"!"}${(o=eZ(n=e.callee.object,r),!eQ(n,r)&&n2(n,r)?`(${o})`:o)}.has(${((e,t)=>{let[r]=e.arguments;return t.sourceCode.getText(r)})(e,r)})`;return e=>e.replaceText(t.node,a)})(e,r,t)}}if((tA(e,t)||tT(e))&&xN(e.callee.object,t)?.kind==="map"&&xV(e.callee.object,t,"truthy")){if(t.sourceCode.getCommentsInside(e).length>0)return;return{node:e.callee.property,messageId:xu,fix:t=>t.replaceText(e.callee.property,"has")}}})(t,e))},meta:{type:"suggestion",docs:{description:"Prefer `.has()` when checking existence.",recommended:"unopinionated"},fixable:"code",messages:{[xu]:"Prefer `.has(…)` when checking existence."},languages:["js/js"]}},"unicorn/prefer-minimal-ternary":x1,"unicorn/consistent-conditional-object-spread":{create:e=>{e.options[0]===x3?e.on("LogicalExpression",t=>{if(x5(t)){if("&&"!==t.operator||ta(t.right)||x4(t.left,t.right,e.sourceCode))return;let r=br(t.left,e.sourceCode);if(r&&!r.isTrueWhenNullish&&x4(r.reference,t.right,e.sourceCode))return;let n=bo(t.left,e),o=bo(t.right,e);return{node:t,messageId:x8,data:{expectedStyle:"ternary"},*fix(r,{abort:a}){if(e.sourceCode.getCommentsInside(t).length>0)return a();yield r.replaceText(t,`${n} ? ${o} : {}`)}}}}):e.on("ConditionalExpression",t=>{if(x5(t))return function(e,t){let{test:r,consequent:n,alternate:o}=e,a=ta(o);if(a===ta(n))return;let i=a?n:o,s=br(r,t.sourceCode),l=t.sourceCode.getCommentsInside(e).length>0;if((a?x4(r,i,t.sourceCode):"UnaryExpression"===r.type&&"!"===r.operator&&r.prefix&&x4(r.argument,i,t.sourceCode))||s&&!l&&(s.isTrueWhenNullish?!a:a)&&x4(s.reference,i,t.sourceCode))return;let u=a?bn(r,"left",t):function(e,t){if("UnaryExpression"===e.type&&"!"===e.operator&&e.prefix)return bn(e.argument,"left",t);let r=eZ(e,t);return!eQ(e,t)&&n8(e,"!")&&(r=`(${r})`),`!${r}`}(r,t),p=bn(i,"right",t);return{node:e,messageId:x8,data:{expectedStyle:"logical"},*fix(t,{abort:r}){if(l)return r();yield t.replaceText(e,`${u} && ${p}`)}}}(t,e)})},meta:{type:"suggestion",docs:{description:"Enforce consistent conditional object spread style.",recommended:!0},fixable:"code",schema:[{description:"The conditional object spread style to enforce.",enum:[x2,x3]}],defaultOptions:[x2],messages:{[x8]:"Prefer {{expectedStyle}} conditional object spreads."},languages:["js/js"]}},"unicorn/default-export-style":bj,"unicorn/no-array-concat-in-loop":{create:e=>{e.on("AssignmentExpression",t=>{let r=function(e,t){var r;if("="!==e.operator)return;let n="Identifier"===e.left.type?e.left:void 0,o=bF(e.right);if(!n||!td(o,{method:"concat",minimumArguments:1,optionalCall:!1,optionalMember:!1,computed:!1}))return;let a=(r=bF(r=o.callee.object),r?.type==="Identifier"?r:void 0),i=bB(n,t);if(!a||!i||i!==bB(a,t)||!function(e){let[t]=e?.defs??[];if(!t||1!==e.defs.length||"global"===e.scope.type||"Variable"!==t.type||"Identifier"!==t.node.id.type||"let"!==t.parent.kind&&"var"!==t.parent.kind)return!1;let r=t.node.init&&bF(t.node.init);return!!(r&&to(r))}(i))return;let s=function(e,t){for(let r of t.sourceCode.getAncestors(e).toReversed()){if(tl(r))return;if(tp(r))return r}}(e,t),[l]=i.defs;if(!(!s||function(e,t,r){let[n,o]=r.sourceCode.getRange(e),[a,i]=r.sourceCode.getRange(t);return n>=a&&o<=i}(l.node,s.body,t)))return{callExpression:o,property:o.callee.property}}(t,e);if(r)return{node:r.property,messageId:bR}})},meta:{type:"suggestion",docs:{description:"Disallow array accumulation with `Array#concat()` in loops.",recommended:!0},schema:[],messages:{[bR]:"Do not use `Array#concat()` to accumulate an array in a loop."},languages:["js/js"]}},"unicorn/no-array-front-mutation":{create:e=>{e.on("CallExpression",t=>{if(!td(t,{methods:["shift","unshift"],optionalCall:!1,computed:!1}))return;let{object:r,property:n}=t.callee,{name:o}=n;if(!("unshift"===o&&ty(t.callee,bP)||rX(r,e)))return{node:n,messageId:b$,data:{method:o}}})},meta:{type:"suggestion",docs:{description:"Disallow front-of-array mutation.",recommended:!1},schema:[],messages:{[b$]:"Avoid front-of-array mutation with `Array#{{method}}()`."},languages:["js/js"]}},"unicorn/no-array-sort-for-min-max":{create:e=>{e.on("MemberExpression",t=>{if(!t.computed||t.optional||!bM(t.property)||r3(t)||("ForInStatement"===t.parent.type||"ForOfStatement"===t.parent.type)&&t.parent.left===t)return;let r=bO(t.object,e);if(r)return bq(t,r,"first",e)}),e.on("CallExpression",t=>{let r;if(!td(t,{method:"at",argumentsLength:1,optionalCall:!1,optionalMember:!1}))return;let[n]=t.arguments;if(bM(n)?r="first":tm(n)&&(r="last"),!r||r3(t))return;let o=bO(t.callee.object,e);if(o)return bq(t,o,r,e)})},meta:{type:"suggestion",docs:{description:"Disallow sorting arrays to get the minimum or maximum value.",recommended:"unopinionated"},hasSuggestions:!0,messages:{[bL]:"Use `Math.{{method}}()` instead of sorting to get the {{extreme}} value.",[bN]:"Replace with `{{replacement}}`."},languages:["js/js"]}},"unicorn/no-boolean-sort-comparator":{create:e=>{e.on("CallExpression",t=>{if(!(e7(t,{minimumArguments:1})&&"MemberExpression"===t.callee.type&&b_.has(eI(t.callee,e.sourceCode.getScope(t.callee))))||rG(t.callee.object,e))return;let[r]=t.arguments;if("SpreadElement"!==r.type){let t=ry(r);if(tl(t)){let n=(e=>{if("BlockStatement"!==e.body.type)return e.body;if(1!==e.body.body.length)return;let[t]=e.body.body;if("ReturnStatement"===t.type)return t.argument})(t);if(!nm(t,e)&&!bK(r,e))return;return{node:r,messageId:bU,suggest:r===t?((e,t,r)=>{var n;if(!t||2!==e.params.length||e.params.some(e=>"Identifier"!==e.type)||e.params.some(e=>e.typeAnnotation)||e.params.some(e=>e.optional)||e.typeParameters||e.returnType||r.sourceCode.getCommentsInside(e).length>0)return;let[o,a]=e.params;if(o.name===a.name)return;let i="BinaryExpression"===(n=ry(n=t)).type&&bV.has(n.operator)?n:void 0;if(!i||rg(i.left)||rg(i.right)||!bz(i.left,i.right,o,a))return;let[s,l]=">"===i.operator||">="===i.operator?[i.left,i.right]:[i.right,i.left],u=`(${o.name}, ${a.name}) => ${r.sourceCode.getText(s)} - ${r.sourceCode.getText(l)}`;return[{messageId:bW,data:{replacement:u},fix:t=>t.replaceText(e,u)}]})(t,n,e):void 0}}return nf(t,e)||function(e,t){if("Identifier"===e.type)return("Boolean"===e.name||na.has(e.name))&&t.sourceCode.isGlobalReference(e);if("MemberExpression"!==e.type||e.optional||"Identifier"!==e.object.type||!t.sourceCode.isGlobalReference(e.object))return!1;let r=ni.get(e.object.name),n=eI(e,t.sourceCode.getScope(e));return!!r?.has(n)}(t,e)||bK(r,e)?{node:r,messageId:bU}:void 0}})},meta:{type:"problem",docs:{description:"Disallow boolean-returning sort comparators.",recommended:"unopinionated"},hasSuggestions:!0,messages:{[bU]:"Do not return a boolean from a sort comparator.",[bW]:"Replace with `{{replacement}}`."},languages:["js/js"]}},"unicorn/no-chained-comparison":{create:e=>{let{sourceCode:t}=e;e.on("BinaryExpression",r=>{let n;if(!bH.has(r.operator))return;let o=bZ(r.left)?r.left:r.right;if(!bZ(o))return;let a=o===r.left,i=a?r.right:r.left;if(bY.has(r.operator)&&ny(i,e))return;let s={node:r,messageId:bG},l=bX.has(o.operator)===bX.has(r.operator)&&("Literal"!==(n=r.right).type||"boolean"!=typeof n.value);if(a&&l&&!bZ(r.right)&&!bZ(o.left)&&((e,t)=>{if(eQ(e,t))return!0;let{parent:r}=e;return"BinaryExpression"!==r.type&&("LogicalExpression"!==r.type||"??"!==r.operator)})(r,e)&&!eP(o.right,t)&&0===t.getCommentsInside(r).length){let n=`${t.getText(r.left)} && ${eZ(o.right,e)} ${r.operator} ${eZ(r.right,e)}`;s.suggest=[{messageId:bJ,data:{replacement:n},fix:e=>e.replaceText(r,n)}]}return s})},meta:{type:"problem",docs:{description:"Disallow chained comparisons such as `a < b < c`.",recommended:"unopinionated"},hasSuggestions:!0,messages:{[bG]:"Comparison operators cannot be chained. The inner comparison evaluates to a boolean, which is then compared instead of the operands.",[bJ]:"Replace with `{{replacement}}`."},languages:["js/js"]}},"unicorn/no-constant-zero-expression":{create:e=>{let{sourceCode:t}=e;e.on("BinaryExpression",e=>{if(!(e=>{switch(e.operator){case"*":case"&":return e0(e.left,0)||e0(e.right,0);case"/":return e0(e.left,0);default:return!1}})(e))return;let r={node:e,messageId:bQ},n=ew(e,t.getScope(e));return n&&Object.is(n.value,0)&&0===t.getCommentsInside(e).length&&(r.suggest=[{messageId:b0,fix:t=>t.replaceText(e,"0")}]),r})},meta:{type:"problem",docs:{description:"Disallow arithmetic and bitwise operations that always evaluate to `0`.",recommended:"unopinionated"},hasSuggestions:!0,messages:{[bQ]:"This operation always evaluates to `0` (or `-0`/`NaN`), which is likely a mistake.",[b0]:"Replace this expression with `0`."},languages:["js/js"]}},"unicorn/no-duplicate-logical-operands":{create:e=>{e.on("LogicalExpression",t=>{let r,n;if("&&"!==t.operator&&"||"!==t.operator)return;let o="LogicalExpression"===t.left.type&&t.left.operator===t.operator?t.left.right:t.left;if((e=>{for(let t=e.parent;t;t=t.parent)if("WithStatement"===t.type)return!0;return!1})(t)||!b6(o)||!b6(t.right)||!ly(o,t.right))return;let a={node:t.right,messageId:b1};if(r=t.left,!e.sourceCode.getCommentsInside(t).every(t=>((e,t,r)=>{let[n,o]=r.sourceCode.getRange(e),[a,i]=eH(t,r);return n>=a&&o<=i})(t,r,e)))return a;let i=eZ(t.left,e),s=e=>e.replaceText(t,i);return b8.has(o.type)&&(n=t.right,b8.has(n.type))?{...a,fix:s}:{...a,suggest:[{messageId:b2,fix:s}]}})},meta:{type:"problem",docs:{description:"Disallow adjacent duplicate operands in logical expressions.",recommended:"unopinionated"},fixable:"code",hasSuggestions:!0,schema:[],messages:{[b1]:"This operand duplicates the left operand.",[b2]:"Remove the duplicate operand."},languages:["js/js"]}},"unicorn/no-impossible-length-comparison":{create:e=>{e.on("BinaryExpression",t=>{let r,n,o,a;if(!Object.hasOwn(b5,t.operator))return;let i=(r=ry(t.left),n=ry(t.right),rl(r)?{memberExpression:r,operator:t.operator,value:ew(n,e.sourceCode.getScope(n))?.value}:rl(n)?{memberExpression:n,operator:b5[t.operator],value:ew(r,e.sourceCode.getScope(r))?.value}:void 0);if(!i)return;let{memberExpression:s}=i;if("ThisExpression"===(o=ry(s.object)).type||"Super"===o.type||function e(t){return!!("ChainExpression"===(t=ry(t)).type||rh(t))||("MemberExpression"===t.type?e(t.object):"CallExpression"===t.type&&e(t.callee))}(s.object)||(a=ew(s,e.sourceCode.getScope(s)))&&(!Number.isSafeInteger(a.value)||a.value<0)||function({node:e,lengthOrSizeNode:t}){let r=function(e){for(;tE(e.parent)&&"&&"===e.parent.operator;)e=e.parent;return e}(e);return"LogicalExpression"===r.type&&"&&"===r.operator&&(function e(t){return[t.left,t.right].flatMap(r=>"LogicalExpression"===r.type&&r.operator===t.operator?e(r):[r])})(r).some(r=>r!==e&&tc(r,{computed:!1,optional:!1})&&"Identifier"===r.property.type&&rs.has(r.property.name)&&tQ(r.object,t.object))}({node:t,lengthOrSizeNode:s}))return;let l=function({operator:e,value:t}){if("number"==typeof t&&Number.isFinite(t))switch(e){case"<":return!(t<=0)&&void 0;case"<=":case"===":case"==":return!(t<0)&&void 0;case">":case"!==":case"!=":return t<0||void 0;case">=":return t<=0||void 0}}(i);if(void 0!==l)return{node:t,messageId:b9,data:{property:s.property.name,result:String(l)}}})},meta:{type:"problem",docs:{description:"Disallow impossible comparisons against `.length` or `.size`.",recommended:"unopinionated"},messages:{[b9]:"This comparison is always {{result}} because `.{{property}}` is always a non-negative integer."},languages:["js/js"]}},"unicorn/no-invalid-character-comparison":{create:e=>{e.on("BinaryExpression",t=>{if(b7.has(t.operator))for(let[r,n]of[[t.left,t.right],[t.right,t.left]]){let o=e3(n);if(void 0!==o&&o.length>1&&Ee(r,e)){let e="!=="===t.operator||"!="===t.operator;return{node:t,messageId:b4,data:{string:o,result:e?"true":"false"}}}}})},meta:{type:"problem",docs:{description:"Disallow comparing a single character from a string to a multi-character string.",recommended:"unopinionated"},schema:[],messages:{[b4]:"A single character can never equal the multi-character string `{{string}}`, so this comparison is always {{result}}."},languages:["js/js"]}},"unicorn/no-loop-iterable-mutation":{create:e=>{let t=new WeakSet,r=oe(e);e.onExit("ForOfStatement",n=>{if(n.await)return;let o=Ed(n.right,e);if(o)return function* e(t,r,n,o){if(Es.has(t.type))return;let a=n;if("ForOfStatement"===t.type&&!t.await){let e=Ed(t.right,o);e&&Ey(e.reference,r.iterable,o)&&(a=Ef(t,e))}if("CallExpression"===t.type){let e=function(e,t,r,n){if("MemberExpression"!==e.callee.type)return;let{addArgumentIdentifier:o,deleteArgumentIdentifier:a,iterable:i,reportedCallExpressions:s,setKeyIdentifier:l}=t,{object:u,property:p}=e.callee,c=eI(e.callee,n.sourceCode.getScope(e.callee));if(!(!Ea[t.collectionKind??"unknown"].has(c)||!Ey(u,i,n)||"delete"===c&&Eh(e,a,n)||Ex(e,{addArgumentIdentifier:o,setKeyIdentifier:l},c,n)&&!function e(t,r,n){let o=function(e){let t=e;for(;t.parent&&"BlockStatement"!==t.parent.type&&"SwitchCase"!==t.parent.type;)t=t.parent;if(t.parent)return{parent:t.parent,statement:t,statements:"SwitchCase"===t.parent.type?t.parent.consequent:t.parent.body}}(t);if(!o)return!1;let{statement:a,statements:i}=o,s=i.indexOf(a);return!!i.slice(0,s).some(e=>(function e(t,r,n){let o=function(e){if("ExpressionStatement"!==e.type)return;let t=ry(e.expression);return"CallExpression"===t.type?t:void 0}(t);if(o)return"MemberExpression"===o.callee.type&&"delete"===eI(o.callee,n.sourceCode.getScope(o.callee))&&Ey(o.callee.object,r.iterable,n)&&Eh(o,r.deleteArgumentIdentifier,n);return"BlockStatement"===t.type?t.body.some(t=>e(t,r,n)):"IfStatement"===t.type&&(!r.branchAlwaysExits(t.consequent)&&e(t.consequent,r,n)||t.alternate&&!r.branchAlwaysExits(t.alternate)&&e(t.alternate,r,n))})(e,r,n))||o.parent!==r.loopBody&&e(o.parent,r,n)}(e,t,n)||r&&Ex(e,r,c,n))&&!s.has(e))return s.add(e),{node:p,messageId:Et,data:{iterable:n.sourceCode.getText(i)}}}(t,r,n,o);e&&(yield e)}for(let n of o.sourceCode.visitorKeys[t.type]??[]){let i=t[n];if(Array.isArray(i)){for(let t of i)t&&(yield*e(t,r,a,o));continue}i&&(yield*e(i,r,a,o))}}(n.body,{branchAlwaysExits:r,...Ef(n,o),reportedCallExpressions:t},void 0,e)})},meta:{type:"problem",docs:{description:"Disallow mutating a loop iterable during iteration.",recommended:!0},schema:[],messages:{[Et]:"Do not mutate `{{iterable}}` while iterating over it."},languages:["js/js"]}},"unicorn/no-selector-as-dom-name":{create:e=>{let{sourceCode:t}=e;e.on("CallExpression",function*(e){for(let{node:r,expectedPrefix:n}of(e=>{if(td(e,{methods:EE})&&tc(e.callee.object,{property:"classList",computed:!1})&&!nT(ry(e.callee.object.object))){let t=e.callee.property.name;return"add"===t||"remove"===t?ET(e.arguments,"."):"replace"===t?e.arguments[0]?.type==="SpreadElement"?[]:ET(e.arguments.slice(0,2),"."):ET(e.arguments.slice(0,1),".")}if(td(e,{methods:["getElementById","getElementsByClassName"],argumentsLength:1})&&!nT(ry(e.callee.object))){let t="getElementById"===e.callee.property.name?"#":".";return ET(e.arguments,t)}return[]})(e)){if("SpreadElement"===r.type)continue;let e=ry(r),o=EC(e);Ev(o)&&(yield EA(e,o,n,t))}})},meta:{type:"problem",docs:{description:"Disallow selector syntax in DOM names.",recommended:!0},fixable:"code",messages:{[Eb]:"Do not use selector syntax in DOM names."},languages:["js/js"]}},"unicorn/no-useless-compound-assignment":{create:e=>{let{sourceCode:t}=e;e.on("AssignmentExpression",r=>{if(!Ej.has(r.operator)||!e8(r.right)||r.right.value!==Ej.get(r.operator))return;let n={operator:r.operator,value:r.right.raw};if(t.getCommentsInside(r).length>0)return{node:r,messageId:Ew,data:n};let{parent:o}=r;if("ExpressionStatement"===o.type&&["Program","BlockStatement","StaticBlock","SwitchCase"].includes(o.parent.type))return{node:r,messageId:Ew,data:n,suggest:[{messageId:Ek,fix:t=>oq(o,e,t)}]};let a=t.getText(r.left);return{node:r,messageId:Ew,data:n,suggest:[{messageId:EI,data:{left:a},fix:e=>e.replaceText(r,a)}]}})},meta:{type:"suggestion",docs:{description:"Disallow useless compound assignments such as `x += 0`.",recommended:"unopinionated"},hasSuggestions:!0,messages:{[Ew]:"This compound assignment is useless as `{{operator}} {{value}}` does not change the value.",[Ek]:"Remove the useless assignment.",[EI]:"Replace the useless assignment with `{{left}}`."},languages:["js/js"]}},"unicorn/no-useless-delete-check":{create:e=>{e.on("IfStatement",t=>{let r=function(e,t){if(e.alternate||"IfStatement"===e.parent.type&&e.parent.alternate===e)return;let r=(e=>{if("BlockStatement"===e.type){if(1!==e.body.length)return;e=e.body[0]}return"ExpressionStatement"===e.type?e.expression:void 0})(e.consequent);if(r)return"UnaryExpression"===r.type&&"delete"===r.operator?function(e,t,r){let n,{test:o}=e,{argument:a}=t;if("BinaryExpression"===o.type&&"in"===o.operator&&"MemberExpression"===a.type&&!a.optional&&tQ(o.right,a.object)&&EW(o.right,r)&&E_(o.left,r)&&E_(o.right,r)&&(!a.computed||E_(a.property,r))){if(a.computed)n=((e,t,r)=>{if(tQ(e,t))return!((e,t)=>{var r;let n;if(EW(e,t)||Eq(ry(e),t))return!0;let o=ra(ry(e),t);if(!o)return!1;let a=ry(o);return"NewExpression"===a.type||"CallExpression"===(r="ChainExpression"===(n=r=a).type?n.expression:n).type&&void 0===EU(r,t)})(e,r);let n=EU(e,r),o=EU(t,r);return void 0!==n&&n===o})(o.left,a.property,r);else{let e=eI(a,r.sourceCode.getScope(a));n=null!==e&&e===EU(o.left,r)}return n?{suggest:[{messageId:EB,fix:Ez(e,t,r)}]}:void 0}}(e,r,t):function(e,t,r){let{test:n}=e;if(EV(n,"has")&&EV(t,"delete")&&((e,t)=>{let r;if("Identifier"!==(e=ry(e)).type)return!1;let n=ra(e,t);if(!n)return!1;let o=ry(n);return"NewExpression"===o.type&&(r=o.callee,"Identifier"===r.type&&E$.has(r.name)&&t.sourceCode.isGlobalReference(r))})(n.callee.object,r)&&tQ(n.callee.object,t.callee.object)&&tQ(n.arguments[0],t.arguments[0])&&E_(n.arguments[0],r))return{fix:Ez(e,t,r)}}(e,r,t)}(t,e);if(r)return{node:t.test,messageId:EF,fix:r.fix,suggest:r.suggest}})},meta:{type:"suggestion",docs:{description:"Disallow unnecessary existence checks before deletion.",recommended:"unopinionated"},fixable:"code",hasSuggestions:!0,schema:[],messages:{[EF]:"The existence check before deletion is unnecessary.",[EB]:"Remove the existence check."},languages:["js/js"]}},"unicorn/no-useless-logical-operand":{create:e=>{e.on("LogicalExpression",t=>{if(!EG.has(t.operator)||"LogicalExpression"===t.parent.type&&t.parent.operator===t.operator)return;let r=function(e,t){let r,n,{operator:o}=e,a=function e(t,r){return"LogicalExpression"===t.type&&t.operator===r?[...e(t.left,r),...e(t.right,r)]:[t]}(e,o),i=(r=EJ.get(o),e2(a[0],r)?a[0]:void 0);if(i)return{target:i,replacementOperands:[i]};let s=(n=EG.get(o),a.filter((e,r)=>e2(e,n)&&function(e,t,r){var n;if(t<e.length-1)return!0;let o=e.slice(0,-1);return tA(n=e[t].parent,r)||tT(n)||o.every(e=>ny(e,r))}(a,r,t)));if(0===s.length)return;let l=a.filter(e=>!s.includes(e));return{target:s[0],replacementOperands:0===l.length?[s.at(-1)]:l}}(t,e);if(!r)return;let{target:n,replacementOperands:o}=r;if(1===o.length&&e1(ry(o[0]))&&function(e){let{parent:t}=e;if("ExpressionStatement"!==t.type||t.expression!==e)return!1;let r=t.parent,n=r.parent;if("Program"!==r.type&&!("BlockStatement"===r.type&&tl(n)))return!1;let o=r.body.indexOf(t);return r.body.slice(0,o).every(e=>"string"==typeof e.directive)}(t))return;let a={node:n,messageId:EK,data:{operator:t.operator}};return e.sourceCode.getCommentsInside(t).length>0||(1===o.length?a.fix=r=>oj(r,t,o[0],e):a.fix=r=>{var n;let a;return r.replaceText(t,(n=t.operator,a=o.map((t,r)=>{let o,a;return o=eQ(t,e),a=eZ(t,e),!o&&n6(t,{operator:n,property:0===r?"left":"right"})&&(a=`(${a})`),0===r&&!o&&EX.has(ry(t).type)&&(a=`(${a})`),a}).join(` ${n} `),nW(e.sourceCode.getTokenBefore(t),e,a)?`;${a}`:a))}),a})},meta:{type:"suggestion",docs:{description:"Disallow unnecessary operands in logical expressions involving boolean literals.",recommended:"unopinionated"},fixable:"code",schema:[],messages:{[EK]:"Simplify this `{{operator}}` expression."},languages:["js/js"]}},"unicorn/prefer-boolean-return":{create:e=>{let{sourceCode:t}=e;function r(n,o,a,i=t.getRange(n)){let s;if(!o||!a||"ConditionalExpression"===n.test.type)return;let l=EQ(o),u=EQ(a);if(void 0===l||void 0===u||l===u)return;let p={node:n,messageId:EY},c=!l,d=t.getCommentsInside(n).length>0||t.getCommentsInside(a).length>0||t7(e,a),m=!c&&!E0(n.test,e)&&!!(s=ei(t.getScope(n),"Boolean"))&&0!==s.defs.length;return d||m?p:{...p,fix:t=>t.replaceTextRange(i,`return ${function(t,r){let n=eZ(t,e);if(r)return n8(t,"!")?`!(${n})`:`!${n}`;if(E0(t,e))return n;let o="SequenceExpression"===t.type?`(${n})`:n;return`Boolean(${o})`}(n.test,c)};`)}}e.on("IfStatement",n=>{if(!n.alternate){let o=on(n,e);if(!o||"ReturnStatement"!==o.type)return;let a=r(n,EZ(n.consequent),o,[t.getRange(n)[0],t.getRange(o)[1]]);return a?.fix&&t.getTokensBetween(n,o,{includeComments:!0}).some(e=>"Block"===e.type||"Line"===e.type)?{node:n,messageId:EY}:a}return r(n,EZ(n.consequent),EZ(n.alternate))})},meta:{type:"suggestion",docs:{description:"Prefer directly returning boolean expressions over `if` statements.",recommended:"unopinionated"},fixable:"code",schema:[],messages:{[EY]:"Return the boolean expression directly."},languages:["js/js"]}},"unicorn/prefer-continue":E7,"unicorn/prefer-flat-math-min-max":{create:e=>{let{sourceCode:t}=e;e.on("CallExpression",e=>{let r=(e=>{for(let t of Dt)if(Dr(e,t))return t})(e);if(!(!r||!e.arguments.some(e=>Dr(e,r))||((e,t)=>{let{parent:r}=e;return Dr(r,t)&&r.arguments.includes(e)})(e,r)))return{node:e,messageId:De,data:{method:r},*fix(n,{abort:o}){if(t.getCommentsInside(e).length>0)return o();let a=t.getText(e.callee),i=Dn(e,r).map(e=>t.getText(e)).join(", ");yield n.replaceText(e,`${a}(${i})`)}}})},meta:{type:"suggestion",docs:{description:"Prefer flat `Math.min()` and `Math.max()` calls over nested calls.",recommended:"unopinionated"},fixable:"code",schema:[],messages:{[De]:"Prefer a flat `Math.{{method}}()` call instead of nested calls."},languages:["js/js"]}},"unicorn/prefer-hoisting-branch-code":{create:e=>{e.on("IfStatement",t=>(function*(e,t){if("IfStatement"===e.parent.type&&e.parent.alternate===e)return;let r=function(e){let t=[],r=e;for(;r?.type==="IfStatement";r=r.alternate)t.push(r.consequent);if(r)return t.push(r),t}(e);if(!r||r.some(e=>"BlockStatement"!==e.type))return;let{sourceCode:n}=t,{leading:o,trailing:a,minLength:i}=function(e,t){let r=Math.min(...e.map(e=>e.length)),n=0;for(;n<r&&e.every(r=>Dp(r[n],e[0][n],t));)n++;let o=0;for(;n+o<r&&e.every(r=>Dp(r.at(-1-o),e[0].at(-1-o),t));)o++;return{leading:n,trailing:o,minLength:r}}(r.map(e=>e.body),n);0===o&&0===a||!(o+a>=i)&&(o>0&&(yield Dd({ifStatement:e,blocks:r,leading:o,trailing:a,isStart:!0},t)),a>0&&(yield Dd({ifStatement:e,blocks:r,leading:o,trailing:a,isStart:!1},t)))})(t,e))},meta:{type:"suggestion",docs:{description:"Prefer moving code shared by all branches of an `if` statement out of the branches.",recommended:!0},fixable:"code",hasSuggestions:!0,messages:{[Do]:"These branches start with the same code. Move it before the `if` statement.",[Da]:"These branches end with the same code. Move it after the `if` statement.",[Di]:"Move the shared code out of the branches."},languages:["js/js"]}},"unicorn/prefer-single-replace":{create:e=>{let{sourceCode:t}=e;e.on("CallExpression",r=>{if(void 0===Dh(r))return;let n=r.arguments[1];if(!e1(n))return;let o=n.value;if(o.includes("$`")||o.includes("$'"))return;let a=e=>void 0!==Dh(e)&&e1(e.arguments[1])&&e.arguments[1].value===o,{parent:i}=r;if("MemberExpression"===i.type&&i.object===r&&"CallExpression"===i.parent.type&&i.parent.callee===i&&a(i.parent))return;let s=[],l=r;for(;a(l);)s.push(Dh(l)),l=l.callee.object;if(s.length<2)return;let u=l;s.reverse();let p=[...new Set(s)];if(p.some(e=>o.includes(e)))return;let c={node:r,messageId:Df};if(0===t.getCommentsInside(r).length){let t=p.map((e,t)=>(function(e,t,r){if(Dy.has(e))return Dy.get(e);if("^"===e)return t?String.raw`\^`:"^";if("-"===e)return t||r?"-":String.raw`\-`;let n=e.codePointAt(0);return n<32||127===n?String.raw`\x${n.toString(16).toUpperCase().padStart(2,"0")}`:e})(e,0===t,t===p.length-1)).join(""),o=eZ(u,e),a=eZ(n,e);c.fix=e=>e.replaceText(r,`${o}.replaceAll(/[${t}]/g, ${a})`)}return c})},meta:{type:"suggestion",docs:{description:"Enforce combining multiple single-character replacements into a single `String#replaceAll()` with a regular expression.",recommended:"unopinionated"},fixable:"code",messages:{[Df]:"Combine these single-character replacements into a single `replaceAll()` with a regular expression."},languages:["js/js"]}}}).map(([e,t])=>{let r;return[e,{meta:{schema:[],...t.meta,docs:{...t.meta.docs,url:(r=d.basename(e,".js"),`https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v68.0.0/docs/rules/${r}.md`)}},create:nH(t.create)}]})))};module.exports=Dx;
|
|
36
|
+
${i}});`)}(a,i,e)),l})},meta:{type:"suggestion",docs:{description:"Prefer `Object.defineProperties()` over multiple `Object.defineProperty()` calls.",recommended:"unopinionated"},fixable:"code",schema:[],messages:{[ha]:"Prefer `Object.defineProperties()` over multiple `Object.defineProperty()` calls."},languages:["js/js"]}},"unicorn/prefer-object-destructuring-defaults":{create:e=>{e.on("VariableDeclarator",t=>{let{id:r,init:n}=t;if("ObjectPattern"!==r.type||n?.type!=="ObjectExpression"||0!==e.sourceCode.getCommentsInside(t).length)return;let o=((e,t)=>{if(e.typeAnnotation)return;let r=[];for(let n of e.properties){if(!(hc(n)&&"Identifier"===n.value.type))return;let e=eI(n,t.sourceCode.getScope(n));if(null===e||hu.has(e))return;r.push({node:n,name:e})}return r})(r,e),a=((e,t)=>{let{properties:r}=e,n=r.at(-1);if(n?.type!=="SpreadElement"||eP(n.argument,t.sourceCode,hp))return;let o=new Map;for(let e of r.slice(0,-1)){if(!hc(e)||eP(e.value,t.sourceCode,hp))return;let r=eI(e,t.sourceCode.getScope(e));if(null===r||o.has(r))return;o.set(r,e)}return{defaultProperties:o,spreadElement:n}})(n,e);if(!o||0===o.length||!a)return;let{defaultProperties:i,spreadElement:s}=a;if(o.length!==i.size)return;let l=new Set(o.map(e=>e.node.value.name)),u=[];for(let t of o){let r=i.get(t.name);if(!r||hd(r.value,l,e))return;u.push(hm(t,r,e))}return{node:t,messageId:hs,suggest:[{messageId:hl,fix:r=>r.replaceText(t,`{${u.join(", ")}} = {${e.sourceCode.getText(s)}}`)}]}})},meta:{type:"suggestion",docs:{description:"Prefer object destructuring defaults over default object literals with spread.",recommended:!0},hasSuggestions:!0,schema:[],messages:{[hs]:"Prefer object destructuring defaults over default object literals with spread.",[hl]:"Use object destructuring defaults."},languages:["js/js"]}},"unicorn/prefer-single-object-destructuring":{create:e=>{let{sourceCode:t}=e;e.on("Program",e=>hh(t,e.body)),e.on(["BlockStatement","StaticBlock"],e=>hh(t,e.body)),e.on("SwitchCase",e=>hh(t,e.consequent))},meta:{type:"suggestion",docs:{description:"Prefer a single object destructuring declaration per local const source.",recommended:!0},fixable:"code",schema:[],messages:{[hf]:"Prefer a single object destructuring declaration from `{{source}}`."},languages:["js/js"]}},"unicorn/prefer-smaller-scope":{create:e=>{let{sourceCode:t}=e;e.on("VariableDeclaration",e=>(function(e,t){if(!(e.parent&&("Program"===e.parent.type||"BlockStatement"===e.parent.type)&&"let"===e.kind&&1===e.declarations.length&&"Identifier"===e.declarations[0].id.type&&!e.declarations[0].init))return;let[r]=e.declarations,[n]=t.getDeclaredVariables(r),o=n.references.filter(e=>!e.init),a=o.filter(e=>e.isWrite());if(1!==a.length||o.every(e=>!e.isRead()))return;let i=function(e){let{identifier:t}=e,r=t.parent;if("AssignmentExpression"!==r.type||"="!==r.operator||r.left!==t||"ExpressionStatement"!==r.parent.type)return;let n=r.parent,o=n.parent;if("BlockStatement"===o.type)return{assignmentExpression:r,assignmentStatement:n,block:o}}(a[0]);if(!i)return;let{assignmentExpression:s,assignmentStatement:l,block:u}=i,[,p]=t.getRange(e),[c,d]=t.getRange(l);if(!hE(u,e.parent)||function e(t,r){if("WithStatement"===t.type||"CallExpression"===t.type&&"Identifier"===t.callee.type&&"eval"===t.callee.name)return!0;for(let n of r[t.type]??[]){let o=t[n];if(Array.isArray(o)){if(o.some(t=>t&&e(t,r)))return!0}else if(o&&e(o,r))return!0}return!1}(e.parent,t.visitorKeys)||c<p||o.some(e=>!hE(e.identifier,u))||o.some(e=>e.isRead()&&t.getRange(e.identifier)[0]<d))return;let m={node:r.id,messageId:hx,data:{name:r.id.name}};return r.id.typeAnnotation||hS(t,s)&&"SequenceExpression"===s.right.type||t.getCommentsInside(e).length>0||t.getCommentsInside(l).length>0||hD(t,e,"before")||hD(t,e,"after")||hD(t,l,"before")||hD(t,l,"after")||(m.fix=function({sourceCode:e,declaration:t,assignmentExpression:r,assignmentStatement:n,name:o}){return function*(a){yield oq(t,{sourceCode:e},a);let i=`const ${o} = `;if(hS(e,r))return void(yield a.replaceText(n,`${i}${e.getText(r.right)};`));let[s]=e.getRange(r),[l]=e.getRange(r.right);yield a.replaceTextRange([s,l],i)}}({sourceCode:t,declaration:e,assignmentExpression:s,assignmentStatement:l,name:r.id.name})),m})(e,t))},meta:{type:"suggestion",docs:{description:"Prefer declaring variables in the smallest possible scope.",recommended:!0},fixable:"code",schema:[],messages:{[hx]:"Move `{{name}}` into the block where it is used."},languages:["js/js"]}},"unicorn/prefer-single-array-predicate":{create:e=>{e.on("LogicalExpression",t=>{if("LogicalExpression"===t.parent.type&&t.parent.operator===t.operator)return;let r=hA.get(t.operator);if(!r||e.sourceCode.getCommentsInside(t).length>0)return;let n=(function e(t,r){return"LogicalExpression"!==t.type||t.operator!==r?[t]:[...e(t.left,r),...e(t.right,r)]})(t,t.operator).map(t=>(function(e,t,r){if(!td(e,{method:t,argumentsLength:1,optionalCall:!1,optionalMember:!1})||e.typeArguments||e.typeParameters)return;let{object:n}=e.callee;if(rG(n,r))return;let o=function(e){if("ArrowFunctionExpression"===e.type&&!e.async&&!e.returnType&&!e.typeParameters&&1===e.params.length&&"Identifier"===e.params[0].type&&"BlockStatement"!==e.body.type)return{parameter:e.params[0],body:e.body}}(e.arguments[0]);if(o){var a;let t;return{node:e,object:n,callback:{...o,parameterText:(a=o.parameter,t=r.sourceCode.getText(a),a.typeAnnotation||a.optional?`(${t})`:t)}}}})(t,r,e));if(!(n.length<2||n.includes(void 0)||n.some(e=>{let t;return t=n[0],!tQ(t.object,e.object)||t.callback.parameterText!==e.callback.parameterText})))return{node:t,messageId:hv,data:{method:r},suggest:[{messageId:hC,data:{method:r},fix:r=>r.replaceText(t,function(e,t,r){let{sourceCode:n}=r,[o]=e,{callback:a}=o,i=e.map(({callback:e})=>(function(e,t,r){var n,o;if(eQ(e,r))return eZ(e,r);let a=r.sourceCode.getText(e);return(n=e,o=t,"LogicalExpression"===n.type?n.operator!==o&&("||"!==o||"&&"!==n.operator):hT.has(n.type))?`(${a})`:a})(e.body,t,r)).join(` ${t} `);return`${n.getText(o.node.callee)}(${a.parameterText} => ${i})`}(n,t.operator,e))}]}})},meta:{type:"suggestion",docs:{description:"Prefer a single `Array#some()` or `Array#every()` with a combined predicate.",recommended:"unopinionated"},hasSuggestions:!0,messages:{[hv]:"Prefer a single `Array#{{method}}()` with a combined predicate.",[hC]:"Merge predicates into one `Array#{{method}}()` call."},languages:["js/js"]}},"unicorn/prefer-url-href":{create:e=>{e.on("CallExpression",t=>{if(td(t,{method:"toString",argumentsLength:0,optionalCall:!1,optionalMember:!1,computed:!1})&&"url"===hz(t.callee.object,e)){let r={node:t.callee.property,messageId:hw};return hG(t,e)&&!eQ(t.callee,e)&&hK(t.callee.object,e)&&(r.fix=r=>r.replaceTextRange([e.sourceCode.getRange(t.callee.property)[0],e.sourceCode.getRange(t)[1]],"href")),r}if(!(e7(t,{name:"String",argumentsLength:1,optional:!1})&&nR(t.callee,e)))return;let[r]=t.arguments;if("url"!==hz(r,e))return;let n={node:t.callee,messageId:hw};return hG(t,e)&&hK(r,e)&&(n.fix=n=>{let o,a,i;return n.replaceText(t,(o=eZ(r,e),a=!eQ(r,e)&&n2(r,e)?`(${o})`:o,i=`${a}.href`,(nW(e.sourceCode.getTokenBefore(r.parent),e,i)?";":"")+i))}),n})},meta:{type:"suggestion",docs:{description:"Prefer `URL#href` over stringifying a `URL`.",recommended:"unopinionated"},fixable:"code",messages:{[hw]:"Prefer `URL#href` over stringifying a `URL`."},languages:["js/js"]}},"unicorn/require-proxy-trap-boolean-return":{create:e=>{let{sourceCode:t}=e,r=new WeakMap,n=[];function*o(e){let n;if(!(te(n=e,{name:"Proxy",argumentsLength:2})||td(n,{object:"Proxy",method:"revocable",argumentsLength:2,optionalCall:!1,optionalMember:!1,computed:!1})))return;let o=e.arguments[1];if("ObjectExpression"===o.type)for(let e of o.properties){let n=h2(e,t);if(!n)continue;let o=h3(n,t,r);o&&(yield o)}}e.on("onCodePathStart",()=>{n.push(new Set)}),e.on("onCodePathEnd",()=>{n.pop()}),e.on("onCodePathSegmentStart",e=>{n.at(-1).add(e)}),e.on("onCodePathSegmentEnd",e=>{n.at(-1).delete(e)}),e.on("onUnreachableCodePathSegmentStart",e=>{n.at(-1).add(e)}),e.on("onUnreachableCodePathSegmentEnd",e=>{n.at(-1).delete(e)}),e.onExit("BlockStatement",e=>{if(!(hY.has(e.parent?.type)&&e.parent.body===e))return;let t=[...n.at(-1)].every(e=>!e.reachable);r.set(e.parent,t)}),e.onExit("CallExpression",o),e.onExit("NewExpression",o)},meta:{type:"problem",docs:{description:"Require boolean-returning Proxy traps to return booleans.",recommended:"unopinionated"},fixable:"code",messages:{[hJ]:"Proxy trap `{{name}}` should return a boolean."},languages:["js/js"]}},"unicorn/logical-assignment-operators":h7,"unicorn/no-useless-coercion":{create:e=>{let{sourceCode:t}=e,r=(r,n,o,a)=>({node:r,messageId:xe,data:{description:o,type:a},*fix(o,{abort:a}){if(t.getCommentsInside(r).length>0)return a();yield oj(o,r,n,e)}});e.on("CallExpression",t=>{if(t.optional||"Identifier"!==t.callee.type||1!==t.arguments.length||"SpreadElement"===t.arguments[0].type)return;let{name:n}=t.callee,o=xt.get(n);if(!o||!nR(t.callee,e))return;let[a]=t.arguments;if(o.isType(a,e))return r(t,a,`\`${n}()\``,o.type)}),e.on("UnaryExpression",e=>{if("+"===e.operator&&nr(e.argument,t.getScope(e.argument)))return r(e,e.argument,"`+`","number")}),e.on("BinaryExpression",t=>{let n;if("+"!==t.operator)return;let{left:o,right:a}=t;if(xr(a)&&nC(o,e))n=o;else{if(!(xr(o)&&nC(a,e)))return;n=a}return r(t,n,"Concatenation with `''`","string")}),e.on("CallExpression",t=>{let{callee:n}=t;if(!t.optional&&!(t.arguments.length>0)&&"MemberExpression"===n.type&&!n.optional&&!n.computed&&"Identifier"===n.property.type&&"toString"===n.property.name&&nC(n.object,e))return r(t,n.object,"`.toString()`","string")})},meta:{type:"suggestion",docs:{description:"Disallow useless type coercions of values that are already of the target type.",recommended:"unopinionated"},fixable:"code",messages:{[xe]:"{{description}} is unnecessary because the value is already a {{type}}."},languages:["js/js"]}},"unicorn/no-useless-boolean-cast":{create:e=>{let{sourceCode:t}=e;e.on("CallExpression",r=>{if(!td(r,{methods:xo,minimumArguments:1,maximumArguments:2,optionalCall:!1,optionalMember:!1}))return;let[n]=r.arguments;if(!tl(n))return;let o=function(e){if(!e.async&&!e.generator&&!e.returnType){if("ArrowFunctionExpression"===e.type&&"BlockStatement"!==e.body.type)return e.body;if("BlockStatement"===e.body.type&&1===e.body.body.length&&"ReturnStatement"===e.body.body[0].type)return e.body.body[0].argument}}(n);if(!tC(o,e)||t.getCommentsInside(o).length>0)return;let[a]=o.arguments;if(!(n.params[0]?.type==="Identifier"&&nB(n.params[0],a)))return{node:o,messageId:xn,data:{method:r.callee.property.name},fix(e){let r,i=t.getText(a);return"ArrowFunctionExpression"===n.type&&n.body===o&&(r=i,"SequenceExpression"===a.type||r.trimStart().startsWith("{"))&&(i=`(${i})`),e.replaceText(o,i)}}})},meta:{type:"suggestion",docs:{description:"Disallow unnecessary `Boolean()` casts in array predicate callbacks.",recommended:"unopinionated"},fixable:"code",messages:{[xn]:"`Boolean()` is unnecessary in `Array#{{method}}()` callbacks."},languages:["js/js"]}},"unicorn/no-useless-continue":{create:e=>{e.on("ContinueStatement",t=>{if(!t.label&&(e=>{if("BlockStatement"!==e.parent.type)return!1;let t=e;for(;;){let{parent:e}=t;if("BlockStatement"===e.type){if(e.body.at(-1)!==t)return!1;t=e;continue}if("IfStatement"===e.type&&(e.consequent===t||e.alternate===t)){t=e;continue}return tp(e)&&e.body===t}})(t))return{node:t,messageId:xa,fix:r=>oq(t,e,r)}})},meta:{type:"suggestion",docs:{description:"Disallow useless `continue` statements.",recommended:"unopinionated"},fixable:"code",messages:{[xa]:"Unnecessary `continue` statement."},languages:["js/js"]}},"unicorn/no-useless-override":{create:e=>{let{sourceCode:t}=e;e.on("MethodDefinition",r=>{let n;if("method"!==r.kind||r.accessibility||r.optional||r.decorators?.length>0||r.value.params.some(e=>e.decorators?.length>0))return;let{value:o}=r;if("FunctionExpression"!==o.type||!o.body||o.generator||!r.parent.parent.superClass)return;let a=function(e,t){let r,n,o,{value:a}=e;if(1!==a.body.body.length)return;let[i]=a.body.body;if("ReturnStatement"===i.type?r=i.argument:"ExpressionStatement"===i.type&&(r=i.expression),r?.type!=="CallExpression"||r.optional)return;let{callee:s}=r;if("MemberExpression"!==s.type||s.optional||"Super"!==s.object.type)return;let l=t.getScope(r),u=eI(e,l);if("string"==typeof u&&eI(s,l)===u&&(n=r.arguments,o=a.params,n.length===o.length&&o.every((e,t)=>{let r=n[t];return"Identifier"===e.type?"Identifier"===r.type&&r.name===e.name:"RestElement"===e.type&&"Identifier"===e.argument.type&&"SpreadElement"===r.type&&"Identifier"===r.argument.type&&r.argument.name===e.argument.name})))return{callExpression:r,name:u,isReturned:"ReturnStatement"===i.type}}(r,t);if(!a)return;let{callExpression:i,name:s,isReturned:l}=a;if(n=t.getScope(r),!r.parent.body.some(e=>e!==r&&"MethodDefinition"===e.type&&"method"===e.kind&&e.static===r.static&&null===e.value.body&&eI(e,n)===s)){if(l){let t;if(o.async&&(void 0===(t=xl(i,e))||!0!==function e(t,r){let n;if(n=t=r.getNonNullableType(t),!rD.has(n.intrinsicName)){if(t.isUnion()){let n=t.types.map(t=>e(t,r));return!!n.every(Boolean)||!n.every(e=>!1===e)&&void 0}return void 0!==r.getPromisedTypeOfPromise(t)}}(t.type,t.checker)))return}else{let t;if(o.async||!(void 0!==(t=xl(i,e))&&xs(t.type)))return}return{node:r.key,messageId:xi,data:{superCall:t.getText(i.callee)},*fix(n,{abort:o}){if(t.getCommentsInside(r).length>0)return o();yield oV(r,"",n,e)}}}})},meta:{type:"suggestion",docs:{description:"Disallow useless overrides of class methods.",recommended:"unopinionated"},fixable:"code",messages:{[xi]:"Useless override; this method only forwards to `{{superCall}}(…)`."},languages:["js/js"]}},"unicorn/prefer-has-check":{create:e=>{e.on("CallExpression",t=>((e,t)=>{if(!td(e,{method:"get",argumentsLength:1,computed:!1,optionalCall:!1,optionalMember:!1,allowSpreadElement:!1}))return;let r=(e=>{let t=(e=>{for(;xS.has(e.parent?.type)&&e.parent.expression===e;)e=e.parent;return e})(e),{parent:r}=t;if(r?.type==="BinaryExpression"&&["!==","===","!=","=="].includes(r.operator)){if(r.left===t)return{node:r,operator:r.operator,value:r.right};if(r.right===t)return{node:r,operator:r.operator,value:r.left}}})(e);if(r){let n,o;if(t.sourceCode.getCommentsInside(e).length>0)return;let a=((e,t,r)=>{let n=xN(e.callee.object,r);if(!n)return;let o="!="===t.operator||"=="===t.operator;if("null-sentinel"===n.kind)return o&&xI(t.value,r)?{missingType:"undefined"}:{missingType:"null"};if("map"===n.kind){if(xI(t.value,r)&&xV(e.callee.object,r,o?"not-nullish":"not-undefined"))return{missingType:"undefined"};if(xz(t.value)&&o&&xV(e.callee.object,r,"not-nullish"))return{missingType:"nullish"}}})(e,r,t);if(!a||(n=r.value,o=a.missingType,"undefined"===o?!xI(n,t):!xz(n)))return;return{node:e.callee.property,messageId:xu,fix:((e,t,r)=>{var n;let o;if(r.sourceCode.getCommentsInside(t.node).length>r.sourceCode.getCommentsInside(e).length)return;let a=`${(({operator:e})=>"!=="===e||"!="===e)(t)?"":"!"}${(o=eZ(n=e.callee.object,r),!eQ(n,r)&&n2(n,r)?`(${o})`:o)}.has(${((e,t)=>{let[r]=e.arguments;return t.sourceCode.getText(r)})(e,r)})`;return e=>e.replaceText(t.node,a)})(e,r,t)}}if((tA(e,t)||tT(e))&&xN(e.callee.object,t)?.kind==="map"&&xV(e.callee.object,t,"truthy")){if(t.sourceCode.getCommentsInside(e).length>0)return;return{node:e.callee.property,messageId:xu,fix:t=>t.replaceText(e.callee.property,"has")}}})(t,e))},meta:{type:"suggestion",docs:{description:"Prefer `.has()` when checking existence.",recommended:"unopinionated"},fixable:"code",messages:{[xu]:"Prefer `.has(…)` when checking existence."},languages:["js/js"]}},"unicorn/consistent-conditional-object-spread":{create:e=>{e.options[0]===xG?e.on("LogicalExpression",t=>{if(xH(t)){if("&&"!==t.operator||ta(t.right)||xZ(t.left,t.right,e.sourceCode))return;let r=x2(t.left,e.sourceCode);if(r&&!r.isTrueWhenNullish&&xZ(r.reference,t.right,e.sourceCode))return;let n=x8(t.left,e),o=x8(t.right,e);return{node:t,messageId:xJ,data:{expectedStyle:"ternary"},*fix(r,{abort:a}){if(e.sourceCode.getCommentsInside(t).length>0)return a();yield r.replaceText(t,`${n} ? ${o} : {}`)}}}}):e.on("ConditionalExpression",t=>{if(xH(t))return function(e,t){let{test:r,consequent:n,alternate:o}=e,a=ta(o);if(a===ta(n))return;let i=a?n:o,s=x2(r,t.sourceCode),l=t.sourceCode.getCommentsInside(e).length>0;if((a?xZ(r,i,t.sourceCode):"UnaryExpression"===r.type&&"!"===r.operator&&r.prefix&&xZ(r.argument,i,t.sourceCode))||s&&!l&&(s.isTrueWhenNullish?!a:a)&&xZ(s.reference,i,t.sourceCode))return;let u=a?x3(r,"left",t):function(e,t){if("UnaryExpression"===e.type&&"!"===e.operator&&e.prefix)return x3(e.argument,"left",t);let r=eZ(e,t);return!eQ(e,t)&&n8(e,"!")&&(r=`(${r})`),`!${r}`}(r,t),p=x3(i,"right",t);return{node:e,messageId:xJ,data:{expectedStyle:"logical"},*fix(t,{abort:r}){if(l)return r();yield t.replaceText(e,`${u} && ${p}`)}}}(t,e)})},meta:{type:"suggestion",docs:{description:"Enforce consistent conditional object spread style.",recommended:!0},fixable:"code",schema:[{description:"The conditional object spread style to enforce.",enum:[xK,xG]}],defaultOptions:[xK],messages:{[xJ]:"Prefer {{expectedStyle}} conditional object spreads."},languages:["js/js"]}},"unicorn/default-export-style":bE,"unicorn/no-array-concat-in-loop":{create:e=>{e.on("AssignmentExpression",t=>{let r=function(e,t){var r;if("="!==e.operator)return;let n="Identifier"===e.left.type?e.left:void 0,o=bD(e.right);if(!n||!td(o,{method:"concat",minimumArguments:1,optionalCall:!1,optionalMember:!1,computed:!1}))return;let a=(r=bD(r=o.callee.object),r?.type==="Identifier"?r:void 0),i=bS(n,t);if(!a||!i||i!==bS(a,t)||!function(e){let[t]=e?.defs??[];if(!t||1!==e.defs.length||"global"===e.scope.type||"Variable"!==t.type||"Identifier"!==t.node.id.type||"let"!==t.parent.kind&&"var"!==t.parent.kind)return!1;let r=t.node.init&&bD(t.node.init);return!!(r&&to(r))}(i))return;let s=function(e,t){for(let r of t.sourceCode.getAncestors(e).toReversed()){if(tl(r))return;if(tp(r))return r}}(e,t),[l]=i.defs;if(!(!s||function(e,t,r){let[n,o]=r.sourceCode.getRange(e),[a,i]=r.sourceCode.getRange(t);return n>=a&&o<=i}(l.node,s.body,t)))return{callExpression:o,property:o.callee.property}}(t,e);if(r)return{node:r.property,messageId:bv}})},meta:{type:"suggestion",docs:{description:"Disallow array accumulation with `Array#concat()` in loops.",recommended:!0},schema:[],messages:{[bv]:"Do not use `Array#concat()` to accumulate an array in a loop."},languages:["js/js"]}},"unicorn/no-array-front-mutation":{create:e=>{e.on("CallExpression",t=>{if(!td(t,{methods:["shift","unshift"],optionalCall:!1,computed:!1}))return;let{object:r,property:n}=t.callee,{name:o}=n;if(!("unshift"===o&&ty(t.callee,bA)||rX(r,e)))return{node:n,messageId:bC,data:{method:o}}})},meta:{type:"suggestion",docs:{description:"Disallow front-of-array mutation.",recommended:!1},schema:[],messages:{[bC]:"Avoid front-of-array mutation with `Array#{{method}}()`."},languages:["js/js"]}},"unicorn/no-array-sort-for-min-max":{create:e=>{e.on("MemberExpression",t=>{if(!t.computed||t.optional||!bk(t.property)||r3(t)||("ForInStatement"===t.parent.type||"ForOfStatement"===t.parent.type)&&t.parent.left===t)return;let r=bI(t.object,e);if(r)return bj(t,r,"first",e)}),e.on("CallExpression",t=>{let r;if(!td(t,{method:"at",argumentsLength:1,optionalCall:!1,optionalMember:!1}))return;let[n]=t.arguments;if(bk(n)?r="first":tm(n)&&(r="last"),!r||r3(t))return;let o=bI(t.callee.object,e);if(o)return bj(t,o,r,e)})},meta:{type:"suggestion",docs:{description:"Disallow sorting arrays to get the minimum or maximum value.",recommended:"unopinionated"},hasSuggestions:!0,messages:{[bT]:"Use `Math.{{method}}()` instead of sorting to get the {{extreme}} value.",[bw]:"Replace with `{{replacement}}`."},languages:["js/js"]}},"unicorn/no-boolean-sort-comparator":{create:e=>{e.on("CallExpression",t=>{if(!(e7(t,{minimumArguments:1})&&"MemberExpression"===t.callee.type&&bR.has(eI(t.callee,e.sourceCode.getScope(t.callee))))||rG(t.callee.object,e))return;let[r]=t.arguments;if("SpreadElement"!==r.type){let t=ry(r);if(tl(t)){let n=(e=>{if("BlockStatement"!==e.body.type)return e.body;if(1!==e.body.body.length)return;let[t]=e.body.body;if("ReturnStatement"===t.type)return t.argument})(t);if(!nm(t,e)&&!bL(r,e))return;return{node:r,messageId:bF,suggest:r===t?((e,t,r)=>{var n;if(!t||2!==e.params.length||e.params.some(e=>"Identifier"!==e.type)||e.params.some(e=>e.typeAnnotation)||e.params.some(e=>e.optional)||e.typeParameters||e.returnType||r.sourceCode.getCommentsInside(e).length>0)return;let[o,a]=e.params;if(o.name===a.name)return;let i="BinaryExpression"===(n=ry(n=t)).type&&b$.has(n.operator)?n:void 0;if(!i||rg(i.left)||rg(i.right)||!bP(i.left,i.right,o,a))return;let[s,l]=">"===i.operator||">="===i.operator?[i.left,i.right]:[i.right,i.left],u=`(${o.name}, ${a.name}) => ${r.sourceCode.getText(s)} - ${r.sourceCode.getText(l)}`;return[{messageId:bB,data:{replacement:u},fix:t=>t.replaceText(e,u)}]})(t,n,e):void 0}}return nf(t,e)||function(e,t){if("Identifier"===e.type)return("Boolean"===e.name||na.has(e.name))&&t.sourceCode.isGlobalReference(e);if("MemberExpression"!==e.type||e.optional||"Identifier"!==e.object.type||!t.sourceCode.isGlobalReference(e.object))return!1;let r=ni.get(e.object.name),n=eI(e,t.sourceCode.getScope(e));return!!r?.has(n)}(t,e)||bL(r,e)?{node:r,messageId:bF}:void 0}})},meta:{type:"problem",docs:{description:"Disallow boolean-returning sort comparators.",recommended:"unopinionated"},hasSuggestions:!0,messages:{[bF]:"Do not return a boolean from a sort comparator.",[bB]:"Replace with `{{replacement}}`."},languages:["js/js"]}},"unicorn/no-chained-comparison":{create:e=>{let{sourceCode:t}=e;e.on("BinaryExpression",r=>{let n;if(!bU.has(r.operator))return;let o=bW(r.left)?r.left:r.right;if(!bW(o))return;let a=o===r.left,i=a?r.right:r.left;if(bq.has(r.operator)&&ny(i,e))return;let s={node:r,messageId:bN},l=bO.has(o.operator)===bO.has(r.operator)&&("Literal"!==(n=r.right).type||"boolean"!=typeof n.value);if(a&&l&&!bW(r.right)&&!bW(o.left)&&((e,t)=>{if(eQ(e,t))return!0;let{parent:r}=e;return"BinaryExpression"!==r.type&&("LogicalExpression"!==r.type||"??"!==r.operator)})(r,e)&&!eP(o.right,t)&&0===t.getCommentsInside(r).length){let n=`${t.getText(r.left)} && ${eZ(o.right,e)} ${r.operator} ${eZ(r.right,e)}`;s.suggest=[{messageId:bM,data:{replacement:n},fix:e=>e.replaceText(r,n)}]}return s})},meta:{type:"problem",docs:{description:"Disallow chained comparisons such as `a < b < c`.",recommended:"unopinionated"},hasSuggestions:!0,messages:{[bN]:"Comparison operators cannot be chained. The inner comparison evaluates to a boolean, which is then compared instead of the operands.",[bM]:"Replace with `{{replacement}}`."},languages:["js/js"]}},"unicorn/no-constant-zero-expression":{create:e=>{let{sourceCode:t}=e;e.on("BinaryExpression",e=>{if(!(e=>{switch(e.operator){case"*":case"&":return e0(e.left,0)||e0(e.right,0);case"/":return e0(e.left,0);default:return!1}})(e))return;let r={node:e,messageId:b_},n=ew(e,t.getScope(e));return n&&Object.is(n.value,0)&&0===t.getCommentsInside(e).length&&(r.suggest=[{messageId:bV,fix:t=>t.replaceText(e,"0")}]),r})},meta:{type:"problem",docs:{description:"Disallow arithmetic and bitwise operations that always evaluate to `0`.",recommended:"unopinionated"},hasSuggestions:!0,messages:{[b_]:"This operation always evaluates to `0` (or `-0`/`NaN`), which is likely a mistake.",[bV]:"Replace this expression with `0`."},languages:["js/js"]}},"unicorn/no-duplicate-logical-operands":{create:e=>{e.on("LogicalExpression",t=>{let r,n;if("&&"!==t.operator&&"||"!==t.operator)return;let o="LogicalExpression"===t.left.type&&t.left.operator===t.operator?t.left.right:t.left;if((e=>{for(let t=e.parent;t;t=t.parent)if("WithStatement"===t.type)return!0;return!1})(t)||!bX(o)||!bX(t.right)||!ly(o,t.right))return;let a={node:t.right,messageId:bz};if(r=t.left,!e.sourceCode.getCommentsInside(t).every(t=>((e,t,r)=>{let[n,o]=r.sourceCode.getRange(e),[a,i]=eH(t,r);return n>=a&&o<=i})(t,r,e)))return a;let i=eZ(t.left,e),s=e=>e.replaceText(t,i);return bJ.has(o.type)&&(n=t.right,bJ.has(n.type))?{...a,fix:s}:{...a,suggest:[{messageId:bK,fix:s}]}})},meta:{type:"problem",docs:{description:"Disallow adjacent duplicate operands in logical expressions.",recommended:"unopinionated"},fixable:"code",hasSuggestions:!0,schema:[],messages:{[bz]:"This operand duplicates the left operand.",[bK]:"Remove the duplicate operand."},languages:["js/js"]}},"unicorn/no-impossible-length-comparison":{create:e=>{e.on("BinaryExpression",t=>{let r,n,o,a;if(!Object.hasOwn(bH,t.operator))return;let i=(r=ry(t.left),n=ry(t.right),rl(r)?{memberExpression:r,operator:t.operator,value:ew(n,e.sourceCode.getScope(n))?.value}:rl(n)?{memberExpression:n,operator:bH[t.operator],value:ew(r,e.sourceCode.getScope(r))?.value}:void 0);if(!i)return;let{memberExpression:s}=i;if("ThisExpression"===(o=ry(s.object)).type||"Super"===o.type||function e(t){return!!("ChainExpression"===(t=ry(t)).type||rh(t))||("MemberExpression"===t.type?e(t.object):"CallExpression"===t.type&&e(t.callee))}(s.object)||(a=ew(s,e.sourceCode.getScope(s)))&&(!Number.isSafeInteger(a.value)||a.value<0)||function({node:e,lengthOrSizeNode:t}){let r=function(e){for(;tE(e.parent)&&"&&"===e.parent.operator;)e=e.parent;return e}(e);return"LogicalExpression"===r.type&&"&&"===r.operator&&(function e(t){return[t.left,t.right].flatMap(r=>"LogicalExpression"===r.type&&r.operator===t.operator?e(r):[r])})(r).some(r=>r!==e&&tc(r,{computed:!1,optional:!1})&&"Identifier"===r.property.type&&rs.has(r.property.name)&&tQ(r.object,t.object))}({node:t,lengthOrSizeNode:s}))return;let l=function({operator:e,value:t}){if("number"==typeof t&&Number.isFinite(t))switch(e){case"<":return!(t<=0)&&void 0;case"<=":case"===":case"==":return!(t<0)&&void 0;case">":case"!==":case"!=":return t<0||void 0;case">=":return t<=0||void 0}}(i);if(void 0!==l)return{node:t,messageId:bY,data:{property:s.property.name,result:String(l)}}})},meta:{type:"problem",docs:{description:"Disallow impossible comparisons against `.length` or `.size`.",recommended:"unopinionated"},messages:{[bY]:"This comparison is always {{result}} because `.{{property}}` is always a non-negative integer."},languages:["js/js"]}},"unicorn/no-invalid-character-comparison":{create:e=>{e.on("BinaryExpression",t=>{if(bQ.has(t.operator))for(let[r,n]of[[t.left,t.right],[t.right,t.left]]){let o=e3(n);if(void 0!==o&&o.length>1&&b0(r,e)){let e="!=="===t.operator||"!="===t.operator;return{node:t,messageId:bZ,data:{string:o,result:e?"true":"false"}}}}})},meta:{type:"problem",docs:{description:"Disallow comparing a single character from a string to a multi-character string.",recommended:"unopinionated"},schema:[],messages:{[bZ]:"A single character can never equal the multi-character string `{{string}}`, so this comparison is always {{result}}."},languages:["js/js"]}},"unicorn/no-loop-iterable-mutation":{create:e=>{let t=new WeakSet,r=oe(e);e.onExit("ForOfStatement",n=>{if(n.await)return;let o=Er(n.right,e);if(o)return function* e(t,r,n,o){if(b5.has(t.type))return;let a=n;if("ForOfStatement"===t.type&&!t.await){let e=Er(t.right,o);e&&Ei(e.reference,r.iterable,o)&&(a=Eo(t,e))}if("CallExpression"===t.type){let e=function(e,t,r,n){if("MemberExpression"!==e.callee.type)return;let{addArgumentIdentifier:o,deleteArgumentIdentifier:a,iterable:i,reportedCallExpressions:s,setKeyIdentifier:l}=t,{object:u,property:p}=e.callee,c=eI(e.callee,n.sourceCode.getScope(e.callee));if(!(!b6[t.collectionKind??"unknown"].has(c)||!Ei(u,i,n)||"delete"===c&&Es(e,a,n)||El(e,{addArgumentIdentifier:o,setKeyIdentifier:l},c,n)&&!function e(t,r,n){let o=function(e){let t=e;for(;t.parent&&"BlockStatement"!==t.parent.type&&"SwitchCase"!==t.parent.type;)t=t.parent;if(t.parent)return{parent:t.parent,statement:t,statements:"SwitchCase"===t.parent.type?t.parent.consequent:t.parent.body}}(t);if(!o)return!1;let{statement:a,statements:i}=o,s=i.indexOf(a);return!!i.slice(0,s).some(e=>(function e(t,r,n){let o=function(e){if("ExpressionStatement"!==e.type)return;let t=ry(e.expression);return"CallExpression"===t.type?t:void 0}(t);if(o)return"MemberExpression"===o.callee.type&&"delete"===eI(o.callee,n.sourceCode.getScope(o.callee))&&Ei(o.callee.object,r.iterable,n)&&Es(o,r.deleteArgumentIdentifier,n);return"BlockStatement"===t.type?t.body.some(t=>e(t,r,n)):"IfStatement"===t.type&&(!r.branchAlwaysExits(t.consequent)&&e(t.consequent,r,n)||t.alternate&&!r.branchAlwaysExits(t.alternate)&&e(t.alternate,r,n))})(e,r,n))||o.parent!==r.loopBody&&e(o.parent,r,n)}(e,t,n)||r&&El(e,r,c,n))&&!s.has(e))return s.add(e),{node:p,messageId:b1,data:{iterable:n.sourceCode.getText(i)}}}(t,r,n,o);e&&(yield e)}for(let n of o.sourceCode.visitorKeys[t.type]??[]){let i=t[n];if(Array.isArray(i)){for(let t of i)t&&(yield*e(t,r,a,o));continue}i&&(yield*e(i,r,a,o))}}(n.body,{branchAlwaysExits:r,...Eo(n,o),reportedCallExpressions:t},void 0,e)})},meta:{type:"problem",docs:{description:"Disallow mutating a loop iterable during iteration.",recommended:!0},schema:[],messages:{[b1]:"Do not mutate `{{iterable}}` while iterating over it."},languages:["js/js"]}},"unicorn/no-selector-as-dom-name":{create:e=>{let{sourceCode:t}=e;e.on("CallExpression",function*(e){for(let{node:r,expectedPrefix:n}of(e=>{if(td(e,{methods:Ep})&&tc(e.callee.object,{property:"classList",computed:!1})&&!nT(ry(e.callee.object.object))){let t=e.callee.property.name;return"add"===t||"remove"===t?Ey(e.arguments,"."):"replace"===t?e.arguments[0]?.type==="SpreadElement"?[]:Ey(e.arguments.slice(0,2),"."):Ey(e.arguments.slice(0,1),".")}if(td(e,{methods:["getElementById","getElementsByClassName"],argumentsLength:1})&&!nT(ry(e.callee.object))){let t="getElementById"===e.callee.property.name?"#":".";return Ey(e.arguments,t)}return[]})(e)){if("SpreadElement"===r.type)continue;let e=ry(r),o=Ef(e);Em(o)&&(yield Eg(e,o,n,t))}})},meta:{type:"problem",docs:{description:"Disallow selector syntax in DOM names.",recommended:!0},fixable:"code",messages:{[Eu]:"Do not use selector syntax in DOM names."},languages:["js/js"]}},"unicorn/no-useless-compound-assignment":{create:e=>{let{sourceCode:t}=e;e.on("AssignmentExpression",r=>{if(!EE.has(r.operator)||!e8(r.right)||r.right.value!==EE.get(r.operator))return;let n={operator:r.operator,value:r.right.raw};if(t.getCommentsInside(r).length>0)return{node:r,messageId:Eh,data:n};let{parent:o}=r;if("ExpressionStatement"===o.type&&["Program","BlockStatement","StaticBlock","SwitchCase"].includes(o.parent.type))return{node:r,messageId:Eh,data:n,suggest:[{messageId:Ex,fix:t=>oq(o,e,t)}]};let a=t.getText(r.left);return{node:r,messageId:Eh,data:n,suggest:[{messageId:Eb,data:{left:a},fix:e=>e.replaceText(r,a)}]}})},meta:{type:"suggestion",docs:{description:"Disallow useless compound assignments such as `x += 0`.",recommended:"unopinionated"},hasSuggestions:!0,messages:{[Eh]:"This compound assignment is useless as `{{operator}} {{value}}` does not change the value.",[Ex]:"Remove the useless assignment.",[Eb]:"Replace the useless assignment with `{{left}}`."},languages:["js/js"]}},"unicorn/no-useless-delete-check":{create:e=>{e.on("IfStatement",t=>{let r=function(e,t){if(e.alternate||"IfStatement"===e.parent.type&&e.parent.alternate===e)return;let r=(e=>{if("BlockStatement"===e.type){if(1!==e.body.length)return;e=e.body[0]}return"ExpressionStatement"===e.type?e.expression:void 0})(e.consequent);if(r)return"UnaryExpression"===r.type&&"delete"===r.operator?function(e,t,r){let n,{test:o}=e,{argument:a}=t;if("BinaryExpression"===o.type&&"in"===o.operator&&"MemberExpression"===a.type&&!a.optional&&tQ(o.right,a.object)&&EB(o.right,r)&&ER(o.left,r)&&ER(o.right,r)&&(!a.computed||ER(a.property,r))){if(a.computed)n=((e,t,r)=>{if(tQ(e,t))return!((e,t)=>{var r;let n;if(EB(e,t)||Ej(ry(e),t))return!0;let o=ra(ry(e),t);if(!o)return!1;let a=ry(o);return"NewExpression"===a.type||"CallExpression"===(r="ChainExpression"===(n=r=a).type?n.expression:n).type&&void 0===EF(r,t)})(e,r);let n=EF(e,r),o=EF(t,r);return void 0!==n&&n===o})(o.left,a.property,r);else{let e=eI(a,r.sourceCode.getScope(a));n=null!==e&&e===EF(o.left,r)}return n?{suggest:[{messageId:ES,fix:EP(e,t,r)}]}:void 0}}(e,r,t):function(e,t,r){let{test:n}=e;if(E$(n,"has")&&E$(t,"delete")&&((e,t)=>{let r;if("Identifier"!==(e=ry(e)).type)return!1;let n=ra(e,t);if(!n)return!1;let o=ry(n);return"NewExpression"===o.type&&(r=o.callee,"Identifier"===r.type&&EC.has(r.name)&&t.sourceCode.isGlobalReference(r))})(n.callee.object,r)&&tQ(n.callee.object,t.callee.object)&&tQ(n.arguments[0],t.arguments[0])&&ER(n.arguments[0],r))return{fix:EP(e,t,r)}}(e,r,t)}(t,e);if(r)return{node:t.test,messageId:ED,fix:r.fix,suggest:r.suggest}})},meta:{type:"suggestion",docs:{description:"Disallow unnecessary existence checks before deletion.",recommended:"unopinionated"},fixable:"code",hasSuggestions:!0,schema:[],messages:{[ED]:"The existence check before deletion is unnecessary.",[ES]:"Remove the existence check."},languages:["js/js"]}},"unicorn/no-useless-logical-operand":{create:e=>{e.on("LogicalExpression",t=>{if(!EN.has(t.operator)||"LogicalExpression"===t.parent.type&&t.parent.operator===t.operator)return;let r=function(e,t){let r,n,{operator:o}=e,a=function e(t,r){return"LogicalExpression"===t.type&&t.operator===r?[...e(t.left,r),...e(t.right,r)]:[t]}(e,o),i=(r=EM.get(o),e2(a[0],r)?a[0]:void 0);if(i)return{target:i,replacementOperands:[i]};let s=(n=EN.get(o),a.filter((e,r)=>e2(e,n)&&function(e,t,r){var n;if(t<e.length-1)return!0;let o=e.slice(0,-1);return tA(n=e[t].parent,r)||tT(n)||o.every(e=>ny(e,r))}(a,r,t)));if(0===s.length)return;let l=a.filter(e=>!s.includes(e));return{target:s[0],replacementOperands:0===l.length?[s.at(-1)]:l}}(t,e);if(!r)return;let{target:n,replacementOperands:o}=r;if(1===o.length&&e1(ry(o[0]))&&function(e){let{parent:t}=e;if("ExpressionStatement"!==t.type||t.expression!==e)return!1;let r=t.parent,n=r.parent;if("Program"!==r.type&&!("BlockStatement"===r.type&&tl(n)))return!1;let o=r.body.indexOf(t);return r.body.slice(0,o).every(e=>"string"==typeof e.directive)}(t))return;let a={node:n,messageId:EL,data:{operator:t.operator}};return e.sourceCode.getCommentsInside(t).length>0||(1===o.length?a.fix=r=>oj(r,t,o[0],e):a.fix=r=>{var n;let a;return r.replaceText(t,(n=t.operator,a=o.map((t,r)=>{let o,a;return o=eQ(t,e),a=eZ(t,e),!o&&n6(t,{operator:n,property:0===r?"left":"right"})&&(a=`(${a})`),0===r&&!o&&EO.has(ry(t).type)&&(a=`(${a})`),a}).join(` ${n} `),nW(e.sourceCode.getTokenBefore(t),e,a)?`;${a}`:a))}),a})},meta:{type:"suggestion",docs:{description:"Disallow unnecessary operands in logical expressions involving boolean literals.",recommended:"unopinionated"},fixable:"code",schema:[],messages:{[EL]:"Simplify this `{{operator}}` expression."},languages:["js/js"]}},"unicorn/prefer-boolean-return":{create:e=>{let{sourceCode:t}=e;function r(n,o,a,i=t.getRange(n)){let s;if(!o||!a||"ConditionalExpression"===n.test.type)return;let l=E_(o),u=E_(a);if(void 0===l||void 0===u||l===u)return;let p={node:n,messageId:Eq},c=!l,d=t.getCommentsInside(n).length>0||t.getCommentsInside(a).length>0||t7(e,a),m=!c&&!EV(n.test,e)&&!!(s=ei(t.getScope(n),"Boolean"))&&0!==s.defs.length;return d||m?p:{...p,fix:t=>t.replaceTextRange(i,`return ${function(t,r){let n=eZ(t,e);if(r)return n8(t,"!")?`!(${n})`:`!${n}`;if(EV(t,e))return n;let o="SequenceExpression"===t.type?`(${n})`:n;return`Boolean(${o})`}(n.test,c)};`)}}e.on("IfStatement",n=>{if(!n.alternate){let o=on(n,e);if(!o||"ReturnStatement"!==o.type)return;let a=r(n,EW(n.consequent),o,[t.getRange(n)[0],t.getRange(o)[1]]);return a?.fix&&t.getTokensBetween(n,o,{includeComments:!0}).some(e=>"Block"===e.type||"Line"===e.type)?{node:n,messageId:Eq}:a}return r(n,EW(n.consequent),EW(n.alternate))})},meta:{type:"suggestion",docs:{description:"Prefer directly returning boolean expressions over `if` statements.",recommended:"unopinionated"},fixable:"code",schema:[],messages:{[Eq]:"Return the boolean expression directly."},languages:["js/js"]}},"unicorn/prefer-continue":EQ,"unicorn/prefer-flat-math-min-max":{create:e=>{let{sourceCode:t}=e;e.on("CallExpression",e=>{let r=(e=>{for(let t of E1)if(E2(e,t))return t})(e);if(!(!r||!e.arguments.some(e=>E2(e,r))||((e,t)=>{let{parent:r}=e;return E2(r,t)&&r.arguments.includes(e)})(e,r)))return{node:e,messageId:E0,data:{method:r},*fix(n,{abort:o}){if(t.getCommentsInside(e).length>0)return o();let a=t.getText(e.callee),i=E3(e,r).map(e=>t.getText(e)).join(", ");yield n.replaceText(e,`${a}(${i})`)}}})},meta:{type:"suggestion",docs:{description:"Prefer flat `Math.min()` and `Math.max()` calls over nested calls.",recommended:"unopinionated"},fixable:"code",schema:[],messages:{[E0]:"Prefer a flat `Math.{{method}}()` call instead of nested calls."},languages:["js/js"]}},"unicorn/prefer-hoisting-branch-code":{create:e=>{e.on("IfStatement",t=>(function*(e,t){if("IfStatement"===e.parent.type&&e.parent.alternate===e)return;let r=function(e){let t=[],r=e;for(;r?.type==="IfStatement";r=r.alternate)t.push(r.consequent);if(r)return t.push(r),t}(e);if(!r||r.some(e=>"BlockStatement"!==e.type))return;let{sourceCode:n}=t,{leading:o,trailing:a,minLength:i}=function(e,t){let r=Math.min(...e.map(e=>e.length)),n=0;for(;n<r&&e.every(r=>De(r[n],e[0][n],t));)n++;let o=0;for(;n+o<r&&e.every(r=>De(r.at(-1-o),e[0].at(-1-o),t));)o++;return{leading:n,trailing:o,minLength:r}}(r.map(e=>e.body),n);0===o&&0===a||!(o+a>=i)&&(o>0&&(yield Dr({ifStatement:e,blocks:r,leading:o,trailing:a,isStart:!0},t)),a>0&&(yield Dr({ifStatement:e,blocks:r,leading:o,trailing:a,isStart:!1},t)))})(t,e))},meta:{type:"suggestion",docs:{description:"Prefer moving code shared by all branches of an `if` statement out of the branches.",recommended:!0},fixable:"code",hasSuggestions:!0,messages:{[E8]:"These branches start with the same code. Move it before the `if` statement.",[E6]:"These branches end with the same code. Move it after the `if` statement.",[E9]:"Move the shared code out of the branches."},languages:["js/js"]}},"unicorn/prefer-single-replace":{create:e=>{let{sourceCode:t}=e;e.on("CallExpression",r=>{if(void 0===Ds(r))return;let n=r.arguments[1];if(!e1(n))return;let o=n.value;if(o.includes("$`")||o.includes("$'"))return;let a=e=>void 0!==Ds(e)&&e1(e.arguments[1])&&e.arguments[1].value===o,{parent:i}=r;if("MemberExpression"===i.type&&i.object===r&&"CallExpression"===i.parent.type&&i.parent.callee===i&&a(i.parent))return;let s=[],l=r;for(;a(l);)s.push(Ds(l)),l=l.callee.object;if(s.length<2)return;let u=l;s.reverse();let p=[...new Set(s)];if(p.some(e=>o.includes(e)))return;let c={node:r,messageId:Do};if(0===t.getCommentsInside(r).length){let t=p.map((e,t)=>(function(e,t,r){if(Di.has(e))return Di.get(e);if("^"===e)return t?String.raw`\^`:"^";if("-"===e)return t||r?"-":String.raw`\-`;let n=e.codePointAt(0);return n<32||127===n?String.raw`\x${n.toString(16).toUpperCase().padStart(2,"0")}`:e})(e,0===t,t===p.length-1)).join(""),o=eZ(u,e),a=eZ(n,e);c.fix=e=>e.replaceText(r,`${o}.replaceAll(/[${t}]/g, ${a})`)}return c})},meta:{type:"suggestion",docs:{description:"Enforce combining multiple single-character replacements into a single `String#replaceAll()` with a regular expression.",recommended:"unopinionated"},fixable:"code",messages:{[Do]:"Combine these single-character replacements into a single `replaceAll()` with a regular expression."},languages:["js/js"]}}}).map(([e,t])=>{let r;return[e,{meta:{schema:[],...t.meta,docs:{...t.meta.docs,url:(r=d.basename(e,".js"),`https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v68.0.0/docs/rules/${r}.md`)}},create:nH(t.create)}]})))};module.exports=Dl;
|