Skip to content

fix(eslint-factory): exempt console.error/console.warn from prefer-core-logging - #46552

Merged
pelikhan merged 2 commits into
mainfrom
copilot/eslint-factory-fix-logging-issue
Jul 19, 2026
Merged

fix(eslint-factory): exempt console.error/console.warn from prefer-core-logging#46552
pelikhan merged 2 commits into
mainfrom
copilot/eslint-factory-fix-logging-issue

Conversation

Copilot AI commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

prefer-core-logging was offering an autofix rewriting console.error/console.warncore.error/core.warning. These two families use different streams: console.error/console.warn write to stderr; core.* methods emit GitHub Actions workflow commands to stdout. For stdio MCP servers that own stdout as a JSON-RPC channel, the substitution silently corrupts the stream.

Changes

  • prefer-core-logging.ts — Drop error and warn from CONSOLE_TO_CORE. The rule no longer reports or suggests replacements for those two methods. console.log, console.info, and console.debugcore.* behavior is unchanged.

  • prefer-core-logging.test.ts — Convert the two console.error/console.warn invalid cases into valid cases that document the stderr exemption. Adds explicit MCP-server-like fixtures (e.g. console.error("MCP transport error:", ...)) to pin the intent.

  • README.md — Add prefer-core-logging rule entry and section. Includes a covered-methods table and an explicit callout explaining why console.error/console.warn are excluded:

    console.error/console.warn write to process.stderr; core.error/core.warning emit workflow commands to process.stdout. For processes that own stdout as a data/protocol channel the substitution is not behavior-preserving.

…re-logging rule

console.error and console.warn write to process.stderr, while core.error
and core.warning emit workflow commands to process.stdout. For stdio MCP
servers that own stdout as a JSON-RPC channel, the substitution is not
behavior-preserving and would corrupt the stream.

- Remove `error` and `warn` from CONSOLE_TO_CORE map so they are never flagged
- Update tests: console.error/console.warn now have valid tests documenting the exemption
- Add prefer-core-logging README section with stream-semantics rationale

Closes #46541

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix logging stream issue in prefer-core-logging fix(eslint-factory): exempt console.error/console.warn from prefer-core-logging Jul 19, 2026
Copilot AI requested a review from pelikhan July 19, 2026 07:18
@pelikhan
pelikhan marked this pull request as ready for review July 19, 2026 07:21
Copilot AI review requested due to automatic review settings July 19, 2026 07:21
@github-actions

github-actions Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Design Decision Gate 🏗️ completed the design decision gate check.

No ADR enforcement needed: PR #46552 does not have the 'implementation' label and has 0 new lines of code in business logic directories (threshold: 100).

@github-actions

github-actions Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

PR Code Quality Reviewer completed the code quality review.

@github-actions

github-actions Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

@github-actions

github-actions Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Test Quality Sentinel completed test quality analysis.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Exempts stderr-based console methods from unsafe stdout rewrites.

Changes:

  • Removes console.error/console.warn mappings.
  • Adds exemption tests and stream-semantics documentation.
  • Preserves other console-to-core mappings.
Show a summary per file
File Description
eslint-factory/src/rules/prefer-core-logging.ts Removes unsafe stderr rewrites.
eslint-factory/src/rules/prefer-core-logging.test.ts Tests error/warn exemptions.
eslint-factory/README.md Documents covered methods and rationale.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 3/3 changed files
  • Comments generated: 2
  • Review effort level: Medium

Comment on lines +6 to +11
// NOTE: console.error and console.warn are intentionally excluded.
// Those methods write to process.stderr, while core.error / core.warning emit
// GitHub Actions workflow commands to process.stdout. For processes that own
// stdout as a data/protocol channel (e.g. stdio MCP servers), rewriting
// stderr logging to stdout would corrupt the stream. The substitution is not
// behavior-preserving and must not be auto-applied.
Comment on lines +112 to +115
`console.warn("warning");`,
`const core = require("@actions/core"); console.warn("warning");`,
],
invalid: [],

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Skills-Based Review 🧠

Applied /diagnosing-bugs — root cause properly addressed with good regression coverage.

📋 Key Themes & Highlights

Key Themes

  • Bug fix is correct: Removing warn and error from CONSOLE_TO_CORE is the right, minimal change. The root cause (wrong stream semantics) is addressed, not just the symptom.
  • Tests are solid: Invalid cases converted to valid ones with clear explanatory comments. The MCP-server fixture (console.error("MCP transport error:", ...)) pins the intent nicely.
  • Documentation is thorough: README callout clearly explains the stderr vs stdout distinction.

Positive Highlights

  • ✅ Minimal, surgical change — existing log/info/debug behavior is entirely untouched
  • ✅ Code comments in both the rule and tests explain why the exemption exists
  • ✅ README covers both the coverage table and the explicit exclusion rationale

One minor suggestion (non-blocking): the console.warn valid block has 2 fixtures, while console.error has 3 (including a multi-arg MCP-server-like case). Adding a parallel multi-arg fixture for console.warn would make the symmetry explicit, but this is purely cosmetic.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · 15 AIC · ⌖ 4.42 AIC · ⊞ 6.7K
Comment /matt to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review: prefer-core-logging exemption for console.error/console.warn

The rationale is sound — stdout/stderr stream semantics differ, and rewriting console.error/console.warn to core.error/core.warning would corrupt stdio-protocol channels such as MCP servers. The implementation, tests, and docs are consistent.

Two existing inline comments (already filed) cover the remaining gaps:

  • Stale meta.docs.description still mentions core.error and core.warning (line 11)
  • Missing console.info invalid test — the suite doesn't verify console.info → core.info still fires (line 115)

No additional blocking issues found.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · 13.9 AIC · ⌖ 8.12 AIC · ⊞ 5K

@github-actions github-actions Bot mentioned this pull request Jul 19, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good

The exemption of console.error/console.warn from prefer-core-logging is correct and well-justified. The stderr-vs-stdout stream semantics rationale is sound (especially relevant for stdio MCP servers). Implementation is minimal and precise: dropping the two entries from CONSOLE_TO_CORE is the right approach since rule detection is gated on that map. Tests and README are accurate.

🔎 Code quality review by PR Code Quality Reviewer · 21 AIC · ⌖ 4.33 AIC · ⊞ 5.6K
Comment /review to run again

@github-actions

Copy link
Copy Markdown
Contributor

🧪 Test Quality Sentinel Report

⚠️ Test Quality Score: 77/100 — Acceptable

Analyzed 11 test(s): 9 design, 2 implementation, 0 violation(s).

📊 Metrics (11 tests)
Metric Value
Analyzed 11 (Go: 0, JS: 11)
✅ Design 9 (82%)
⚠️ Implementation 2 (18%)
Edge/error coverage 9 (82%)
Duplicate clusters 0
Inflation Marginal (16 test lines added / 7 prod lines added ≈ 2.3:1, but net test lines decreased)
🚨 Violations 0
Test File Classification Issues
uses the correct docs URL prefer-core-logging.test.ts implementation_test low_value: meta-property assertion
hasSuggestions enabled prefer-core-logging.test.ts implementation_test low_value: meta-property assertion
invalid: plain console.log prefer-core-logging.test.ts design_test none
valid: core.info calls are fine prefer-core-logging.test.ts design_test none
invalid: console.log in function prefer-core-logging.test.ts design_test none
invalid: console.log when core in scope prefer-core-logging.test.ts design_test none
NEW valid: console.error is not flagged prefer-core-logging.test.ts design_test none
NEW valid: console.warn is not flagged prefer-core-logging.test.ts design_test none
invalid: console.debug when core in scope prefer-core-logging.test.ts design_test none
invalid: console.log with function param prefer-core-logging.test.ts design_test none
invalid: console.log multi-arg prefer-core-logging.test.ts design_test none
⚠️ Flagged Tests (2)

uses the correct docs URL (prefer-core-logging.test.ts:13) — implementation_test, low_value. Asserts the metadata URL string, an internal implementation detail rather than a behavioral contract. Only catches doc URL typos, not rule logic regressions.

hasSuggestions enabled (prefer-core-logging.test.ts:17) — implementation_test, low_value. Checks a meta-property flag rather than verifying suggestions actually work. Behavioral coverage for suggestions is provided by the suggestions: arrays in the invalid test cases.

Verdict

Passed. 18% implementation tests (threshold: 30%). The two new tests (console.error and console.warn exemptions) correctly encode the behavioral contract that stderr-bound console methods must not be replaced with stdout-bound core.* equivalents — protecting stdio-protocol channels such as MCP servers. Strong behavioral coverage overall.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • awmgmcpg

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

🧪 Test quality analysis by Test Quality Sentinel · 33.1 AIC · ⌖ 9.81 AIC · ⊞ 7K ·
Comment /review to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Test Quality Sentinel: 77/100. 18% implementation tests (threshold: 30%).

@pelikhan
pelikhan merged commit 9f48166 into main Jul 19, 2026
37 checks passed
@pelikhan
pelikhan deleted the copilot/eslint-factory-fix-logging-issue branch July 19, 2026 07:38
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.82.14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants