Skip to content

fix: lint --format markdown renders report instead of [object Object]#95

Merged
davideast merged 1 commit into
mainfrom
fix/lint-markdown-object-object
Jun 2, 2026
Merged

fix: lint --format markdown renders report instead of [object Object]#95
davideast merged 1 commit into
mainfrom
fix/lint-markdown-object-object

Conversation

@davideast
Copy link
Copy Markdown
Collaborator

@davideast davideast commented Jun 2, 2026

Summary

lint --format markdown emits a literal # [object Object] instead of a readable report. This was originally reported in PR #56, which was closed due to CLA. Thank you to @johansabent for raising it originally.

Before:

$ design.md lint DESIGN.md --format markdown
# [object Object]

After:

$ design.md lint DESIGN.md --format markdown
# Lint Report

**0 errors**, **4 warnings**, **1 infos**

## Findings

- **warning** `components.glass-card-standard`: textColor (#ffffff) on backgroundColor (#ffffff1a) has contrast ratio 1.00:1, below WCAG AA minimum of 4.5:1.
- **info**: Design system defines 47 colors, 6 typography scales, 6 rounding levels, 5 spacing tokens, 10 components.

Root cause

formatAsMarkdown in utils.ts template-literaled obj.summary directly on line 59: \# ${obj.summary}`. This works when summary is a string (the legacy fixer shape) but the lint command returns { errors: number, warnings: number, infos: number }, which coerces to [object Object]`.

Fix

  • Detect the lint output shape (findings array + numeric summary object) and route to a dedicated formatLintAsMarkdown renderer
  • Gate the legacy obj.summary branch on typeof obj.summary === 'string' so fixer/diff shapes still work
  • Render a proper markdown report: heading, severity counts, and a bulleted findings list with optional code-formatted paths

Tests

New utils.test.ts with 6 tests:

  • Lint-shape input does not contain [object Object] and produces a headed report (regression test)
  • Findings with and without a path render correctly
  • Empty findings omit the Findings section
  • --format md alias works
  • Legacy fixer shape with string summary still renders correctly
  • Default format still returns valid JSON

All 244 tests pass.

formatAsMarkdown template-literaled obj.summary directly, which coerced
the lint summary object { errors, warnings, infos } to its toString
representation '[object Object]'.

Detect the lint output shape (findings array + numeric summary) and
render a proper markdown report with severity counts and a bulleted
findings list. The legacy string-summary path for fixer/diff shapes
is preserved.

Adds 6 tests covering the regression, findings with and without paths,
empty findings, the --format md alias, and the legacy fixer shape.

Fixes the bug originally reported in PR #56.
@davideast davideast merged commit 2bcb6c6 into main Jun 2, 2026
13 checks passed
@davideast davideast deleted the fix/lint-markdown-object-object branch June 2, 2026 04:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant