Skip to content

Fix ESLint debug output log level - #2212

Open
Pradeep Ramola (pradeep-ramola) wants to merge 9 commits into
microsoft:mainfrom
pradeep-ramola:fix/GH-2060-debug-log-level
Open

Fix ESLint debug output log level#2212
Pradeep Ramola (pradeep-ramola) wants to merge 9 commits into
microsoft:mainfrom
pradeep-ramola:fix/GH-2060-debug-log-level

Conversation

@pradeep-ramola

@pradeep-ramola Pradeep Ramola (pradeep-ramola) commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Fixes #2060

Summary

Uses the stdioOptions API from vscode-languageclient@10.1.1 to handle ESLint server stdout/stderr formatting without patching VS Code's LogOutputChannel object.

ESLint debug namespace messages from stderr (eslint: / eslintrc:) are sanitized and written as info, while non-debug stderr lines continue to use error. Stdout lines are sanitized and written as info.

This keeps the fix on the client side, follows the new LSP client API, and avoids mutating VS Code API objects.

Validation

Passed locally:

npm run lint --prefix client
npm run lint --prefix server
npx tsc --ignoreConfig --noEmit --target ES2022 --module Node16 --moduleResolution Node16 --types node --skipLibCheck --strict client/src/logOutput.ts client/src/tests/logOutput.test.ts

Also compiled client/src/logOutput.ts and client/src/tests/logOutput.test.ts to a temp directory and ran the emitted test with node --test; all 4 log-output tests passed.

@dbaeumer

Copy link
Copy Markdown
Member

Although this is working the server side is not the right place to fix this. Major reason is that the server doesn't know anything about the formatting of the output channel and different clients might handle things differently. A better solution is to do this on the client side by overriding the error, warn, log and info method and string any date format from the start of the message.

@dbaeumer Dirk Bäumer (dbaeumer) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

See latest comment in PR.

@pradeep-ramola

Copy link
Copy Markdown
Contributor Author

Updated as requested. I removed the server-side stderr bridge and moved the fix to the client output channel.

What changed:

  • Added a client-side LogOutputChannel sanitizer.
  • Strips leading date prefixes and ANSI escape sequences from error, warn, info, and optional log messages.
  • Routes eslint: / eslintrc: debug messages that arrive through error to info.
  • Leaves non-debug stderr/server errors on error.
  • Added client-side unit tests for the sanitizer and debug-message rerouting.

Validated with:

  • npm run lint --prefix client
  • npm run lint --prefix server
  • Focused TypeScript check for client/src/logOutput.ts and client/src/tests/logOutput.test.ts
  • Compiled and ran the emitted log-output test with node --test

@dbaeumer

Copy link
Copy Markdown
Member

We should first fix microsoft/vscode-languageserver-node#1838 and then use the new API to provide a nice implementation for ESLint.

In general I am not a big fan of batching methods on VS Code API object. If they freeze these object or do some other tricks this will fail in the future.

@pradeep-ramola
Pradeep Ramola (pradeep-ramola) marked this pull request as draft August 25, 2026 09:26
@pradeep-ramola

Pradeep Ramola (pradeep-ramola) commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

Thanks, agreed. I converted this PR to draft while the upstream API work lands.

Once microsoft/vscode-languageserver-node#1838 / microsoft/vscode-languageserver-node#1839 is merged and a vscode-languageclient version exposes stdioOptions, I’ll update this PR to use that API for ESLint stderr handling instead of patching the VS Code output channel object.

@dbaeumer

Copy link
Copy Markdown
Member

The LSP libs are updated and #2228 will make them available here.

@pradeep-ramola
Pradeep Ramola (pradeep-ramola) marked this pull request as ready for review September 2, 2026 19:31
@pradeep-ramola

Copy link
Copy Markdown
Contributor Author

Updated now that #2228 has landed.

This PR now uses stdioOptions from vscode-languageclient@10.1.1 instead of patching LogOutputChannel methods. The stderr handler sanitizes ESLint debug output and routes eslint: / eslintrc: namespace messages to info, while preserving error for other stderr lines. Stdout is sanitized and written to info.

Validated with:

  • npm run lint --prefix client
  • npm run lint --prefix server
  • focused TypeScript check for client/src/logOutput.ts and client/src/tests/logOutput.test.ts
  • emitted node --test run for logOutput.test.ts

@pradeep-ramola

Copy link
Copy Markdown
Contributor Author

Follow-up: the first Azure rerun caught an unused type import from the refactor. I removed it in 3a9e67b, and the new Azure run is green for both Linux and Windows.

@dbaeumer

Copy link
Copy Markdown
Member

/AzurePipelines run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command.

@dbaeumer

Copy link
Copy Markdown
Member

/AzurePipelines run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The change is client-scoped, aligns with the stated intent (fixing debug output log levels), and includes targeted tests validating the new routing/sanitization behavior.

Pull request overview

This PR fixes incorrect log-level tagging for ESLint --debug output in the VS Code ESLint extension by using vscode-languageclient’s stdioOptions hooks to sanitize and re-route server stdout/stderr lines, avoiding any mutation/patching of VS Code’s LogOutputChannel.

Changes:

  • Add client-side stdout/stderr line processing to strip leading timestamps and ANSI sequences, and route ESLint debug namespaces (eslint: / eslintrc:) from stderr to info.
  • Wire the new stdioOptions behavior into the LanguageClientOptions used to start the ESLint server.
  • Add focused unit tests (Node’s node:test) validating sanitization and stdout/stderr routing.
File summaries
File Description
client/src/client.ts Passes stdioOptions into LanguageClientOptions to control how server stdout/stderr is logged.
client/src/logOutput.ts Implements sanitization and routing logic for ESLint server stdout/stderr lines.
client/src/tests/logOutput.test.ts Adds unit tests covering sanitization and log-level routing behavior.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread client/src/logOutput.ts Outdated
Comment thread client/src/tests/logOutput.test.ts Outdated
@dbaeumer

Copy link
Copy Markdown
Member

Pradeep Ramola (@pradeep-ramola) see the Copilot comments.

@pradeep-ramola

Copy link
Copy Markdown
Contributor Author

Addressed the two Copilot review comments in 87035b6:

  • stderr now sanitizes each line once and checks the ESLint debug namespace on the already-sanitized message.
  • pipeOutput now uses a test handler type that covers both stdout and stderr stdio handlers.

Validated locally with:

  • npm run lint --prefix client
  • npm run lint --prefix server
  • focused TypeScript check for client/src/logOutput.ts and client/src/tests/logOutput.test.ts
  • emitted node --test run for logOutput.test.ts

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.

VS Code ESLint@3.0.16 --debug option

3 participants