rokucommunity / rokucommunity/brighterscript

Require plugins to declare their diagnostic codes

Open
#1,797 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Breaking Change
Dominant language
TypeScript
Stars
208
Forks
68
Avg merge
8h 39m
Merged PRs (30d)
39

Description

Right now diagnostic codes are completely unrestricted. You can use numbers, strings, or a mix. This presents several problems:

  • no detection for diagnostic collision. 2 plugins could use the same diagnostic code for completely independent things
  • no detection for a typo in your bs:disable comments

This is a breaking change, as we will start flagging all unknown diagnostic codes that are provided through validation flows, as well as in bs:disable comments.

Proposal

  1. Add a plugin lifecycle hook (e.g. onRegisterDiagnostics / activation event) where plugins declare the diagnostic codes they own, up front.
  2. Support re-declaration if a plugin's diagnostics change based on config (call the hook again on config change, or let plugins return a fresh list each time it's invoked. (e.g. program.registerDaignosticsForPlugin(pluginName: string, diagnosticDeclarations: []) )
  3. BrighterScript validates all registered codes at startup/reload and throws on collision.
  4. Once codes are registered, bs:disable comments referencing an unregistered code become a diagnostic themselves (typo detection).

Open questions

  • Prefix delimiter/format (:, -, .)?
  • Namespacing policy: should we require all plugin diagnostics to be prefixed (myplugin:1000), full stop? Core BrighterScript codes stay unprefixed. Or, we could do "prefix only if you collide"?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing plugin registration, validation flows, and bs:disable comment handling described in the issue. Resolve the open questions about declaration hooks, re-declaration, namespacing, and delimiters before implementation. Done means registered diagnostic codes are validated for collisions and unknown codes are reported consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.