Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion javascript/packages/linter/src/cli/summary-reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ export class SummaryReporter {
for (const ruleName of ruleNames) {
const ruleText = colorize(ruleName, "white")
const ruleLink = hyperlink(ruleText, ruleDocumentationUrl(ruleName))
console.log(` ${ruleLink} ${colorize(`(introduced in ${versionLabel})`, "gray")}`)
console.log(` ${ruleLink}${colorize(` (introduced in ${versionLabel})`, "gray")}`)
}
}

Expand Down
44 changes: 44 additions & 0 deletions javascript/packages/linter/test/summary-reporter.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { afterEach, describe, expect, test, vi } from "vitest"

import { SummaryReporter } from "../src/cli/summary-reporter.js"

import type { SummaryData } from "../src/cli/summary-reporter.js"

describe("SummaryReporter", () => {
afterEach(() => {
vi.restoreAllMocks()
})

test("keeps the space before a version label inside its color sequence", () => {

@marcoroth marcoroth Aug 5, 2026

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joeeei11 would you mind moving this to the existing cli.test.ts and using toMatchSnapshot on the output.

const originalNoColor = process.env.NO_COLOR
delete process.env.NO_COLOR

const log = vi.spyOn(console, "log").mockImplementation(() => {})

try {
new SummaryReporter().displayVersionSkippedRules({
rulesSkippedByVersion: [
{ ruleName: "html-example", introducedIn: "0.10.3" },
],
configVersion: "0.10.3",
hasConfigFile: true,
} as SummaryData)

const ruleLine = log.mock.calls
.map(([line]) => line)
.find(
(line) => typeof line === "string" && line.includes("html-example"),
)

expect(ruleLine).toMatch(
/\x1b\\\x1b\[[0-9;]+m \(introduced in 0\.10\.3\)/,
)
} finally {
if (originalNoColor === undefined) {
delete process.env.NO_COLOR
} else {
process.env.NO_COLOR = originalNoColor
}
}
})
})
Loading