@sarj/eslint-plugin 19.0.1 → 19.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -10,7 +10,9 @@ npm install --save-dev @sarj/eslint-plugin
10
10
 
11
11
  Version 19 is an Oxlint JS plugin. Load it as `jsPlugins: [{ name: "@sarj", specifier: "@sarj/eslint-plugin" }]`, or extend the managed `createConfig()` that Standards syncs. Type-aware rules get type information from `tsrs`, a required peer; `settings.sarj.typeAware: false` or `SARJ_TYPE_AWARE=0` runs them untyped. The package no longer ships ESLint rules or presets. Rule names, options and suppression IDs are unchanged.
12
12
 
13
- Managed subpath entrypoints retain the selected upstream rules without installing ESLint. The `react-correctness` entrypoint also needs the optional TypeScript JavaScript API peer; the managed toolchain supplies TypeScript 6.
13
+ The `unicorn` entrypoint additionally exports upstream `prefer-https` and `prefer-switch` for explicit consumer opt-in; neither is enabled by managed defaults.
14
+
15
+ The opt-in `next` entrypoint exports the official `no-location-assign-relative-destination` rule for existing consumer policies; it does not enable extra Next policies in the managed profile. The Next 16.4.1 prefix resolver has a narrow cycle guard: cyclic aliases return unknown instead of overflowing the stack; resolvable relative prefixes still report. Managed subpath entrypoints retain the selected upstream rules without installing ESLint. The `react-correctness` entrypoint also needs the optional TypeScript JavaScript API peer; the managed toolchain supplies TypeScript 6.
14
16
 
15
17
  Rules and configuration are documented in the generated rule directory.
16
18
 
package/dist/next.js ADDED
@@ -0,0 +1,3 @@
1
+ import {createRequire as sarjCreateRequire} from "node:module";const require=sarjCreateRequire(import.meta.url);
2
+ var Le=Object.create;var Z=Object.defineProperty;var Be=Object.getOwnPropertyDescriptor;var De=Object.getOwnPropertyNames;var Fe=Object.getPrototypeOf,Me=Object.prototype.hasOwnProperty;var I=(e,r)=>()=>{try{return r||e((r={exports:{}}).exports,r),r.exports}catch(t){throw r=0,t}};var $e=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of De(r))!Me.call(e,i)&&i!==t&&Z(e,i,{get:()=>r[i],enumerable:!(n=Be(r,i))||n.enumerable});return e};var Ue=(e,r,t)=>(t=e!=null?Le(Fe(e)):{},$e(r||!e||!e.__esModule?Z(t,"default",{value:e,enumerable:!0}):t,e));var ee=I(D=>{"use strict";Object.defineProperty(D,"__esModule",{value:!0});Object.defineProperty(D,"defineRule",{enumerable:!0,get:function(){return qe}});var qe=function(e){return e}});var te=I(T=>{"use strict";Object.defineProperty(T,"__esModule",{value:!0});var k={ArrayExpression:["elements"],ArrayPattern:["elements"],ArrowFunctionExpression:["params","body"],AssignmentExpression:["left","right"],AssignmentPattern:["left","right"],AwaitExpression:["argument"],BinaryExpression:["left","right"],BlockStatement:["body"],BreakStatement:["label"],CallExpression:["callee","arguments"],CatchClause:["param","body"],ChainExpression:["expression"],ClassBody:["body"],ClassDeclaration:["id","superClass","body"],ClassExpression:["id","superClass","body"],ConditionalExpression:["test","consequent","alternate"],ContinueStatement:["label"],DebuggerStatement:[],DoWhileStatement:["body","test"],EmptyStatement:[],ExperimentalRestProperty:["argument"],ExperimentalSpreadProperty:["argument"],ExportAllDeclaration:["exported","source"],ExportDefaultDeclaration:["declaration"],ExportNamedDeclaration:["declaration","specifiers","source"],ExportSpecifier:["exported","local"],ExpressionStatement:["expression"],ForInStatement:["left","right","body"],ForOfStatement:["left","right","body"],ForStatement:["init","test","update","body"],FunctionDeclaration:["id","params","body"],FunctionExpression:["id","params","body"],Identifier:[],IfStatement:["test","consequent","alternate"],ImportDeclaration:["specifiers","source"],ImportDefaultSpecifier:["local"],ImportExpression:["source"],ImportNamespaceSpecifier:["local"],ImportSpecifier:["imported","local"],JSXAttribute:["name","value"],JSXClosingElement:["name"],JSXClosingFragment:[],JSXElement:["openingElement","children","closingElement"],JSXEmptyExpression:[],JSXExpressionContainer:["expression"],JSXFragment:["openingFragment","children","closingFragment"],JSXIdentifier:[],JSXMemberExpression:["object","property"],JSXNamespacedName:["namespace","name"],JSXOpeningElement:["name","attributes"],JSXOpeningFragment:[],JSXSpreadAttribute:["argument"],JSXSpreadChild:["expression"],JSXText:[],LabeledStatement:["label","body"],Literal:[],LogicalExpression:["left","right"],MemberExpression:["object","property"],MetaProperty:["meta","property"],MethodDefinition:["key","value"],NewExpression:["callee","arguments"],ObjectExpression:["properties"],ObjectPattern:["properties"],PrivateIdentifier:[],Program:["body"],Property:["key","value"],PropertyDefinition:["key","value"],RestElement:["argument"],ReturnStatement:["argument"],SequenceExpression:["expressions"],SpreadElement:["argument"],StaticBlock:["body"],Super:[],SwitchCase:["test","consequent"],SwitchStatement:["discriminant","cases"],TaggedTemplateExpression:["tag","quasi"],TemplateElement:[],TemplateLiteral:["quasis","expressions"],ThisExpression:[],ThrowStatement:["argument"],TryStatement:["block","handler","finalizer"],UnaryExpression:["argument"],UpdateExpression:["argument"],VariableDeclaration:["declarations"],VariableDeclarator:["id","init"],WhileStatement:["test","body"],WithStatement:["object","body"],YieldExpression:["argument"]},Ve=Object.keys(k);for(let e of Ve)Object.freeze(k[e]);Object.freeze(k);var ze=new Set(["parent","leadingComments","trailingComments"]);function We(e){return!ze.has(e)&&e[0]!=="_"}function Je(e){return Object.keys(e).filter(We)}function Xe(e){let r=Object.assign({},k);for(let t of Object.keys(e))if(Object.prototype.hasOwnProperty.call(r,t)){let n=new Set(e[t]);for(let i of r[t])n.add(i);r[t]=Object.freeze(Array.from(n))}else r[t]=Object.freeze(Array.from(e[t]));return Object.freeze(r)}T.KEYS=k;T.getKeys=Je;T.unionWith=Xe});var Ae=I(l=>{"use strict";Object.defineProperty(l,"__esModule",{value:!0});var le=te();function M(e,r){let t=r.range[0],n=e,i=!1;do{i=!1;for(let s of n.childScopes){let o=s.block.range;if(o[0]<=t&&t<o[1]){n=s,i=!0;break}}}while(i);return n}function x(e,r){let t="",n=e;for(typeof r=="string"?t=r:(t=r.name,n=M(n,r));n!=null;){let i=n.set.get(t);if(i!=null)return i;n=n.upper}return null}function g(e){return r=>!e(r)}function m(e,r){return e.type==="Punctuator"&&e.value===r}function j(e){return m(e,"=>")}function $(e){return m(e,",")}function U(e){return m(e,";")}function q(e){return m(e,":")}function d(e){return m(e,"(")}function R(e){return m(e,")")}function V(e){return m(e,"[")}function z(e){return m(e,"]")}function W(e){return m(e,"{")}function J(e){return m(e,"}")}function X(e){return["Block","Line","Shebang"].includes(e.type)}var ue=g(j),ce=g($),pe=g(U),fe=g(q),ye=g(d),ge=g(R),me=g(V),de=g(z),he=g(W),ve=g(J),be=g(X);function re(e,r){return e.id?r.getTokenAfter(e.id,d):r.getFirstToken(e,d)}function xe(e,r){let t=e.parent,n=null,i=null;if(e.type==="ArrowFunctionExpression"){let s=r.getTokenBefore(e.body,j);n=s.loc.start,i=s.loc.end}else t&&(t.type==="Property"||t.type==="MethodDefinition"||t.type==="PropertyDefinition")?(n=t.loc.start,i=re(e,r).loc.start):(n=e.loc.start,i=re(e,r).loc.start);return{start:{...n},end:{...i}}}var Se=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{},_e=Object.freeze(new Set(["Array","ArrayBuffer","BigInt","BigInt64Array","BigUint64Array","Boolean","DataView","Date","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","Float32Array","Float64Array","Function","Infinity","Int16Array","Int32Array","Int8Array","isFinite","isNaN","isPrototypeOf","JSON","Map","Math","NaN","Number","Object","parseFloat","parseInt","Promise","Proxy","Reflect","RegExp","Set","String","Symbol","Uint16Array","Uint32Array","Uint8Array","Uint8ClampedArray","undefined","unescape","WeakMap","WeakSet"])),F=new Set([Array.isArray,Array.of,Array.prototype.at,Array.prototype.concat,Array.prototype.entries,Array.prototype.every,Array.prototype.filter,Array.prototype.find,Array.prototype.findIndex,Array.prototype.flat,Array.prototype.includes,Array.prototype.indexOf,Array.prototype.join,Array.prototype.keys,Array.prototype.lastIndexOf,Array.prototype.slice,Array.prototype.some,Array.prototype.toString,Array.prototype.values,typeof BigInt=="function"?BigInt:void 0,Boolean,Date,Date.parse,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,escape,isFinite,isNaN,isPrototypeOf,Map,Map.prototype.entries,Map.prototype.get,Map.prototype.has,Map.prototype.keys,Map.prototype.values,...Object.getOwnPropertyNames(Math).filter(e=>e!=="random").map(e=>Math[e]).filter(e=>typeof e=="function"),Number,Number.isFinite,Number.isNaN,Number.parseFloat,Number.parseInt,Number.prototype.toExponential,Number.prototype.toFixed,Number.prototype.toPrecision,Number.prototype.toString,Object,Object.entries,Object.is,Object.isExtensible,Object.isFrozen,Object.isSealed,Object.keys,Object.values,parseFloat,parseInt,RegExp,Set,Set.prototype.entries,Set.prototype.has,Set.prototype.keys,Set.prototype.values,String,String.fromCharCode,String.fromCodePoint,String.raw,String.prototype.at,String.prototype.charAt,String.prototype.charCodeAt,String.prototype.codePointAt,String.prototype.concat,String.prototype.endsWith,String.prototype.includes,String.prototype.indexOf,String.prototype.lastIndexOf,String.prototype.normalize,String.prototype.padEnd,String.prototype.padStart,String.prototype.slice,String.prototype.startsWith,String.prototype.substr,String.prototype.substring,String.prototype.toLowerCase,String.prototype.toString,String.prototype.toUpperCase,String.prototype.trim,String.prototype.trimEnd,String.prototype.trimLeft,String.prototype.trimRight,String.prototype.trimStart,Symbol.for,Symbol.keyFor,unescape].filter(e=>typeof e=="function")),ne=new Set([Object.freeze,Object.preventExtensions,Object.seal]),Ge=[[Map,new Set(["size"])],[RegExp,new Set(["dotAll","flags","global","hasIndices","ignoreCase","multiline","source","sticky","unicode"])],[Set,new Set(["size"])]];function Ke(e,r){let t=e;for(;(typeof t=="object"||typeof t=="function")&&t!==null;){let n=Object.getOwnPropertyDescriptor(t,r);if(n)return n;t=Object.getPrototypeOf(t)}return null}function Ye(e,r){let t=Ke(e,r);return t!=null&&t.get!=null}function A(e,r){let t=[];for(let n=0;n<e.length;++n){let i=e[n];if(i==null)t.length=n+1;else if(i.type==="SpreadElement"){let s=u(i.argument,r);if(s==null)return null;t.push(...s.value)}else{let s=u(i,r);if(s==null)return null;t.push(s.value)}}return t}function He(e){return e!=null&&e.defs.length===0&&_e.has(e.name)&&e.name in Se}function Qe(e){if(e.defs.length!==1)return!1;let r=e.defs[0];return!!(r.parent&&r.type==="Variable"&&(r.parent.kind==="const"||Ze(e)))}function Ze(e){let r=e.references,t=r.filter(i=>i.init).length,n=r.filter(i=>i.isReadOnly()).length;return t===1&&n+t===r.length}function et(e,r){for(let n of e.references){let i=n.identifier;for(;i&&i.parent&&i.parent.type==="MemberExpression";)i=i.parent;if(!(!i||!i.parent)){if(i.parent.type==="AssignmentExpression"&&i.parent.left===i||i.parent.type==="UpdateExpression"&&i.parent.argument===i)return!0;if(i.parent.type==="CallExpression"&&i.parent.callee===i&&i.type==="MemberExpression"){let s=O(i,r);if(t(s))return!0}}}return!1;function t(n){if(n==null||n.value==null)return!1;let i=n.value;return i==="copyWithin"||i==="fill"||i==="pop"||i==="push"||i==="reverse"||i==="shift"||i==="sort"||i==="splice"||i==="unshift"}}var ie=Object.freeze({ArrayExpression(e,r){let t=A(e.elements,r);return t!=null?{value:t}:null},AssignmentExpression(e,r){return e.operator==="="?u(e.right,r):null},BinaryExpression(e,r){if(e.operator==="in"||e.operator==="instanceof")return null;let t=u(e.left,r),n=u(e.right,r);if(t!=null&&n!=null)switch(e.operator){case"==":return{value:t.value==n.value};case"!=":return{value:t.value!=n.value};case"===":return{value:t.value===n.value};case"!==":return{value:t.value!==n.value};case"<":return{value:t.value<n.value};case"<=":return{value:t.value<=n.value};case">":return{value:t.value>n.value};case">=":return{value:t.value>=n.value};case"<<":return{value:t.value<<n.value};case">>":return{value:t.value>>n.value};case">>>":return{value:t.value>>>n.value};case"+":return{value:t.value+n.value};case"-":return{value:t.value-n.value};case"*":return{value:t.value*n.value};case"/":return{value:t.value/n.value};case"%":return{value:t.value%n.value};case"**":return{value:t.value**n.value};case"|":return{value:t.value|n.value};case"^":return{value:t.value^n.value};case"&":return{value:t.value&n.value}}return null},CallExpression(e,r){let t=e.callee,n=A(e.arguments,r);if(n!=null)if(t.type==="MemberExpression"){if(t.property.type==="PrivateIdentifier")return null;let i=u(t.object,r);if(i!=null){if(i.value==null&&(i.optional||e.optional))return{value:void 0,optional:!0};let s=O(t,r);if(s!=null){let o=i.value,a=s.value;if(F.has(o[a]))return{value:o[a](...n)};if(ne.has(o[a]))return{value:n[0]}}}}else{let i=u(t,r);if(i!=null){if(i.value==null&&e.optional)return{value:void 0,optional:!0};let s=i.value;if(F.has(s))return{value:s(...n)};if(ne.has(s))return{value:n[0]}}}return null},ConditionalExpression(e,r){let t=u(e.test,r);return t!=null?t.value?u(e.consequent,r):u(e.alternate,r):null},ExpressionStatement(e,r){return u(e.expression,r)},Identifier(e,r){if(r!=null){let t=x(r,e);if(t!=null){if(He(t))return{value:Se[t.name]};if(Qe(t)){let n=t.defs[0];if(n.node.id.type==="Identifier"){let i=u(n.node.init,r);return i&&typeof i.value=="object"&&i.value!==null&&et(t,r)?null:i}}}}return null},Literal(e){let r=e;return(r.regex!=null||r.bigint!=null)&&r.value==null?null:{value:r.value}},LogicalExpression(e,r){let t=u(e.left,r);if(t!=null){if(e.operator==="||"&&t.value||e.operator==="&&"&&!t.value||e.operator==="??"&&t.value!=null)return t;let n=u(e.right,r);if(n!=null)return n}return null},MemberExpression(e,r){if(e.property.type==="PrivateIdentifier")return null;let t=u(e.object,r);if(t!=null){if(t.value==null&&(t.optional||e.optional))return{value:void 0,optional:!0};let n=O(e,r);if(n!=null){if(!Ye(t.value,n.value))return{value:t.value[n.value]};for(let[i,s]of Ge)if(t.value instanceof i&&s.has(n.value))return{value:t.value[n.value]}}}return null},ChainExpression(e,r){let t=u(e.expression,r);return t!=null?{value:t.value}:null},NewExpression(e,r){let t=u(e.callee,r),n=A(e.arguments,r);if(t!=null&&n!=null){let i=t.value;if(F.has(i))return{value:new i(...n)}}return null},ObjectExpression(e,r){let t={};for(let n of e.properties)if(n.type==="Property"){if(n.kind!=="init")return null;let i=O(n,r),s=u(n.value,r);if(i==null||s==null)return null;t[i.value]=s.value}else if(n.type==="SpreadElement"||n.type==="ExperimentalSpreadProperty"){let i=u(n.argument,r);if(i==null)return null;Object.assign(t,i.value)}else return null;return{value:t}},SequenceExpression(e,r){let t=e.expressions[e.expressions.length-1];return u(t,r)},TaggedTemplateExpression(e,r){let t=u(e.tag,r),n=A(e.quasi.expressions,r);if(t!=null&&n!=null){let i=t.value,s=e.quasi.quasis.map(o=>o.value.cooked);if(s.raw=e.quasi.quasis.map(o=>o.value.raw),i===String.raw)return{value:i(s,...n)}}return null},TemplateLiteral(e,r){let t=A(e.expressions,r);if(t!=null){let n=e.quasis[0].value.cooked;for(let i=0;i<t.length;++i)n+=t[i],n+=e.quasis[i+1].value.cooked;return{value:n}}return null},UnaryExpression(e,r){if(e.operator==="delete")return null;if(e.operator==="void")return{value:void 0};let t=u(e.argument,r);if(t!=null)switch(e.operator){case"-":return{value:-t.value};case"+":return{value:+t.value};case"!":return{value:!t.value};case"~":return{value:~t.value};case"typeof":return{value:typeof t.value}}return null},TSAsExpression(e,r){return u(e.expression,r)},TSSatisfiesExpression(e,r){return u(e.expression,r)},TSTypeAssertion(e,r){return u(e.expression,r)},TSNonNullExpression(e,r){return u(e.expression,r)},TSInstantiationExpression(e,r){return u(e.expression,r)}});function u(e,r){return e!=null&&Object.hasOwnProperty.call(ie,e.type)?ie[e.type](e,r):null}function O(e,r){let t=e.type==="Property"?e.key:e.property;return e.computed?u(t,r):t.type==="Identifier"?{value:t.name}:t.type==="Literal"?t.bigint?{value:t.bigint}:{value:String(t.value)}:null}function _(e,r=null){try{return u(e,r)}catch{return null}}function C(e,r=null){if(e&&e.type==="Literal"&&e.value===null){let n=e;if(n.regex)return`/${n.regex.pattern}/${n.regex.flags}`;if(n.bigint)return n.bigint}let t=_(e,r);if(t)try{return String(t.value)}catch{}return null}function P(e,r){switch(e.type){case"MemberExpression":return e.computed?C(e.property,r):e.property.type==="PrivateIdentifier"?null:e.property.name;case"Property":case"MethodDefinition":case"PropertyDefinition":return e.computed?C(e.key,r):e.key.type==="Literal"?String(e.key.value):e.key.type==="PrivateIdentifier"?null:e.key.name}return null}function Ee(e,r){let t=e.parent;if(!t)return"";let n=[],i=t.type==="Property"&&t.value===e,s=t.type==="MethodDefinition"&&t.value===e,o=t.type==="PropertyDefinition"&&t.value===e;if((s||o)&&(t.static&&n.push("static"),t.key.type==="PrivateIdentifier"&&n.push("private")),e.async&&n.push("async"),e.generator&&n.push("generator"),i||s){if(t.kind==="constructor")return"constructor";t.kind==="get"?n.push("getter"):t.kind==="set"?n.push("setter"):n.push("method")}else o?n.push("method"):(e.type==="ArrowFunctionExpression"&&n.push("arrow"),n.push("function"));if(i||s||o)if(t.key.type==="PrivateIdentifier")n.push(`#${t.key.name}`);else{let a=P(t);if(a)n.push(`'${a}'`);else if(r){let p=r.getText(t.key);p.includes(`
3
+ `)||n.push(`[${p}]`)}}else tt(e)?n.push(`'${e.id.name}'`):t.type==="VariableDeclarator"&&t.id&&t.id.type==="Identifier"?n.push(`'${t.id.name}'`):(t.type==="AssignmentExpression"||t.type==="AssignmentPattern")&&t.left&&t.left.type==="Identifier"?n.push(`'${t.left.name}'`):t.type==="ExportDefaultDeclaration"&&t.declaration===e&&n.push("'default'");return n.join(" ")}function tt(e){return!!e.id}var rt=Object.freeze(new Set(["==","!=","<","<=",">",">=","<<",">>",">>>","+","-","*","/","%","|","^","&","in"])),nt=Object.freeze(new Set(["-","+","!","~"]));function se(e){return e!==null&&typeof e=="object"&&typeof e.type=="string"}var it=Object.freeze(Object.assign(Object.create(null),{$visit(e,r,t){let{type:n}=e;return typeof this[n]=="function"?this[n](e,r,t):this.$visitChildren(e,r,t)},$visitChildren(e,r,t){let{type:n}=e;for(let i of t[n]||le.getKeys(e)){let s=e[i];if(Array.isArray(s)){for(let o of s)if(se(o)&&this.$visit(o,r,t))return!0}else if(se(s)&&this.$visit(s,r,t))return!0}return!1},ArrowFunctionExpression(){return!1},AssignmentExpression(){return!0},AwaitExpression(){return!0},BinaryExpression(e,r,t){return r.considerImplicitTypeConversion&&rt.has(e.operator)&&(e.left.type!=="Literal"||e.right.type!=="Literal")?!0:this.$visitChildren(e,r,t)},CallExpression(){return!0},FunctionExpression(){return!1},ImportExpression(){return!0},MemberExpression(e,r,t){return r.considerGetters||r.considerImplicitTypeConversion&&e.computed&&e.property.type!=="Literal"?!0:this.$visitChildren(e,r,t)},MethodDefinition(e,r,t){return r.considerImplicitTypeConversion&&e.computed&&e.key.type!=="Literal"?!0:this.$visitChildren(e,r,t)},NewExpression(){return!0},Property(e,r,t){return r.considerImplicitTypeConversion&&e.computed&&e.key.type!=="Literal"?!0:this.$visitChildren(e,r,t)},PropertyDefinition(e,r,t){return r.considerImplicitTypeConversion&&e.computed&&e.key.type!=="Literal"?!0:this.$visitChildren(e,r,t)},UnaryExpression(e,r,t){return e.operator==="delete"||r.considerImplicitTypeConversion&&nt.has(e.operator)&&e.argument.type!=="Literal"?!0:this.$visitChildren(e,r,t)},UpdateExpression(){return!0},YieldExpression(){return!0}}));function ke(e,r,t={}){let{considerGetters:n=!1,considerImplicitTypeConversion:i=!1}=t;return it.$visit(e,{considerGetters:n,considerImplicitTypeConversion:i},r.visitorKeys||le.KEYS)}function st(e,r){let t=e.parent;if(!t)return null;switch(t.type){case"CallExpression":case"NewExpression":return t.arguments.length===1&&t.arguments[0]===e?r.getTokenAfter(t.typeArguments||t.typeParameters||t.callee,d):null;case"DoWhileStatement":return t.test===e?r.getTokenAfter(t.body,d):null;case"IfStatement":case"WhileStatement":return t.test===e?r.getFirstToken(t,1):null;case"ImportExpression":return t.source===e?r.getFirstToken(t,1):null;case"SwitchStatement":return t.discriminant===e?r.getFirstToken(t,1):null;case"WithStatement":return t.object===e?r.getFirstToken(t,1):null;default:return null}}function Te(e,r,t){let n,i,s,o,a;if(typeof e=="number"){if(n=e|0,i=r,s=t,!(n>=1))throw new TypeError("'times' should be a positive integer.")}else n=1,i=e,s=r;if(i==null||i.parent==null||i.parent.type==="CatchClause"&&i.parent.param===i)return!1;o=a=i;do o=s.getTokenBefore(o),a=s.getTokenAfter(a);while(o!=null&&a!=null&&d(o)&&R(a)&&o!==st(i,s)&&--n>0);return n===0}var ot=/\$(?:[$&`']|[1-9][0-9]?)/gu,oe=new WeakMap;function at(e,r){let t=!1;for(let n=r-1;n>=0&&e.charCodeAt(n)===92;--n)t=!t;return t}function lt(e,r,t){let n=[],i=0;function s(o,a){switch(o){case"$$":return"$";case"$&":return a[0];case"$`":return r.slice(0,a.index);case"$'":return r.slice(a.index+a[0].length);default:{let p=o.slice(1);return p in a?a[p]:o}}}for(let o of e.execAll(r))n.push(r.slice(i,o.index)),n.push(t.replace(ot,a=>s(a,o))),i=o.index+o[0].length;return n.push(r.slice(i)),n.join("")}function ut(e,r,t){let n=[],i=0;for(let s of e.execAll(r))n.push(r.slice(i,s.index)),n.push(String(t(...s,s.index,s.input))),i=s.index+s[0].length;return n.push(r.slice(i)),n.join("")}var w=class{constructor(r,t={}){let{escaped:n=!1}=t;if(!(r instanceof RegExp))throw new TypeError("'pattern' should be a RegExp instance.");if(!r.flags.includes("g"))throw new Error("'pattern' should contains 'g' flag.");oe.set(this,{pattern:new RegExp(r.source,r.flags),escaped:!!n})}*execAll(r){let{pattern:t,escaped:n}=oe.get(this),i=null,s=0;for(t.lastIndex=0;(i=t.exec(r))!=null;)(n||!at(r,i.index))&&(s=t.lastIndex,yield i,t.lastIndex=s)}test(r){return!this.execAll(r).next().done}[Symbol.replace](r,t){return typeof t=="function"?ut(this,String(r),t):lt(this,String(r),String(t))}},ct=/^(?:Import|Export(?:All|Default|Named))Declaration$/u;function pt(e){return ct.test(e.type)&&e.source!=null}var v=Function.call.bind(Object.hasOwnProperty),c=Symbol("read"),b=Symbol("call"),S=Symbol("construct"),N=Symbol("esm"),ft={require:{[b]:!0}};function ae(e){return e==null||e.defs.length!==0||e.references.some(r=>r.isWrite())}function yt(e){let r=e.parent;if(r)switch(r.type){case"ConditionalExpression":return r.consequent===e||r.alternate===e;case"LogicalExpression":return!0;case"SequenceExpression":return r.expressions[r.expressions.length-1]===e;case"ChainExpression":return!0;case"TSAsExpression":case"TSSatisfiesExpression":case"TSTypeAssertion":case"TSNonNullExpression":case"TSInstantiationExpression":return!0;default:return!1}return!1}var h=class{constructor(r,t={}){let{mode:n="strict",globalObjectNames:i=["global","globalThis","self","window"]}=t;this.variableStack=[],this.globalScope=r,this.mode=n,this.globalObjectNames=i.slice(0)}*iterateGlobalReferences(r){for(let t of Object.keys(r)){let n=r[t],i=[t],s=this.globalScope.set.get(t);ae(s)||(yield*this._iterateVariableReferences(s,i,n,!0))}for(let t of this.globalObjectNames){let n=[],i=this.globalScope.set.get(t);ae(i)||(yield*this._iterateVariableReferences(i,n,r,!1))}}*iterateCjsReferences(r){for(let{node:t}of this.iterateGlobalReferences(ft)){let n=C(t.arguments[0]);if(n==null||!v(r,n))continue;let i=r[n],s=[n];i[c]&&(yield{node:t,path:s,type:c,info:i[c]}),yield*this._iteratePropertyReferences(t,s,i)}}*iterateEsmReferences(r){let t=this.globalScope.block;for(let n of t.body){if(!pt(n))continue;let i=n.source.value;if(!v(r,i))continue;let s=r[i],o=[i];if(s[c]&&(yield{node:n,path:o,type:c,info:s[c]}),n.type==="ExportAllDeclaration")for(let a of Object.keys(s)){let p=s[a];p[c]&&(yield{node:n,path:o.concat(a),type:c,info:p[c]})}else for(let a of n.specifiers){let p=v(s,N),f=this._iterateImportReferences(a,o,p?s:this.mode==="legacy"?{default:s,...s}:{default:s});if(p)yield*f;else for(let y of f)y.path=y.path.filter(gt),(y.path.length>=2||y.type!==c)&&(yield y)}}}*iteratePropertyReferences(r,t){yield*this._iteratePropertyReferences(r,[],t)}*_iterateVariableReferences(r,t,n,i){if(!this.variableStack.includes(r)){this.variableStack.push(r);try{for(let s of r.references){if(!s.isRead())continue;let o=s.identifier;i&&n[c]&&(yield{node:o,path:t,type:c,info:n[c]}),yield*this._iteratePropertyReferences(o,t,n)}}finally{this.variableStack.pop()}}}*_iteratePropertyReferences(r,t,n){let i=r;for(;yt(i);)i=i.parent;let s=i.parent;if(s){if(s.type==="MemberExpression"){if(s.object===i){let o=P(s);if(o==null||!v(n,o))return;t=t.concat(o);let a=n[o];a[c]&&(yield{node:s,path:t,type:c,info:a[c]}),yield*this._iteratePropertyReferences(s,t,a)}return}if(s.type==="CallExpression"){s.callee===i&&n[b]&&(yield{node:s,path:t,type:b,info:n[b]});return}if(s.type==="NewExpression"){s.callee===i&&n[S]&&(yield{node:s,path:t,type:S,info:n[S]});return}if(s.type==="AssignmentExpression"){s.right===i&&(yield*this._iterateLhsReferences(s.left,t,n),yield*this._iteratePropertyReferences(s,t,n));return}if(s.type==="AssignmentPattern"){s.right===i&&(yield*this._iterateLhsReferences(s.left,t,n));return}s.type==="VariableDeclarator"&&s.init===i&&(yield*this._iterateLhsReferences(s.id,t,n))}}*_iterateLhsReferences(r,t,n){if(r.type==="Identifier"){let i=x(this.globalScope,r);i!=null&&(yield*this._iterateVariableReferences(i,t,n,!1));return}if(r.type==="ObjectPattern"){for(let i of r.properties){let s=P(i);if(s==null||!v(n,s))continue;let o=t.concat(s),a=n[s];a[c]&&(yield{node:i,path:o,type:c,info:a[c]}),yield*this._iterateLhsReferences(i.value,o,a)}return}r.type==="AssignmentPattern"&&(yield*this._iterateLhsReferences(r.left,t,n))}*_iterateImportReferences(r,t,n){let i=r.type;if(i==="ImportSpecifier"||i==="ImportDefaultSpecifier"){let s=i==="ImportDefaultSpecifier"?"default":r.imported.type==="Identifier"?r.imported.name:r.imported.value;if(!v(n,s))return;t=t.concat(s);let o=n[s];o[c]&&(yield{node:r,path:t,type:c,info:o[c]}),yield*this._iterateVariableReferences(x(this.globalScope,r.local),t,o,!1);return}if(i==="ImportNamespaceSpecifier"){yield*this._iterateVariableReferences(x(this.globalScope,r.local),t,n,!1);return}if(i==="ExportSpecifier"){let s=r.local.type==="Identifier"?r.local.name:r.local.value;if(!v(n,s))return;t=t.concat(s);let o=n[s];o[c]&&(yield{node:r,path:t,type:c,info:o[c]})}}};h.READ=c;h.CALL=b;h.CONSTRUCT=S;h.ESM=N;function gt(e,r){return!(r===1&&e==="default")}var mt={CALL:b,CONSTRUCT:S,ESM:N,findVariable:x,getFunctionHeadLocation:xe,getFunctionNameWithKind:Ee,getInnermostScope:M,getPropertyName:P,getStaticValue:_,getStringIfConstant:C,hasSideEffect:ke,isArrowToken:j,isClosingBraceToken:J,isClosingBracketToken:z,isClosingParenToken:R,isColonToken:q,isCommaToken:$,isCommentToken:X,isNotArrowToken:ue,isNotClosingBraceToken:ve,isNotClosingBracketToken:de,isNotClosingParenToken:ge,isNotColonToken:fe,isNotCommaToken:ce,isNotCommentToken:be,isNotOpeningBraceToken:he,isNotOpeningBracketToken:me,isNotOpeningParenToken:ye,isNotSemicolonToken:pe,isOpeningBraceToken:W,isOpeningBracketToken:V,isOpeningParenToken:d,isParenthesized:Te,isSemicolonToken:U,PatternMatcher:w,READ:c,ReferenceTracker:h};l.CALL=b;l.CONSTRUCT=S;l.ESM=N;l.PatternMatcher=w;l.READ=c;l.ReferenceTracker=h;l.default=mt;l.findVariable=x;l.getFunctionHeadLocation=xe;l.getFunctionNameWithKind=Ee;l.getInnermostScope=M;l.getPropertyName=P;l.getStaticValue=_;l.getStringIfConstant=C;l.hasSideEffect=ke;l.isArrowToken=j;l.isClosingBraceToken=J;l.isClosingBracketToken=z;l.isClosingParenToken=R;l.isColonToken=q;l.isCommaToken=$;l.isCommentToken=X;l.isNotArrowToken=ue;l.isNotClosingBraceToken=ve;l.isNotClosingBracketToken=de;l.isNotClosingParenToken=ge;l.isNotColonToken=fe;l.isNotCommaToken=ce;l.isNotCommentToken=be;l.isNotOpeningBraceToken=he;l.isNotOpeningBracketToken=me;l.isNotOpeningParenToken=ye;l.isNotSemicolonToken=pe;l.isOpeningBraceToken=W;l.isOpeningBracketToken=V;l.isOpeningParenToken=d;l.isParenthesized=Te;l.isSemicolonToken=U});var je=I(K=>{"use strict";Object.defineProperty(K,"__esModule",{value:!0});Object.defineProperty(K,"default",{enumerable:!0,get:function(){return ht}});var dt=ee(),Ce=Ae(),Pe="https://nextjs.org/docs/messages/no-location-assign-relative-destination",ht=(0,dt.defineRule)({meta:{docs:{description:"Prevent usage of `location.assign` or `location.href` assignment to navigate to internal Next.js pages.",recommended:!0,url:Pe},type:"problem",schema:[],messages:{noLocationAssign:"Do not use `{{expression}}` to navigate to internal Next.js pages. Use `redirect()` in the render phase, or `useRouter().push()` in Client Components' event handlers instead. See: "+Pe}},create:function(r){var t=r.sourceCode,n=t.scopeManager;return n?{CallExpression:function(s){var o=s.callee,a=s.arguments;if(G(o,"assign")){var p=Oe(o.object);if(p&&we(t,p)&&!(a.length<1)){var f=a[0];if(f.type!=="SpreadElement"){var y=L(f,t);y!==null&&Ie(y)&&r.report({node:s,messageId:"noLocationAssign",data:{expression:t.getText(o)+"()"}})}}}},AssignmentExpression:function(s){var o=s.left,a=s.right;if(G(o,"href")){var p=Oe(o.object);if(p&&we(t,p)){var f=L(a,t);f!==null&&Ie(f)&&r.report({node:s,messageId:"noLocationAssign",data:{expression:t.getText(o)}})}}}}:{}}}),vt=/^(?:[a-z][\d+.a-z-]*:|\/\/)/i,bt=new Set(["window","globalThis","document","self"]);function G(e,r){return e.type!=="MemberExpression"?!1:e.computed?e.property.type==="Literal"&&e.property.value===r:e.property.type==="Identifier"&&e.property.name===r}function Ie(e){return!vt.test(e)}function Oe(e){return e.type==="Identifier"&&e.name==="location"?e:e.type==="MemberExpression"&&e.object.type==="Identifier"&&bt.has(e.object.name)&&G(e,"location")?e.object:null}function we(e,r){if(!r||r.type!=="Identifier")return!1;var t=e.scopeManager.scopes[0].set.get(r.name);return!t||t.defs.length>0?!1:t.references.some(function(n){var i=n.identifier;return i===r})}function L(e,r,t=new Set){if(t.has(e))return null;t.add(e);try{var n=(0,Ce.getStringIfConstant)(e,r.getScope(e));if(n!==null)return n;if(e.type==="TemplateLiteral"&&e.quasis.length>0){var i;return(i=e.quasis[0].value.cooked)!==null&&i!==void 0?i:e.quasis[0].value.raw}if(e.type==="BinaryExpression"&&e.operator==="+")return L(e.left,r,t);if(e.type==="Identifier"){var s=(0,Ce.findVariable)(r.getScope(e),e);if(!s||s.defs.length<1)return null;var o=s.defs[s.defs.length-1];if(o.type!=="Variable")return null;var a=e.range[0],p,f=(p=o.node.init)!==null&&p!==void 0?p:null,y=!0,Y=!1,H=void 0;try{for(var B=s.references[Symbol.iterator](),Q;!(y=(Q=B.next()).done);y=!0){var E=Q.value;if(E.identifier.range[0]>=a)break;E.isWrite()&&E.writeExpr&&E.writeExpr!==o.node.init&&(f=E.writeExpr)}}catch(Ne){Y=!0,H=Ne}finally{try{!y&&B.return!=null&&B.return()}finally{if(Y)throw H}}return f?L(f,r,t):null}return null}finally{t.delete(e)}}});var Re=Ue(je()),xt={"no-location-assign-relative-destination":Re.default},Ct={meta:{name:"@next/eslint-plugin-next",version:"16.4.1"},rules:xt};export{Ct as default};