From 2ecdaf0cc8dba966bfc9b6d0849baee6b35045d4 Mon Sep 17 00:00:00 2001 From: Christopher Dwyer-Perkins Date: Wed, 6 May 2026 10:22:32 -0300 Subject: [PATCH 1/5] Add diagnosticReporter config option for diagnostic output formatting Adds a new `diagnosticReporter` setting in bsconfig.json (and a matching `--diagnostic-reporter` CLI flag) that lets users pick how diagnostics are rendered to the console. Accepts a single value or an array, where each value is a preset name ("detailed", "github-actions"), a custom template string, or an explicit object form. Multiple reporters can run in the same build so a CI run can emit detailed terminal output and GitHub Actions PR annotations simultaneously without a third-party tool. Invalid reporter values are logged and skipped rather than aborting the build; if every configured reporter is invalid the build falls back to "detailed". Schema and docs/bsconfig.md updated. --- bsconfig.schema.json | 62 +++++++++ docs/bsconfig.md | 52 +++++++ src/BsConfig.ts | 49 ++++++- src/ProgramBuilder.ts | 22 ++- src/cli.ts | 8 ++ src/diagnosticUtils.spec.ts | 269 ++++++++++++++++++++++++++++++++++++ src/diagnosticUtils.ts | 243 +++++++++++++++++++++++++++++++- 7 files changed, 701 insertions(+), 4 deletions(-) diff --git a/bsconfig.schema.json b/bsconfig.schema.json index 7c421a0d5..520d740c4 100644 --- a/bsconfig.schema.json +++ b/bsconfig.schema.json @@ -8,6 +8,53 @@ "password" ] }, + "definitions": { + "diagnosticReporterValue": { + "oneOf": [ + { + "type": "string", + "description": "Either a preset name ('detailed' or 'github-actions') or a custom template string containing at least one known placeholder." + }, + { + "type": "object", + "required": ["type"], + "properties": { + "type": { + "type": "string", + "enum": ["detailed"] + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": ["type"], + "properties": { + "type": { + "type": "string", + "enum": ["github-actions"] + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": ["type", "format"], + "properties": { + "type": { + "type": "string", + "enum": ["custom"] + }, + "format": { + "type": "string", + "description": "Template string. Supported placeholders: {file}, {line}, {col}, {endLine}, {endCol}, {severity}, {severityCode}, {code}, {message}, {source}." + } + }, + "additionalProperties": false + } + ] + } + }, "properties": { "extends": { "description": "Relative or absolute path to another bsconfig.json file that this file should use as a base and then override. Prefix with a question mark (?) to prevent throwing an exception if the file does not exist.", @@ -300,6 +347,21 @@ "error" ] }, + "diagnosticReporter": { + "description": "Specify how diagnostics are reported to the console. Accepts a single value or an array; each diagnostic is rendered once per entry. Each value is either a preset name ('detailed', 'github-actions'), a custom template string containing at least one known placeholder ({file}, {line}, {col}, {endLine}, {endCol}, {severity}, {severityCode}, {code}, {message}, {source}), or an object with explicit `type`. Defaults to 'detailed'.", + "default": "detailed", + "oneOf": [ + { + "$ref": "#/definitions/diagnosticReporterValue" + }, + { + "type": "array", + "items": { + "$ref": "#/definitions/diagnosticReporterValue" + } + } + ] + }, "allowBrighterScriptInBrightScript": { "description": "Allow brighterscript features (classes, interfaces, etc...) to be included in BrightScript (`.brs`) files, and force those files to be transpiled.", "type": "boolean", diff --git a/docs/bsconfig.md b/docs/bsconfig.md index 13a2c12d9..25e3c59cb 100644 --- a/docs/bsconfig.md +++ b/docs/bsconfig.md @@ -121,6 +121,58 @@ Type: `"hint" | "info" | "warn" | "error"` Specify what diagnostic levels are printed to the console. This has no effect on what diagnostics are reported in the LanguageServer. Defaults to `"warn"`. +## `diagnosticReporter` + +Type: `string | { type: string; format?: string } | Array` + +Specify how diagnostics are reported to the console. Accepts a single value or an array; when given an array, each diagnostic is rendered once per entry (so you can, for example, emit detailed terminal output and GitHub Actions PR annotations from a single run). Defaults to `"detailed"`. + +Each value can be: + +- A **preset name**: `"detailed"` (the default rich, multi-line, colored output) or `"github-actions"` (one-line workflow commands like `::error file=...,line=...::message` so the GitHub Actions runner surfaces them as PR annotations). +- A **custom template string** containing at least one of the known placeholders. The placeholders supported are: + + | Placeholder | Value | + |------------------|---| + | `{file}` | file path (respects `emitFullPaths`) | + | `{line}` / `{col}` | 1-based start line / column | + | `{endLine}` / `{endCol}` | 1-based end line / column | + | `{severity}` | `error` / `warning` / `info` / `hint` | + | `{severityCode}` | numeric LSP severity (1=error, 2=warning, 3=info, 4=hint) | + | `{code}` | diagnostic code (e.g. `1001`) | + | `{message}` | diagnostic message | + | `{source}` | diagnostic source (e.g. `brs`) | + + Unknown placeholders pass through unchanged so typos surface visually. +- An **explicit object** with `type`: `{ "type": "detailed" }`, `{ "type": "github-actions" }`, or `{ "type": "custom", "format": "