Skip to content

[Code Quality] Fix prefer-core-logging: corrupts MCP stdio channel and drops multi-arg content #46643

Description

@github-actions

Description

The prefer-core-logging ESLint rule rewrites console.error/console.warn (which write to stderr) to core.error/core.warning (which write ::error:: commands to stdout). In stdio MCP servers and transports that use stdout for JSON-RPC, this rewrite corrupts the protocol channel.

Additionally, the autofix joins multi-argument console.error(msg, err) calls into a single string, silently dropping trailing arguments.

Suggested Changes

  • Add a file-pattern exclusion (or AST heuristic) to skip rewrites in stdio MCP server and transport files
  • Fix multi-argument autofix to properly interpolate arguments rather than silently drop them
  • Update tests to cover the lossy multi-arg case (currently test at line 180 canonizes the loss)

Files Affected

  • actions/setup/js/eslint-factory/rules/prefer-core-logging.ts (rule + autofix)
  • actions/setup/js/eslint-factory/rules/prefer-core-logging.test.ts (line 180 — lossy test)
  • Affected production sites: safe_outputs_mcp_server.cjs:101, mcp_scripts_mcp_server.cjs:87,105, mcp_http_transport.cjs:295

Success Criteria

  • MCP stdio servers are excluded from the rewrite (stdout integrity preserved)
  • Multi-argument calls produce non-lossy output after autofix
  • Tests cover both cases

Source

Extracted from ESLint Refiner Report #46543

Priority

High — Current rule corrupts MCP stdio channel and silently drops error context

🔍 Task mining by Discussion Task Miner - Code Quality Improvement Agent · 40.8 AIC · ⌖ 6.1 AIC · ⊞ 7K ·

  • expires on Jul 20, 2026, 11:13 AM UTC-08:00

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions