Skip to content

build(settings): add JSON output formatter for markdownlint-cli2#1382

Merged
bindsi merged 6 commits intomicrosoft:mainfrom
MukundaKatta:codex/markdownlint-json-formatter
Apr 23, 2026
Merged

build(settings): add JSON output formatter for markdownlint-cli2#1382
bindsi merged 6 commits intomicrosoft:mainfrom
MukundaKatta:codex/markdownlint-json-formatter

Conversation

@MukundaKatta
Copy link
Copy Markdown
Contributor

@MukundaKatta MukundaKatta commented Apr 19, 2026

Pull Request

Description

npm run lint:md previously produced only console output, so markdown lint results were lost after the terminal session ended. This PR wires up markdownlint-cli2's official JSON formatter so runs also emit logs/markdownlint-results.json, matching the structured log pattern already used by other linters in this repo.

Changes included in this PR:

  • package.json and package-lock.json: add [email protected] as a dev dependency.
  • .markdownlint-cli2.jsonc: configure outputFormatters to write logs/markdownlint-results.json.

No script changes are required because markdownlint-cli2 loads configured formatters automatically, and logs/ is already ignored by git.

Related Issue(s)

Closes #990.

Type of Change

Select all that apply:

Code & Documentation:

  • Bug fix (non-breaking change fixing an issue)
  • New feature (non-breaking change adding functionality)
  • Breaking change (fix or feature causing existing functionality to change)
  • Documentation update

Infrastructure & Configuration:

  • GitHub Actions workflow
  • Linting configuration (markdown, PowerShell, etc.)
  • Security configuration
  • DevContainer configuration
  • Dependency update

AI Artifacts:

  • Reviewed contribution with prompt-builder agent and addressed all feedback
  • Copilot instructions (.github/instructions/*.instructions.md)
  • Copilot prompt (.github/prompts/*.prompt.md)
  • Copilot agent (.github/agents/*.agent.md)
  • Copilot skill (.github/skills/*/SKILL.md)

Note for AI Artifact Contributors:

  • Agents: Research, indexing/referencing other project (using standard VS Code GitHub Copilot/MCP tools), planning, and general implementation agents likely already exist. Review .github/agents/ before creating new ones.
  • Skills: Must include both bash and PowerShell scripts. See Skills.
  • Model Versions: Only contributions targeting the latest Anthropic and OpenAI models will be accepted. Older model versions (e.g., GPT-3.5, Claude 3) will be rejected.
  • See Agents Not Accepted and Model Version Requirements.

Other:

  • Script/automation (.ps1, .sh, .py)
  • Other (please describe):

Testing

  • mkdir -p logs && npm run lint:md
  • Verified that logs/markdownlint-results.json is created.
  • Verified that the output file is [] on a clean tree and that the formatter schema matches the documented fields when violations exist.

Checklist

Required Checks

  • Documentation is updated (if applicable)
  • Files follow existing naming conventions
  • Changes are backwards compatible (if applicable)
  • Tests added for new functionality (if applicable)

AI Artifact Contributions

  • Used /prompt-analyze to review contribution
  • Addressed all feedback from prompt-builder review
  • Verified contribution follows common standards and type-specific requirements

Required Automated Checks

The following validation commands must pass before merging:

  • Markdown linting: npm run lint:md
  • Spell checking: npm run spell-check
  • Frontmatter validation: npm run lint:frontmatter
  • Skill structure validation: npm run validate:skills
  • Link validation: npm run lint:md-links
  • PowerShell analysis: npm run lint:ps
  • Plugin freshness: npm run plugin:generate
  • Docusaurus tests: npm run docs:test

Security Considerations

  • This PR does not contain any sensitive or NDA information
  • Any new dependencies have been reviewed for security issues
  • Security-related scripts follow the principle of least privilege

Additional Notes

  • This PR keeps the original issue context from Add JSON output formatter for markdownlint-cli2 #990 and the previous verification details, but reformats them into the repo's PR template.
  • The targeted verification above was run locally; the full repository-wide automated checklist has not been re-run as part of this description update.

npm run lint:md previously produced only console output, so results
were lost as soon as the terminal closed. markdownlint-cli2 supports
outputFormatters; add the official markdownlint-cli2-formatter-json
package and wire it up in .markdownlint-cli2.jsonc so a
logs/markdownlint-results.json file is produced on every run (the
logs/ directory is already gitignored).

Manual verification: npm run lint:md now writes
logs/markdownlint-results.json (0 entries when clean, full violation
array with fileName/lineNumber/ruleNames/errorDetail when not).

Closes microsoft#990.
@WilliamBerryiii WilliamBerryiii changed the title lint(md): add JSON output formatter for markdownlint-cli2 build(settings): add JSON output formatter for markdownlint-cli2 Apr 23, 2026
Copy link
Copy Markdown
Member

@WilliamBerryiii WilliamBerryiii left a comment

Choose a reason for hiding this comment

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

LGTM with one suggested change.

Concern: Specifying outputFormatters replaces the default stderr listing rather than adding to it (per markdownlint-cli2 docs). After this change, npm run lint:md will stop printing human-readable violations to the console — devs and CI logs will only see the banner and have to open logs/markdownlint-results.json to find failures.

Suggested fix — include both formatters so console output is preserved alongside the new JSON file:

"outputFormatters": [
  ["markdownlint-cli2-formatter-default"],
  ["markdownlint-cli2-formatter-json", { "name": "logs/markdownlint-results.json" }]
]

markdownlint-cli2-formatter-default is already pulled in transitively; if referenced explicitly in config it should also be added to dependencies in package.json.

Other notes (non-blocking):

  • Nice catch on the missing EOF newline in package.json.
  • logs/ is already gitignored, so the output file won't be committed. ✅
  • Worth adding a sentence to the PR description on the use case (e.g., enabling structured parsing referenced in copilot-instructions.md).

Copy link
Copy Markdown
Member

@WilliamBerryiii WilliamBerryiii left a comment

Choose a reason for hiding this comment

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

LGTM with one suggested change.

Concern: Specifying outputFormatters replaces the default stderr listing rather than adding to it (per markdownlint-cli2 docs). After this change, npm run lint:md will stop printing human-readable violations to the console — devs and CI logs will only see the banner and have to open logs/markdownlint-results.json to find failures.

Suggested fix — include both formatters so console output is preserved alongside the new JSON file:

"outputFormatters": [
  ["markdownlint-cli2-formatter-default"],
  ["markdownlint-cli2-formatter-json", { "name": "logs/markdownlint-results.json" }]
]

markdownlint-cli2-formatter-default is already pulled in transitively; if referenced explicitly in config it should also be added to dependencies in package.json.

Other notes (non-blocking):

  • Nice catch on the missing EOF newline in package.json.
  • logs/ is already gitignored, so the output file won't be committed. ✅
  • Worth adding a sentence to the PR description on the use case (e.g., enabling structured parsing referenced in copilot-instructions.md).

Include markdownlint-cli2-formatter-default alongside the JSON formatter
so
> [email protected] lint:md
> markdownlint-cli2 "**/*.md"

markdownlint-cli2 v0.22.0 (markdownlint v0.40.0)
Finding: **/*.md !**/node_modules/** !**/packages/** !.copilot-tracking/** !logs/** !venv/** !scripts/tests/Fixtures/** !extension/README.md !extension/README.*.md !extension/CHANGELOG.md !collections/*.collection.md !plugins/**/agents/** !plugins/**/instructions/** !plugins/**/commands/** !plugins/**/skills/** !plugins/**/docs/** !plugins/**/scripts/** !.github/instructions/** !.github/aw/logs/** !.github/agents/** !.github/prompts/** !.github/skills/**
Linting: 197 file(s)
Summary: 0 error(s) keeps emitting human-readable violations to stderr
while also writing logs/markdownlint-results.json. Pin the default
formatter as a direct devDependency since it is now referenced
explicitly in config.
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.91%. Comparing base (6324a69) to head (9fe4479).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1382      +/-   ##
==========================================
- Coverage   87.92%   87.91%   -0.02%     
==========================================
  Files          62       62              
  Lines        9593     9593              
==========================================
- Hits         8435     8434       -1     
- Misses       1158     1159       +1     
Flag Coverage Δ
pester 85.22% <ø> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@katriendg
Copy link
Copy Markdown
Contributor

@MukundaKatta we have done the additional changes as we wanted to merge, thanks for your contribution! No actions required from you.
@WilliamBerryiii I also added logs folder creation to some of the workflows - FYI.

@bindsi bindsi merged commit a5c3837 into microsoft:main Apr 23, 2026
57 checks passed
@github-actions github-actions Bot mentioned this pull request Apr 23, 2026
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.

Add JSON output formatter for markdownlint-cli2

5 participants