diff --git a/lib/generator.ts b/lib/generator.ts index 46b915a2..a4cff58a 100644 --- a/lib/generator.ts +++ b/lib/generator.ts @@ -209,7 +209,7 @@ export async function generate(path: string, options?: GenerateOptions) { for (const section of ruleDocSectionInclude) { expectSectionHeaderOrFail( `\`${name}\` rule doc`, - contents, + contentsNew, [section], true ); @@ -219,7 +219,7 @@ export async function generate(path: string, options?: GenerateOptions) { for (const section of ruleDocSectionExclude) { expectSectionHeaderOrFail( `\`${name}\` rule doc`, - contents, + contentsNew, [section], false ); @@ -229,7 +229,7 @@ export async function generate(path: string, options?: GenerateOptions) { // Options section. expectSectionHeaderOrFail( `\`${name}\` rule doc`, - contents, + contentsNew, ['Options', 'Config'], hasOptions(schema) ); @@ -237,7 +237,7 @@ export async function generate(path: string, options?: GenerateOptions) { expectContentOrFail( `\`${name}\` rule doc`, 'rule option', - contents, + contentsNew, namedOption, true ); // Each rule option is mentioned. diff --git a/test/lib/generate/__snapshots__/rule-options-list-test.ts.snap b/test/lib/generate/__snapshots__/rule-options-list-test.ts.snap index 67b872aa..4cb62c09 100644 --- a/test/lib/generate/__snapshots__/rule-options-list-test.ts.snap +++ b/test/lib/generate/__snapshots__/rule-options-list-test.ts.snap @@ -43,7 +43,7 @@ exports[`generate (rule options list) with no options generates the documentatio "# test/no-foo -## Options + diff --git a/test/lib/generate/rule-options-list-test.ts b/test/lib/generate/rule-options-list-test.ts index 5ef92b46..8c490381 100644 --- a/test/lib/generate/rule-options-list-test.ts +++ b/test/lib/generate/rule-options-list-test.ts @@ -4,6 +4,7 @@ import { dirname, resolve } from 'node:path'; import { fileURLToPath } from 'node:url'; import { readFileSync } from 'node:fs'; import { jest } from '@jest/globals'; +import * as sinon from 'sinon'; const __dirname = dirname(fileURLToPath(import.meta.url)); @@ -74,7 +75,10 @@ describe('generate (rule options list)', function () { }); it('generates the documentation', async function () { + const consoleErrorStub = sinon.stub(console, 'error'); await generate('.'); + expect(consoleErrorStub.callCount).toBe(0); + consoleErrorStub.restore(); expect(readFileSync('docs/rules/no-foo.md', 'utf8')).toMatchSnapshot(); }); }); @@ -126,7 +130,10 @@ describe('generate (rule options list)', function () { }); it('generates the documentation', async function () { + const consoleErrorStub = sinon.stub(console, 'error'); await generate('.'); + expect(consoleErrorStub.callCount).toBe(0); + consoleErrorStub.restore(); expect(readFileSync('docs/rules/no-foo.md', 'utf8')).toMatchSnapshot(); }); }); @@ -155,7 +162,7 @@ describe('generate (rule options list)', function () { 'README.md': '## Rules\n', - 'docs/rules/no-foo.md': `## Options + 'docs/rules/no-foo.md': ` `, @@ -170,7 +177,10 @@ describe('generate (rule options list)', function () { }); it('generates the documentation', async function () { + const consoleErrorStub = sinon.stub(console, 'error'); await generate('.'); + expect(consoleErrorStub.callCount).toBe(0); + consoleErrorStub.restore(); expect(readFileSync('docs/rules/no-foo.md', 'utf8')).toMatchSnapshot(); }); }); @@ -211,7 +221,10 @@ describe('generate (rule options list)', function () { }); it('generates the documentation', async function () { + const consoleErrorStub = sinon.stub(console, 'error'); await generate('.'); + expect(consoleErrorStub.callCount).toBe(0); + consoleErrorStub.restore(); expect(readFileSync('docs/rules/no-foo.md', 'utf8')).toMatchSnapshot(); }); }); @@ -255,7 +268,10 @@ describe('generate (rule options list)', function () { }); it('generates the documentation', async function () { + const consoleErrorStub = sinon.stub(console, 'error'); await generate('.'); + expect(consoleErrorStub.callCount).toBe(0); + consoleErrorStub.restore(); expect(readFileSync('docs/rules/no-foo.md', 'utf8')).toMatchSnapshot(); }); });