eslint-cli-bundle 2.0.0 → 2.0.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/README.md CHANGED
@@ -1,3 +1,4 @@
1
1
  # eslint-cli-bundle
2
+ [![](https://img.shields.io/npm/v/eslint-cli-bundle.svg?style=flat)](https://www.npmjs.org/package/eslint-cli-bundle) [![](https://img.shields.io/npm/dm/eslint-cli-bundle.svg)](https://www.npmjs.org/package/eslint-cli-bundle) [![](https://packagephobia.com/badge?p=eslint-cli-bundle)](https://packagephobia.com/result?p=eslint-cli-bundle)
2
3
 
3
4
  Bundled version of [`eslint`](https://github.com/eslint/eslint).
package/dist/api.d.ts CHANGED
@@ -663,8 +663,7 @@ export namespace Rule {
663
663
  interface NodeListener extends CustomRuleVisitorWithExit<
664
664
  {
665
665
  [Node in Rule.Node as Node["type"]]?:
666
- | ((node: Node) => void)
667
- | undefined;
666
+ ((node: Node) => void) | undefined;
668
667
  } & {
669
668
  // A `Program` visitor's node type has no `parent` property.
670
669
  Program?: ((node: AST.Program) => void) | undefined;
@@ -723,6 +722,22 @@ export namespace Rule {
723
722
  | "class-field-initializer"
724
723
  | "class-static-block";
725
724
 
725
+ interface CodePathSegmentTraversalController {
726
+ skip(): void;
727
+ break(): void;
728
+ }
729
+
730
+ type CodePathSegmentTraversalCallback = (
731
+ this: CodePath,
732
+ segment: CodePathSegment,
733
+ controller: CodePathSegmentTraversalController,
734
+ ) => void;
735
+
736
+ interface CodePathTraversalOptions {
737
+ first?: CodePathSegment | undefined;
738
+ last?: CodePathSegment | undefined;
739
+ }
740
+
726
741
  interface CodePath {
727
742
  id: string;
728
743
  origin: CodePathOrigin;
@@ -732,12 +747,19 @@ export namespace Rule {
732
747
  thrownSegments: CodePathSegment[];
733
748
  upper: CodePath | null;
734
749
  childCodePaths: CodePath[];
750
+ traverseSegments(callback: CodePathSegmentTraversalCallback): void;
751
+ traverseSegments(
752
+ options: CodePathTraversalOptions,
753
+ callback: CodePathSegmentTraversalCallback,
754
+ ): void;
735
755
  }
736
756
 
737
757
  interface CodePathSegment {
738
758
  id: string;
739
759
  nextSegments: CodePathSegment[];
740
760
  prevSegments: CodePathSegment[];
761
+ allNextSegments: CodePathSegment[];
762
+ allPrevSegments: CodePathSegment[];
741
763
  reachable: boolean;
742
764
  }
743
765
 
@@ -946,7 +968,7 @@ export namespace Linter {
946
968
  */
947
969
  impliedStrict?: boolean | undefined;
948
970
  /**
949
- * Enable [JSX](https://facebook.github.io/jsx/).
971
+ * Enable [JSX](https://react.github.io/jsx/).
950
972
  *
951
973
  * @default false
952
974
  */
@@ -964,11 +986,9 @@ export namespace Linter {
964
986
  filename?: string | undefined;
965
987
  preprocess?: ((code: string) => string[]) | undefined;
966
988
  postprocess?:
967
- | ((problemLists: LintMessage[][]) => LintMessage[])
968
- | undefined;
989
+ ((problemLists: LintMessage[][]) => LintMessage[]) | undefined;
969
990
  filterCodeBlock?:
970
- | ((filename: string, text: string) => boolean)
971
- | undefined;
991
+ ((filename: string, text: string) => boolean) | undefined;
972
992
  disableFixes?: boolean | undefined;
973
993
  allowInlineConfig?: boolean | undefined;
974
994
  reportUnusedDisableDirectives?: boolean | undefined;
@@ -1105,8 +1125,9 @@ export namespace Linter {
1105
1125
  interface TimePass {
1106
1126
  /**
1107
1127
  * The parse object containing all parse time information.
1128
+ * If no parsing was performed, the property is omitted.
1108
1129
  */
1109
- parse: { total: number };
1130
+ parse?: { total: number };
1110
1131
 
1111
1132
  /**
1112
1133
  * The rules object containing all lint time information for each rule.
package/dist/api.js CHANGED
@@ -1,7 +1,7 @@
1
- import{r as e,t}from"./chunk-qnHZjHhP.js";import{b as n,c as r,d as i,f as a,g as o,h as s,i as c,l,m as u,o as d,s as f,t as p,u as m}from"./eslint-BTrx12MV.js";var h=t(((e,t)=>{function n(e){return e===null||typeof e==`string`||typeof e==`boolean`||typeof e==`number`||typeof e==`object`&&e.constructor===Object||Array.isArray(e)}function r(e,t=new Set){if(!n(e))return!1;if(typeof e==`object`&&e){if(t.has(e))return!1;for(let i in e)if(Object.hasOwn(e,i)&&(!n(e[i])||typeof e[i]==`object`&&e[i]!==null&&!r(e[i],new Set([...t,e]))))return!1}return!0}t.exports={isSerializable:r}})),g=t(((t,p)=>{let g=e(`node:assert`),{existsSync:_,readFileSync:v}=e(`node:fs`),y=e(`node:util`),b=e(`node:path`),x=i(),S=n(),{Config:C}=l(),{Linter:w,SourceCodeFixer:T}=d(),{interpolate:E,getPlaceholderMatcher:ee}=f(),te=c(),{isSerializable:ne}=h(),{FlatConfigArray:re}=r(),{defaultConfig:D,defaultRuleTesterConfig:ie}=u(),O=m()({strictDefaults:!0}),k=Symbol.for(`eslint.RuleTester.parser`),{ConfigArraySymbol:A}=a(),ae=s(),{SourceCode:j}=o(),oe={rules:{}},M={rules:{}},se=[`name`,`code`,`filename`,`options`,`before`,`after`,`errors`,`output`,`only`],N=new Set([`message`,`messageId`,`data`,`line`,`column`,`endLine`,`endColumn`,`suggestions`]),ce=`[${[...N].map(e=>`'${e}'`).join(`, `)}]`,P=new Set([`desc`,`messageId`,`data`,`output`]),le=`[${[...P].map(e=>`'${e}'`).join(`, `)}]`,F=[`applyInlineConfig`,`applyLanguageOptions`,`finalize`],ue=new Map(F.map(e=>[e,new WeakSet])),I=Function.call.bind(Object.hasOwnProperty);function L(e){if(typeof e==`object`&&e){if(Array.isArray(e))return e.map(L);let t={};for(let n in e)n!==`parent`&&I(e,n)&&(t[n]=L(e[n]));return t}return e}function R(e,t=new Set){if(typeof e==`object`&&e){if(t.has(e))return;if(t.add(e),Array.isArray(e))e.forEach(e=>{R(e,t)});else for(let n in e)n!==`parent`&&I(e,n)&&R(e[n],t);Object.freeze(e)}}function z(e){return typeof e==`string`?e.replace(/[\u0000-\u0009\u000b-\u001a]/gu,e=>`\\u${e.codePointAt(0).toString(16).padStart(4,`0`)}`):``}function B(e,t){Object.defineProperties(t,{start:{get(){throw Error(`Use ${e}.range[0] instead of ${e}.start`)},configurable:!0,enumerable:!1},end:{get(){throw Error(`Use ${e}.range[1] instead of ${e}.end`)},configurable:!0,enumerable:!1}})}function V(e,t){S.traverse(e,{visitorKeys:t,enter:B.bind(null,`node`)}),e.tokens.forEach(B.bind(null,`token`)),e.comments.forEach(B.bind(null,`token`))}function de(e){return typeof e.parseForESLint==`function`?{[k]:e,parseForESLint(...t){let n=e.parseForESLint(...t);return V(n.ast,n.visitorKeys),n}}:{[k]:e,parse(...t){let n=e.parse(...t);return V(n),n}}}function fe(e,t){let n=t[e];return function(...t){let r=ue.get(e);if(!r.has(this))return r.add(this),n.apply(this,t);throw Error(`\`SourceCode#${e}()\` cannot be called inside a rule.`)}}function H(e){let t=ee();return Array.from(e.matchAll(t),([,e])=>e.trim())}function U(e,t,n={}){let r=H(e);if(r.length===0)return[];let i=H(t),a=Object.keys(n);return r.filter(e=>i.includes(e)&&!a.includes(e))}let W="\n - If the rule has options, set `meta.schema` to an array or non-empty object to enable options validation.\n - If the rule doesn't have options, omit `meta.schema` to enforce that no options can be passed to the rule.\n - You can also set `meta.schema` to `false` to opt-out of options validation (not recommended).\n\n https://eslint.org/docs/latest/extend/custom-rules#options-schemas\n",pe=new Set([`name`,`errors`,`output`]);function G(e){return e&&typeof e==`object`?e:{code:e}}function me(e,t,n={}){let r=typeof e==`number`,i=Array.isArray(e);!r&&!i&&(e===void 0?g.fail(`Did not specify errors for an invalid test of ${t}`):g.fail(`Invalid 'errors' property for invalid test of ${t}: expected a number or an array but got ${e===null?`null`:typeof e}`));let{requireMessage:a=!1,requireLocation:o=!1}=n;if(i){g.ok(e.length!==0,`Invalid cases must have at least one error`);for(let[t,n]of e.entries())if(typeof n==`string`||n instanceof RegExp)g.ok(a!==`messageId`&&!o,`errors[${t}] should be an object when 'assertionOptions.requireMessage' is 'messageId' or 'assertionOptions.requireLocation' is true.`);else if(typeof n==`object`&&n){for(let e of Object.keys(n))g.ok(N.has(e),`Invalid error property name '${e}'. Expected one of ${ce}.`);a===`message`?g.ok(!I(n,`messageId`)&&I(n,`message`),`errors[${t}] should specify 'message' (and not 'messageId') when 'assertionOptions.requireMessage' is 'message'.`):a===`messageId`&&g.ok(!I(n,`message`)&&I(n,`messageId`),`errors[${t}] should specify 'messageId' (and not 'message') when 'assertionOptions.requireMessage' is 'messageId'.`),I(n,`message`)?(g.ok(!I(n,`messageId`),`errors[${t}] should not specify both 'message' and 'messageId'.`),g.ok(!I(n,`data`),`errors[${t}] should not specify both 'data' and 'message'.`)):g.ok(I(n,`messageId`),`errors[${t}] must specify either 'messageId' or 'message'.`)}else g.fail(`errors[${t}] must be a string, RegExp, or an object.`)}else g.ok(!a&&!o,`Invalid cases must have 'errors' value as an array`),g.ok(e>0,`Invalid cases must have 'error' value greater than 0`)}function K(e,t){if(!ne(e))return;let n=te(e,{replacer(t,n){return e!==this||!pe.has(t)?n:void 0}});g(!t.has(n),`detected duplicate test case`),t.add(n)}function he(e,t){g.ok(e&&typeof e==`object`&&typeof e.create==`function`,`Rule ${t} must be an object with a \`create\` method`)}function ge(e,t){g.ok(e&&typeof e==`object`,`Test Scenarios for rule ${t} : Could not find test scenario object`);let n=Array.isArray(e.valid),r=Array.isArray(e.invalid);g.ok(n,`Test Scenarios for rule ${t} is invalid: Could not find any valid test scenarios`),g.ok(r,`Test Scenarios for rule ${t} is invalid: Could not find any invalid test scenarios`)}function q(e){g.ok(typeof e.code==`string`,`Test case must specify a string value for 'code'`),e.name&&g.ok(typeof e.name==`string`,`Optional test case property 'name' must be a string`),I(e,`only`)&&g.ok(typeof e.only==`boolean`,`Optional test case property 'only' must be a boolean`),I(e,`filename`)&&g.ok(typeof e.filename==`string`,`Optional test case property 'filename' must be a string`),I(e,`options`)&&g.ok(Array.isArray(e.options),`Optional test case property 'options' must be an array`)}function J(e,t){g.ok(e.errors===void 0,`Valid test case must not have 'errors' property`),g.ok(e.output===void 0,`Valid test case must not have 'output' property`),q(e),K(e,t)}function _e(e,t,n,r={}){q(e),me(e.errors,n,r),I(e,`output`)&&g.ok(e.output===null||typeof e.output==`string`,`Test property 'output', if specified, must be a string or null. If no autofix is expected, then omit the 'output' property or set it to null.`),K(e,t)}function Y(e=Y){let t={},n,{prepareStackTrace:r}=Error;return Error.prepareStackTrace=(e,[t])=>{n={sourceFile:t.getFileName()??`${t.getEvalOrigin()}, <anonymous>`,sourceLine:t.getLineNumber()??1,sourceColumn:t.getColumnNumber()??1}},Error.captureStackTrace(t,e),t.stack,Error.prepareStackTrace=r,n}function ve(e){let t=Y(e),n=null;return e=>{if(n===null){let{sourceFile:e,sourceLine:r,sourceColumn:i}=t;if(n={root:`${e}:${r}:${i}`},_(e)){let t=v(e,`utf8`).split(`
2
- `).slice(r-1);t[0]=t[0].slice(Math.max(0,i-1)),t=t.map(e=>e.trim().replace(/\s*\/\/.*$(?<!,)/u,``));let a=t.findIndex(e=>/\bvalid\s*:/u.test(e)),o=t.findIndex(e=>/\binvalid\s*:/u.test(e));n.valid=`${e}:${r+a}`,n.invalid=`${e}:${r+o}`;let s=a<o?o:t.length,c=a<o?t.length:a,l=t.slice(a,s),u=t.slice(o,c),d=0,f=l.map((e,t)=>(/^(?:\w+\s*:\s*)?\{/u.test(e)&&d++,d>0?((e.endsWith(`}`)||e.endsWith(`},`))&&d--,d<=1&&e.includes(`code:`)?t:null):e.endsWith(`,`)?t:null)).filter(Boolean),p=u.map((e,t)=>e.trimStart().startsWith(`errors:`)?t:null).filter(Boolean);Object.assign(n,{"valid[0]":`${e}:${r+a}`},Object.fromEntries(f.map((t,n)=>[`valid[${n}]`,`${e}:${r+a+t}`])),Object.fromEntries(p.map((t,n)=>[`invalid[${n}]`,`${e}:${r+o+t}`]))),p.push(u.length);for(let t=0;t<p.length-1;t++){let i=p[t],a=p[t+1],s=u.slice(i,a),c=0,l=s.map((e,t)=>e.startsWith(`{`)||e.endsWith(`{`)?(c++,(e.endsWith(`}`)||e.endsWith(`},`))&&c--,c<=1?t:null):c>0?((e.endsWith(`}`)||e.endsWith(`},`))&&c--,null):e.endsWith(`,`)?t:null).filter(Boolean);Object.assign(n,Object.fromEntries(l.map((n,a)=>[`invalid[${t}].errors[${a}]`,`${e}:${r+o+i+n}`])))}}}return n[e]||`unknown source`}}let X=Symbol(`describe`),Z=Symbol(`it`),Q=Symbol(`itOnly`);function ye(e,t){try{return t.call(this)}catch(e){throw e instanceof g.AssertionError&&(e.message+=` (${y.inspect(e.actual)} ${e.operator} ${y.inspect(e.expected)})`),e}}function be(e,t){return t.call(this)}var $=class{constructor(e={}){this.testerConfig=[M,e,{rules:{"rule-tester/validate-ast":`error`}}],this.linter=new w({configType:`flat`})}static setDefaultConfig(e){if(typeof e!=`object`||!e)throw TypeError(`RuleTester.setDefaultConfig: config must be an object`);M=e,M.rules=M.rules||{}}static getDefaultConfig(){return M}static resetDefaultConfig(){M={rules:{...oe.rules}}}static get describe(){return this[X]||(typeof describe==`function`?describe:be)}static set describe(e){this[X]=e}static get it(){return this[Z]||(typeof it==`function`?it:ye)}static set it(e){this[Z]=e}static only(e){return typeof e==`string`?{code:e,only:!0}:{...e,only:!0}}static get itOnly(){if(typeof this[Q]==`function`)return this[Q];if(typeof this[Z]==`function`&&typeof this[Z].only==`function`)return Function.bind.call(this[Z].only,this[Z]);if(typeof it==`function`&&typeof it.only==`function`)return Function.bind.call(it.only,it);throw typeof this[X]==`function`||typeof this[Z]==`function`?Error("Set `RuleTester.itOnly` to use `only` with a custom test framework.\nSee https://eslint.org/docs/latest/integrate/nodejs-api#customizing-ruletester for more."):Error(typeof it==`function`?"The current test framework does not support exclusive tests with `only`.":"To use `only`, use RuleTester with a test framework that provides `it.only()` like Mocha.")}static set itOnly(e){this[Q]=e}run(e,t,n){let r=this.testerConfig,i=this.linter,a=`rule-to-test/${e}`;he(t,e),ge(n,e);let o=ve(this.run),s=[{plugins:{"@":{parsers:{...D[0].plugins[`@`].parsers},rules:D[0].plugins[`@`].rules,languages:D[0].plugins[`@`].languages},"rule-to-test":{rules:{[e]:Object.assign({},t,{create(e){return R(e.options),R(e.settings),R(e.parserOptions),t.create(e)}})}}},language:D[0].language},...ie];function c(e,t){I(e,t)&&(g.strictEqual(typeof e[t],`function`,`Optional test case property '${t}' must be a function`),e[t]())}function l(n){let o=n.code,c=I(n,`filename`)?n.filename:void 0,l=I(n,`options`)?n.options:[],u={baseConfig:s};c&&(u.basePath=b.parse(c).root||void 0);let d=new re(r,u);d[A.finalizeConfig]=function(...e){let t=Object.getPrototypeOf(this)[A.finalizeConfig].apply(this,e);return t.language===ae&&(t.languageOptions.parser=de(t.languageOptions.parser)),t};let f,p,m,h={...n};for(let e of se)delete h[e];d.push(h),d.push({rules:{[a]:[1,...l]}});let _;try{_=C.getRuleOptionsSchema(t)}catch(e){throw e.message+=W,e}if(_&&Object.keys(_).length===0)throw Error(`\`schema: {}\` is a no-op${W}`);if(d.push({plugins:{"rule-tester":{rules:{"validate-ast":{create(){return{Program(e){p=L(e)},"Program:exit"(e){m=e}}}}}}}}),_){if(O.validateSchema(_),O.errors){let t=O.errors.map(e=>`\t${e.dataPath[0]===`.`?e.dataPath.slice(1):e.dataPath}: ${e.message}`).join(`
3
- `);throw Error([`Schema for rule ${e} is invalid:`,t])}try{O.compile(_)}catch(t){throw Error(`Schema for rule ${e} is invalid: ${t.message}`,{cause:t})}}try{d.normalizeSync(),d.getConfig(`test.js`)}catch(e){throw e.message=`ESLint configuration in rule-tester is invalid: ${e.message}`,e}let{applyLanguageOptions:v,applyInlineConfig:y,finalize:x}=j.prototype,S;try{F.forEach(e=>{j.prototype[e]=fe(e,j.prototype)}),S=i.verify(o,d,c)}finally{j.prototype.applyInlineConfig=y,j.prototype.applyLanguageOptions=v,j.prototype.finalize=x}let w=S.find(e=>e.fatal);if(g(!w,`A fatal parsing error occurred: ${w&&w.message}`),S.some(e=>e.fix)){f=T.applyFixes(o,S).output;let e=i.verify(f,d,c).find(e=>e.fatal);g(!e,[`A fatal parsing error occurred in autofix.`,`Error: ${e&&e.message}`,`Autofix output:`,f].join(`
4
- `))}else f=o;return{messages:S,output:f,beforeAST:p,afterAST:L(m),configs:d,filename:c}}function u(e,t){x(e,t)||g.fail(`Rule should not modify AST.`)}function d(e){let t=l(e),n=t.messages;g.strictEqual(n.length,0,y.format(`Should have no errors but had %d: %s`,n.length,y.inspect(n))),u(t.beforeAST,t.afterAST)}function f(e,t){t instanceof RegExp?g.ok(t.test(e),`Expected '${e}' to match ${t}`):g.strictEqual(e,t)}function p(e){let{requireMessage:r=!1,requireLocation:o=!1,requireData:s=!1}=n.assertionOptions??{},c=I(t,`meta`)&&I(t.meta,`messages`),d=c?`[${Object.keys(t.meta.messages).map(e=>`'${e}'`).join(`, `)}]`:null;g.ok(c||r!==`messageId`,`Assertion options can not use 'requireMessage: "messageId"' if rule under test doesn't define 'meta.messages'.`);let p=l(e),m=p.messages;for(let e of m)if(I(e,`suggestions`)){let t=new Map;for(let n=0;n<e.suggestions.length;n+=1){let r=e.suggestions[n].desc,i=t.get(r);g.ok(!t.has(r),`Suggestion message '${r}' reported from suggestion ${n} was previously reported by suggestion ${i}. Suggestion messages should be unique within an error.`),t.set(r,n)}}if(typeof e.errors==`number`)g.strictEqual(m.length,e.errors,y.format(`Should have %d error%s but had %d: %s`,e.errors,e.errors===1?``:`s`,m.length,y.inspect(m)));else{g.strictEqual(m.length,e.errors.length,y.format(`Should have %d error%s but had %d: %s`,e.errors.length,e.errors.length===1?``:`s`,m.length,y.inspect(m)));let n=m.some(e=>e.ruleId===a);for(let r=0,a=e.errors.length;r<a;r++)try{let a=e.errors[r],l=m[r];if(g(n,`Error rule name should be the same as the name of the rule being tested`),typeof a==`string`||a instanceof RegExp)f(l.message,a),g.ok(l.suggestions===void 0,`Error at index ${r} has suggestions. Please convert the test error into an object and specify 'suggestions' property on it to test suggestions.`);else if(typeof a==`object`&&a){if(I(a,`message`))f(l.message,a.message);else if(I(a,`messageId`)){g.ok(c,`Error can not use 'messageId' if rule under test doesn't define 'meta.messages'.`),I(t.meta.messages,a.messageId)||g(!1,`Invalid messageId '${a.messageId}'. Expected one of ${d}.`),g.strictEqual(l.messageId,a.messageId,`messageId '${l.messageId}' does not match expected messageId '${a.messageId}'.`);let e=U(l.message,t.meta.messages[l.messageId],a.data);if(g.ok(e.length===0,`The reported message has ${e.length>1?`unsubstituted placeholders: ${e.map(e=>`'${e}'`).join(`, `)}`:`an unsubstituted placeholder '${e[0]}'`}. Please provide the missing ${e.length>1?`values`:`value`} via the 'data' property in the context.report() call.`),I(a,`data`)){let e=t.meta.messages[a.messageId],n=E(e,a.data);g.strictEqual(l.message,n,`Hydrated message "${n}" does not match "${l.message}"`)}else{let e=s===!0||s===`error`,n=H(t.meta.messages[a.messageId]).length>0;g.ok(!e||!n,`Error should specify the 'data' property as the referenced message has placeholders.`)}}let n=[`line`,`column`,`endLine`,`endColumn`],u={},m={};for(let e of n)I(a,e)&&(u[e]=l[e],m[e]=a[e]);if(o){let e=n.filter(e=>!I(a,e)&&I(l,e));g.ok(e.length===0,`Error is missing expected location properties: ${e.join(`, `)}`)}if(Object.keys(m).length>0&&g.deepStrictEqual(u,m,`Actual error location does not match expected error location.`),g.ok(!l.suggestions||I(a,`suggestions`),`Error at index ${r} has suggestions. Please specify 'suggestions' property on the test error object.`),I(a,`suggestions`)){let n=Array.isArray(a.suggestions)?a.suggestions.length>0:!!a.suggestions,r=l.suggestions!==void 0;!r&&n?g.ok(!a.suggestions,`Error should have suggestions on error with message: "${l.message}"`):r&&(g.ok(n,`Error should have no suggestions on error with message: "${l.message}"`),typeof a.suggestions==`number`?g.strictEqual(l.suggestions.length,a.suggestions,`Error should have ${a.suggestions} suggestions. Instead found ${l.suggestions.length} suggestions`):Array.isArray(a.suggestions)?(g.strictEqual(l.suggestions.length,a.suggestions.length,`Error should have ${a.suggestions.length} suggestions. Instead found ${l.suggestions.length} suggestions`),a.suggestions.forEach((n,r)=>{g.ok(typeof n==`object`&&!!n,`Test suggestion in 'suggestions' array must be an object.`),Object.keys(n).forEach(e=>{g.ok(P.has(e),`Invalid suggestion property name '${e}'. Expected one of ${le}.`)});let a=l.suggestions[r],o=`Error Suggestion at index ${r}:`;if(I(n,`desc`))g.ok(!I(n,`data`),`${o} Test should not specify both 'desc' and 'data'.`),g.ok(!I(n,`messageId`),`${o} Test should not specify both 'desc' and 'messageId'.`),g.strictEqual(a.desc,n.desc,`${o} desc should be "${n.desc}" but got "${a.desc}" instead.`);else if(I(n,`messageId`)){g.ok(c,`${o} Test can not use 'messageId' if rule under test doesn't define 'meta.messages'.`),g.ok(I(t.meta.messages,n.messageId),`${o} Test has invalid messageId '${n.messageId}', the rule under test allows only one of ${d}.`),g.strictEqual(a.messageId,n.messageId,`${o} messageId should be '${n.messageId}' but got '${a.messageId}' instead.`);let e=t.meta.messages[n.messageId],r=U(a.desc,e,n.data);if(g.ok(r.length===0,`The message of the suggestion has ${r.length>1?`unsubstituted placeholders: ${r.map(e=>`'${e}'`).join(`, `)}`:`an unsubstituted placeholder '${r[0]}'`}. Please provide the missing ${r.length>1?`values`:`value`} via the 'data' property for the suggestion in the context.report() call.`),I(n,`data`)){let e=t.meta.messages[n.messageId],r=E(e,n.data);g.strictEqual(a.desc,r,`${o} Hydrated test desc "${r}" does not match received desc "${a.desc}".`)}else{let t=s===!0||s===`suggestion`,n=H(e).length>0;g.ok(!t||!n,`${o} Suggestion should specify the 'data' property as the referenced message has placeholders.`)}}else I(n,`data`)?g.fail(`${o} Test must specify 'messageId' if 'data' is used.`):g.fail(`${o} Test must specify either 'messageId' or 'desc'.`);g.ok(I(n,`output`),`${o} The "output" property is required.`);let u=T.applyFixes(e.code,[a]).output,f=i.verify(u,p.configs,p.filename).find(e=>e.fatal);g(!f,[`A fatal parsing error occurred in suggestion fix.`,`Error: ${f&&f.message}`,`Suggestion output:`,u].join(`
5
- `)),g.strictEqual(u,n.output,`Expected the applied suggestion fix to match the test suggestion output for suggestion at index: ${r} on error with message: "${l.message}"`),g.notStrictEqual(n.output,e.code,`The output of a suggestion should differ from the original source code for suggestion at index: ${r} on error with message: "${l.message}"`)})):g.fail(`Test error object property 'suggestions' should be an array or a number`))}}}catch(e){throw e instanceof Error&&(e.errorIndex=r),e}}I(e,`output`)?e.output===null?g.strictEqual(p.output,e.code,`Expected no autofixes to be suggested`):(g.strictEqual(p.output,e.output,`Output is incorrect.`),g.notStrictEqual(e.code,e.output,`Test property 'output' matches 'code'. If no autofix is expected, then omit the 'output' property or set it to null.`)):g.strictEqual(p.output,e.code,`The rule fixed the code. Please add 'output' property.`),u(p.beforeAST,p.afterAST)}this.constructor.describe(e,()=>{n.valid.length>0&&this.constructor.describe(`valid`,()=>{let e=new Set;n.valid.forEach((t,n)=>{let r=G(t);this.constructor[t.only?`itOnly`:`it`](z(r.name||r.code),()=>{try{c(r,`before`),J(r,e),d(r)}catch(e){throw e instanceof Error&&(e.scenarioType=`valid`,e.scenarioIndex=n,e.stack=e.stack.replace(/^ +at /mu,[` roughly at RuleTester.run.valid[${n}] (${o(`valid[${n}]`)})`,` roughly at RuleTester.run.valid (${o(`valid`)})`,` at RuleTester.run (${o(`root`)})`,` at `].join(`
6
- `))),e}finally{c(r,`after`)}})})}),n.invalid.length>0&&this.constructor.describe(`invalid`,()=>{let t=new Set;n.invalid.forEach((r,i)=>{let a=G(r);this.constructor[a.only?`itOnly`:`it`](z(a.name||a.code),()=>{try{c(a,`before`),_e(a,t,e,n.assertionOptions),p(a)}catch(e){if(e instanceof Error){e.scenarioType=`invalid`,e.scenarioIndex=i;let t=e.errorIndex;e.stack=e.stack.replace(/^ +at /mu,[...typeof t==`number`?[` roughly at RuleTester.run.invalid[${i}].error[${t}] (${o(`invalid[${i}].errors[${t}]`)})`]:[],` roughly at RuleTester.run.invalid[${i}] (${o(`invalid[${i}]`)})`,` roughly at RuleTester.run.invalid (${o(`invalid`)})`,` at RuleTester.run (${o(`root`)})`,` at `].join(`
7
- `))}throw e}finally{c(a,`after`)}})})})})}};$[X]=$[Z]=$[Q]=null,p.exports=$})),_=t(((e,t)=>{t.exports={RuleTester:g()}})),v=t(((e,t)=>{let{ESLint:n}=p(),{Linter:r}=d(),{RuleTester:i}=_(),{SourceCode:a}=o();async function s(){return n}t.exports={Linter:r,loadESLint:s,ESLint:n,RuleTester:i,SourceCode:a}}))(),y=v.ESLint,b=v.Linter,x=v.RuleTester,S=v.SourceCode,C=v.loadESLint;export{y as ESLint,b as Linter,x as RuleTester,S as SourceCode,C as loadESLint};
1
+ import{i as e,t}from"./rolldown-runtime-CN7XbDR5.js";import{b as n,c as r,d as i,f as a,g as o,h as s,i as c,l,m as u,o as d,s as f,t as p,u as m}from"./eslint-BYId4sVl.js";var h=/* @__PURE__ */ t(((e,t)=>{function n(e){return e===null||typeof e==`string`||typeof e==`boolean`||typeof e==`number`||typeof e==`object`&&e.constructor===Object||Array.isArray(e)}function r(e,t=/* @__PURE__ */ new Set){if(!n(e))return!1;if(typeof e==`object`&&e){if(t.has(e))return!1;for(let i in e)if(Object.hasOwn(e,i)&&(!n(e[i])||typeof e[i]==`object`&&e[i]!==null&&!r(e[i],/* @__PURE__ */ new Set([...t,e]))))return!1}return!0}t.exports={isSerializable:r}})),g=/* @__PURE__ */ t(((t,p)=>{let g=e(`node:assert`),{existsSync:_,readFileSync:v}=e(`node:fs`),y=e(`node:util`),b=e(`node:path`),x=i(),S=n(),{Config:C}=l(),{Linter:w,SourceCodeFixer:T}=d(),{interpolate:E,getPlaceholderMatcher:ee}=f(),te=c(),{isSerializable:ne}=h(),{FlatConfigArray:re}=r(),{defaultConfig:D,defaultRuleTesterConfig:ie}=u(),O=Symbol.for(`eslint.RuleTester.parser`),{ConfigArraySymbol:k}=a(),ae=s(),{SourceCode:A}=o(),j={rules:{}},M,N={rules:{}},oe=[`name`,`code`,`filename`,`options`,`before`,`after`,`errors`,`output`,`only`],P=/* @__PURE__ */ new Set([`message`,`messageId`,`data`,`line`,`column`,`endLine`,`endColumn`,`suggestions`]),se=`[${[...P].map(e=>`'${e}'`).join(`, `)}]`,F=/* @__PURE__ */ new Set([`desc`,`messageId`,`data`,`output`]),ce=`[${[...F].map(e=>`'${e}'`).join(`, `)}]`,I=[`applyInlineConfig`,`applyLanguageOptions`,`finalize`],le=new Map(I.map(e=>[e,/* @__PURE__ */ new WeakSet])),L=Function.call.bind(Object.hasOwnProperty);function ue(){return M||=m()({strictDefaults:!0}),M}function R(e){if(typeof e==`object`&&e){if(Array.isArray(e))return e.map(R);let t={};for(let n in e)n!==`parent`&&L(e,n)&&(t[n]=R(e[n]));return t}return e}function z(e,t=/* @__PURE__ */ new Set){if(typeof e==`object`&&e){if(t.has(e))return;if(t.add(e),Array.isArray(e))e.forEach(e=>{z(e,t)});else for(let n in e)n!==`parent`&&L(e,n)&&z(e[n],t);Object.freeze(e)}}function B(e){return typeof e==`string`?e.replace(/[\u0000-\u0009\u000b-\u001a]/gu,e=>`\\u${e.codePointAt(0).toString(16).padStart(4,`0`)}`):``}function V(e,t){Object.defineProperties(t,{start:{get(){throw Error(`Use ${e}.range[0] instead of ${e}.start`)},configurable:!0,enumerable:!1},end:{get(){throw Error(`Use ${e}.range[1] instead of ${e}.end`)},configurable:!0,enumerable:!1}})}function H(e,t){S.traverse(e,{visitorKeys:t,enter:V.bind(null,`node`)}),e.tokens.forEach(V.bind(null,`token`)),e.comments.forEach(V.bind(null,`token`))}function de(e){return typeof e.parseForESLint==`function`?{[O]:e,parseForESLint(...t){let n=e.parseForESLint(...t);return H(n.ast,n.visitorKeys),n}}:{[O]:e,parse(...t){let n=e.parse(...t);return H(n),n}}}function fe(e,t){let n=t[e];return function(...t){let r=le.get(e);if(!r.has(this))return r.add(this),n.apply(this,t);throw Error(`\`SourceCode#${e}()\` cannot be called inside a rule.`)}}function U(e){let t=ee();return Array.from(e.matchAll(t),([,e])=>e.trim())}function W(e,t,n={}){let r=U(e);if(r.length===0)return[];let i=U(t),a=Object.keys(n);return r.filter(e=>i.includes(e)&&!a.includes(e))}let G="\n - If the rule has options, set `meta.schema` to an array or non-empty object to enable options validation.\n - If the rule doesn't have options, omit `meta.schema` to enforce that no options can be passed to the rule.\n - You can also set `meta.schema` to `false` to opt-out of options validation (not recommended).\n\n https://eslint.org/docs/latest/extend/custom-rules#options-schemas\n",pe=/* @__PURE__ */ new Set([`name`,`errors`,`output`]);function K(e){return e&&typeof e==`object`?e:{code:e}}function me(e,t,n={}){let r=typeof e==`number`,i=Array.isArray(e);!r&&!i&&(e===void 0?g.fail(`Did not specify errors for an invalid test of ${t}`):g.fail(`Invalid 'errors' property for invalid test of ${t}: expected a number or an array but got ${e===null?`null`:typeof e}`));let{requireMessage:a=!1,requireLocation:o=!1}=n;if(i){g.ok(e.length!==0,`Invalid cases must have at least one error`);for(let[t,n]of e.entries())if(typeof n==`string`||n instanceof RegExp)g.ok(a!==`messageId`&&!o,`errors[${t}] should be an object when 'assertionOptions.requireMessage' is 'messageId' or 'assertionOptions.requireLocation' is true.`);else if(typeof n==`object`&&n){for(let e of Object.keys(n))g.ok(P.has(e),`Invalid error property name '${e}'. Expected one of ${se}.`);a===`message`?g.ok(!L(n,`messageId`)&&L(n,`message`),`errors[${t}] should specify 'message' (and not 'messageId') when 'assertionOptions.requireMessage' is 'message'.`):a===`messageId`&&g.ok(!L(n,`message`)&&L(n,`messageId`),`errors[${t}] should specify 'messageId' (and not 'message') when 'assertionOptions.requireMessage' is 'messageId'.`),L(n,`message`)?(g.ok(!L(n,`messageId`),`errors[${t}] should not specify both 'message' and 'messageId'.`),g.ok(!L(n,`data`),`errors[${t}] should not specify both 'data' and 'message'.`)):g.ok(L(n,`messageId`),`errors[${t}] must specify either 'messageId' or 'message'.`)}else g.fail(`errors[${t}] must be a string, RegExp, or an object.`)}else g.ok(!a&&!o,`Invalid cases must have 'errors' value as an array`),g.ok(e>0,`Invalid cases must have 'error' value greater than 0`)}function q(e,t){if(!ne(e))return;let n=te(e,{replacer(t,n){return e!==this||!pe.has(t)?n:void 0}});g(!t.has(n),`detected duplicate test case`),t.add(n)}function he(e,t){g.ok(e&&typeof e==`object`&&typeof e.create==`function`,`Rule ${t} must be an object with a \`create\` method`)}function ge(e,t){g.ok(e&&typeof e==`object`,`Test Scenarios for rule ${t} : Could not find test scenario object`);let n=Array.isArray(e.valid),r=Array.isArray(e.invalid);g.ok(n,`Test Scenarios for rule ${t} is invalid: Could not find any valid test scenarios`),g.ok(r,`Test Scenarios for rule ${t} is invalid: Could not find any invalid test scenarios`)}function J(e){g.ok(typeof e.code==`string`,`Test case must specify a string value for 'code'`),e.name&&g.ok(typeof e.name==`string`,`Optional test case property 'name' must be a string`),L(e,`only`)&&g.ok(typeof e.only==`boolean`,`Optional test case property 'only' must be a boolean`),L(e,`filename`)&&g.ok(typeof e.filename==`string`,`Optional test case property 'filename' must be a string`),L(e,`options`)&&g.ok(Array.isArray(e.options),`Optional test case property 'options' must be an array`)}function _e(e,t){g.ok(e.errors===void 0,`Valid test case must not have 'errors' property`),g.ok(e.output===void 0,`Valid test case must not have 'output' property`),J(e),q(e,t)}function ve(e,t,n,r={}){J(e),me(e.errors,n,r),L(e,`output`)&&g.ok(e.output===null||typeof e.output==`string`,`Test property 'output', if specified, must be a string or null. If no autofix is expected, then omit the 'output' property or set it to null.`),q(e,t)}function Y(e=Y){let t={},n,{prepareStackTrace:r}=Error;return Error.prepareStackTrace=(e,[t])=>{n={sourceFile:t.getFileName()??`${t.getEvalOrigin()}, <anonymous>`,sourceLine:t.getLineNumber()??1,sourceColumn:t.getColumnNumber()??1}},Error.captureStackTrace(t,e),t.stack,Error.prepareStackTrace=r,n}function ye(e){let t=Y(e),n=null;return e=>{if(n===null){let{sourceFile:e,sourceLine:r,sourceColumn:i}=t;if(n={root:`${e}:${r}:${i}`},_(e)){let t=v(e,`utf8`).split(`
2
+ `).slice(r-1);t[0]=t[0].slice(Math.max(0,i-1)),t=t.map(e=>e.trim().replace(/\s*\/\/.*$(?<!,)/u,``));let a=t.findIndex(e=>/\bvalid\s*:/u.test(e)),o=t.findIndex(e=>/\binvalid\s*:/u.test(e));n.valid=`${e}:${r+a}`,n.invalid=`${e}:${r+o}`;let s=a<o?o:t.length,c=a<o?t.length:a,l=t.slice(a,s),u=t.slice(o,c),d=0,f=l.map((e,t)=>(/^(?:\w+\s*:\s*)?\{/u.test(e)&&d++,d>0?((e.endsWith(`}`)||e.endsWith(`},`))&&d--,d<=1&&e.includes(`code:`)?t:null):e.endsWith(`,`)?t:null)).filter(Boolean),p=u.map((e,t)=>e.trimStart().startsWith(`errors:`)?t:null).filter(Boolean);Object.assign(n,{"valid[0]":`${e}:${r+a}`},Object.fromEntries(f.map((t,n)=>[`valid[${n}]`,`${e}:${r+a+t}`])),Object.fromEntries(p.map((t,n)=>[`invalid[${n}]`,`${e}:${r+o+t}`]))),p.push(u.length);for(let t=0;t<p.length-1;t++){let i=p[t],a=p[t+1],s=u.slice(i,a),c=0,l=s.map((e,t)=>e.startsWith(`{`)||e.endsWith(`{`)?(c++,(e.endsWith(`}`)||e.endsWith(`},`))&&c--,c<=1?t:null):c>0?((e.endsWith(`}`)||e.endsWith(`},`))&&c--,null):e.endsWith(`,`)?t:null).filter(Boolean);Object.assign(n,Object.fromEntries(l.map((n,a)=>[`invalid[${t}].errors[${a}]`,`${e}:${r+o+i+n}`])))}}}return n[e]||`unknown source`}}let X=Symbol(`describe`),Z=Symbol(`it`),Q=Symbol(`itOnly`);function be(e,t){try{return t.call(this)}catch(e){throw e instanceof g.AssertionError&&(e.message+=` (${y.inspect(e.actual)} ${e.operator} ${y.inspect(e.expected)})`),e}}function xe(e,t){return t.call(this)}var $=class{constructor(e={}){this.testerConfig=[N,e,{rules:{"rule-tester/validate-ast":`error`}}],this.linter=new w({configType:`flat`})}static setDefaultConfig(e){if(typeof e!=`object`||!e)throw TypeError(`RuleTester.setDefaultConfig: config must be an object`);N=e,N.rules=N.rules||{}}static getDefaultConfig(){return N}static resetDefaultConfig(){N={rules:{...j.rules}}}static get describe(){return this[X]||(typeof describe==`function`?describe:xe)}static set describe(e){this[X]=e}static get it(){return this[Z]||(typeof it==`function`?it:be)}static set it(e){this[Z]=e}static only(e){return typeof e==`string`?{code:e,only:!0}:{...e,only:!0}}static get itOnly(){if(typeof this[Q]==`function`)return this[Q];if(typeof this[Z]==`function`&&typeof this[Z].only==`function`)return Function.bind.call(this[Z].only,this[Z]);if(typeof it==`function`&&typeof it.only==`function`)return Function.bind.call(it.only,it);throw typeof this[X]==`function`||typeof this[Z]==`function`?Error("Set `RuleTester.itOnly` to use `only` with a custom test framework.\nSee https://eslint.org/docs/latest/integrate/nodejs-api#customizing-ruletester for more."):Error(typeof it==`function`?"The current test framework does not support exclusive tests with `only`.":"To use `only`, use RuleTester with a test framework that provides `it.only()` like Mocha.")}static set itOnly(e){this[Q]=e}run(e,t,n){let r=this.testerConfig,i=this.linter,a=`rule-to-test/${e}`;he(t,e),ge(n,e);let o=ye(this.run),s=[{plugins:{"@":{parsers:{...D[0].plugins[`@`].parsers},rules:D[0].plugins[`@`].rules,languages:D[0].plugins[`@`].languages},"rule-to-test":{rules:{[e]:Object.assign({},t,{create(e){return z(e.options),z(e.settings),z(e.parserOptions),t.create(e)}})}}},language:D[0].language},...ie];function c(e,t){L(e,t)&&(g.strictEqual(typeof e[t],`function`,`Optional test case property '${t}' must be a function`),e[t]())}function l(n){let o=n.code,c=L(n,`filename`)?n.filename:void 0,l=L(n,`options`)?n.options:[],u={baseConfig:s};c&&(u.basePath=b.parse(c).root||void 0);let d=new re(r,u);d[k.finalizeConfig]=function(...e){let t=Object.getPrototypeOf(this)[k.finalizeConfig].apply(this,e);return t.language===ae&&(t.languageOptions.parser=de(t.languageOptions.parser)),t};let f,p,m,h={...n};for(let e of oe)delete h[e];d.push(h),d.push({rules:{[a]:[1,...l]}});let _;try{_=C.getRuleOptionsSchema(t)}catch(e){throw e.message+=G,e}if(_&&Object.keys(_).length===0)throw Error(`\`schema: {}\` is a no-op${G}`);if(d.push({plugins:{"rule-tester":{rules:{"validate-ast":{create(){return{Program(e){p=R(e)},"Program:exit"(e){m=e}}}}}}}}),_){let t=ue();if(t.validateSchema(_),t.errors){let n=t.errors.map(e=>`\t${e.dataPath[0]===`.`?e.dataPath.slice(1):e.dataPath}: ${e.message}`).join(`
3
+ `);throw Error([`Schema for rule ${e} is invalid:`,n])}try{t.compile(_)}catch(t){throw Error(`Schema for rule ${e} is invalid: ${t.message}`,{cause:t})}}try{d.normalizeSync(),d.getConfig(`test.js`)}catch(e){throw e.message=`ESLint configuration in rule-tester is invalid: ${e.message}`,e}let{applyLanguageOptions:v,applyInlineConfig:y,finalize:x}=A.prototype,S;try{I.forEach(e=>{A.prototype[e]=fe(e,A.prototype)}),S=i.verify(o,d,c)}finally{A.prototype.applyInlineConfig=y,A.prototype.applyLanguageOptions=v,A.prototype.finalize=x}let w=S.find(e=>e.fatal);if(g(!w,`A fatal parsing error occurred: ${w&&w.message}`),S.some(e=>e.fix)){f=T.applyFixes(o,S).output;let e=i.verify(f,d,c).find(e=>e.fatal);g(!e,[`A fatal parsing error occurred in autofix.`,`Error: ${e&&e.message}`,`Autofix output:`,f].join(`
4
+ `))}else f=o;return{messages:S,output:f,beforeAST:p,afterAST:R(m),configs:d,filename:c}}function u(e,t){x(e,t)||g.fail(`Rule should not modify AST.`)}function d(e){let t=l(e),n=t.messages;g.strictEqual(n.length,0,y.format(`Should have no errors but had %d: %s`,n.length,y.inspect(n))),u(t.beforeAST,t.afterAST)}function f(e,t){t instanceof RegExp?g.ok(t.test(e),`Expected '${e}' to match ${t}`):g.strictEqual(e,t)}function p(e){let{requireMessage:r=!1,requireLocation:o=!1,requireData:s=!1}=n.assertionOptions??{},c=L(t,`meta`)&&L(t.meta,`messages`),d=c?`[${Object.keys(t.meta.messages).map(e=>`'${e}'`).join(`, `)}]`:null;g.ok(c||r!==`messageId`,`Assertion options can not use 'requireMessage: "messageId"' if rule under test doesn't define 'meta.messages'.`);let p=l(e),m=p.messages;for(let e of m)if(L(e,`suggestions`)){let t=/* @__PURE__ */ new Map;for(let n=0;n<e.suggestions.length;n+=1){let r=e.suggestions[n].desc,i=t.get(r);g.ok(!t.has(r),`Suggestion message '${r}' reported from suggestion ${n} was previously reported by suggestion ${i}. Suggestion messages should be unique within an error.`),t.set(r,n)}}if(typeof e.errors==`number`)g.strictEqual(m.length,e.errors,y.format(`Should have %d error%s but had %d: %s`,e.errors,e.errors===1?``:`s`,m.length,y.inspect(m)));else{g.strictEqual(m.length,e.errors.length,y.format(`Should have %d error%s but had %d: %s`,e.errors.length,e.errors.length===1?``:`s`,m.length,y.inspect(m)));let n=m.some(e=>e.ruleId===a);for(let r=0,a=e.errors.length;r<a;r++)try{let a=e.errors[r],l=m[r];if(g(n,`Error rule name should be the same as the name of the rule being tested`),typeof a==`string`||a instanceof RegExp)f(l.message,a),g.ok(l.suggestions===void 0,`Error at index ${r} has suggestions. Please convert the test error into an object and specify 'suggestions' property on it to test suggestions.`);else if(typeof a==`object`&&a){if(L(a,`message`))f(l.message,a.message);else if(L(a,`messageId`)){g.ok(c,`Error can not use 'messageId' if rule under test doesn't define 'meta.messages'.`),L(t.meta.messages,a.messageId)||g(!1,`Invalid messageId '${a.messageId}'. Expected one of ${d}.`),g.strictEqual(l.messageId,a.messageId,`messageId '${l.messageId}' does not match expected messageId '${a.messageId}'.`);let e=W(l.message,t.meta.messages[l.messageId],a.data);if(g.ok(e.length===0,`The reported message has ${e.length>1?`unsubstituted placeholders: ${e.map(e=>`'${e}'`).join(`, `)}`:`an unsubstituted placeholder '${e[0]}'`}. Please provide the missing ${e.length>1?`values`:`value`} via the 'data' property in the context.report() call.`),L(a,`data`)){let e=t.meta.messages[a.messageId],n=E(e,a.data);g.strictEqual(l.message,n,`Hydrated message "${n}" does not match "${l.message}"`)}else{let e=s===!0||s===`error`,n=U(t.meta.messages[a.messageId]).length>0;g.ok(!e||!n,`Error should specify the 'data' property as the referenced message has placeholders.`)}}let n=[`line`,`column`,`endLine`,`endColumn`],u={},m={};for(let e of n)L(a,e)&&(u[e]=l[e],m[e]=a[e]);if(o){let e=n.filter(e=>!L(a,e)&&L(l,e));g.ok(e.length===0,`Error is missing expected location properties: ${e.join(`, `)}`)}if(Object.keys(m).length>0&&g.deepStrictEqual(u,m,`Actual error location does not match expected error location.`),g.ok(!l.suggestions||L(a,`suggestions`),`Error at index ${r} has suggestions. Please specify 'suggestions' property on the test error object.`),L(a,`suggestions`)){let n=Array.isArray(a.suggestions)?a.suggestions.length>0:!!a.suggestions,r=l.suggestions!==void 0;!r&&n?g.ok(!a.suggestions,`Error should have suggestions on error with message: "${l.message}"`):r&&(g.ok(n,`Error should have no suggestions on error with message: "${l.message}"`),typeof a.suggestions==`number`?g.strictEqual(l.suggestions.length,a.suggestions,`Error should have ${a.suggestions} suggestions. Instead found ${l.suggestions.length} suggestions`):Array.isArray(a.suggestions)?(g.strictEqual(l.suggestions.length,a.suggestions.length,`Error should have ${a.suggestions.length} suggestions. Instead found ${l.suggestions.length} suggestions`),a.suggestions.forEach((n,r)=>{g.ok(typeof n==`object`&&!!n,`Test suggestion in 'suggestions' array must be an object.`),Object.keys(n).forEach(e=>{g.ok(F.has(e),`Invalid suggestion property name '${e}'. Expected one of ${ce}.`)});let a=l.suggestions[r],o=`Error Suggestion at index ${r}:`;if(L(n,`desc`))g.ok(!L(n,`data`),`${o} Test should not specify both 'desc' and 'data'.`),g.ok(!L(n,`messageId`),`${o} Test should not specify both 'desc' and 'messageId'.`),g.strictEqual(a.desc,n.desc,`${o} desc should be "${n.desc}" but got "${a.desc}" instead.`);else if(L(n,`messageId`)){g.ok(c,`${o} Test can not use 'messageId' if rule under test doesn't define 'meta.messages'.`),g.ok(L(t.meta.messages,n.messageId),`${o} Test has invalid messageId '${n.messageId}', the rule under test allows only one of ${d}.`),g.strictEqual(a.messageId,n.messageId,`${o} messageId should be '${n.messageId}' but got '${a.messageId}' instead.`);let e=t.meta.messages[n.messageId],r=W(a.desc,e,n.data);if(g.ok(r.length===0,`The message of the suggestion has ${r.length>1?`unsubstituted placeholders: ${r.map(e=>`'${e}'`).join(`, `)}`:`an unsubstituted placeholder '${r[0]}'`}. Please provide the missing ${r.length>1?`values`:`value`} via the 'data' property for the suggestion in the context.report() call.`),L(n,`data`)){let e=t.meta.messages[n.messageId],r=E(e,n.data);g.strictEqual(a.desc,r,`${o} Hydrated test desc "${r}" does not match received desc "${a.desc}".`)}else{let t=s===!0||s===`suggestion`,n=U(e).length>0;g.ok(!t||!n,`${o} Suggestion should specify the 'data' property as the referenced message has placeholders.`)}}else L(n,`data`)?g.fail(`${o} Test must specify 'messageId' if 'data' is used.`):g.fail(`${o} Test must specify either 'messageId' or 'desc'.`);g.ok(L(n,`output`),`${o} The "output" property is required.`);let u=T.applyFixes(e.code,[a]).output,f=i.verify(u,p.configs,p.filename).find(e=>e.fatal);g(!f,[`A fatal parsing error occurred in suggestion fix.`,`Error: ${f&&f.message}`,`Suggestion output:`,u].join(`
5
+ `)),g.strictEqual(u,n.output,`Expected the applied suggestion fix to match the test suggestion output for suggestion at index: ${r} on error with message: "${l.message}"`),g.notStrictEqual(n.output,e.code,`The output of a suggestion should differ from the original source code for suggestion at index: ${r} on error with message: "${l.message}"`)})):g.fail(`Test error object property 'suggestions' should be an array or a number`))}}}catch(e){throw e instanceof Error&&(e.errorIndex=r),e}}L(e,`output`)?e.output===null?g.strictEqual(p.output,e.code,`Expected no autofixes to be suggested`):(g.strictEqual(p.output,e.output,`Output is incorrect.`),g.notStrictEqual(e.code,e.output,`Test property 'output' matches 'code'. If no autofix is expected, then omit the 'output' property or set it to null.`)):g.strictEqual(p.output,e.code,`The rule fixed the code. Please add 'output' property.`),u(p.beforeAST,p.afterAST)}this.constructor.describe(e,()=>{n.valid.length>0&&this.constructor.describe(`valid`,()=>{let e=/* @__PURE__ */ new Set;n.valid.forEach((t,n)=>{let r=K(t);this.constructor[t.only?`itOnly`:`it`](B(r.name||r.code),()=>{try{c(r,`before`),_e(r,e),d(r)}catch(e){throw e instanceof Error&&(e.scenarioType=`valid`,e.scenarioIndex=n,e.stack=e.stack.replace(/^ +at /mu,[` roughly at RuleTester.run.valid[${n}] (${o(`valid[${n}]`)})`,` roughly at RuleTester.run.valid (${o(`valid`)})`,` at RuleTester.run (${o(`root`)})`,` at `].join(`
6
+ `))),e}finally{c(r,`after`)}})})}),n.invalid.length>0&&this.constructor.describe(`invalid`,()=>{let t=/* @__PURE__ */ new Set;n.invalid.forEach((r,i)=>{let a=K(r);this.constructor[a.only?`itOnly`:`it`](B(a.name||a.code),()=>{try{c(a,`before`),ve(a,t,e,n.assertionOptions),p(a)}catch(e){if(e instanceof Error){e.scenarioType=`invalid`,e.scenarioIndex=i;let t=e.errorIndex;e.stack=e.stack.replace(/^ +at /mu,[...typeof t==`number`?[` roughly at RuleTester.run.invalid[${i}].error[${t}] (${o(`invalid[${i}].errors[${t}]`)})`]:[],` roughly at RuleTester.run.invalid[${i}] (${o(`invalid[${i}]`)})`,` roughly at RuleTester.run.invalid (${o(`invalid`)})`,` at RuleTester.run (${o(`root`)})`,` at `].join(`
7
+ `))}throw e}finally{c(a,`after`)}})})})})}};$[X]=$[Z]=$[Q]=null,p.exports=$})),_=/* @__PURE__ */ t(((e,t)=>{t.exports={RuleTester:g()}})),v=(/* @__PURE__ */ t(((e,t)=>{let{ESLint:n}=p(),{Linter:r}=d(),{RuleTester:i}=_(),{SourceCode:a}=o();async function s(){return n}t.exports={Linter:r,loadESLint:s,ESLint:n,RuleTester:i,SourceCode:a}})))(),y=v.ESLint,b=v.Linter,x=v.RuleTester,S=v.SourceCode,C=v.loadESLint;export{y as ESLint,b as Linter,x as RuleTester,S as SourceCode,C as loadESLint};