Skip to content

refactor(linter): Add optional diagnostic code to Diagnostic in stacks-core #2334

@jbencin-stacks

Description

@jbencin-stacks

In #2307, I added an optional diagnostic code which prints out the lint name . Since the Diagnostic struct in stacks-core didn't have a field for this, I implemented a wrapper, LintDiagnostic around it. This is kind of messy, it leaves us with both Diagnostics and LintDiagnostics and requires special handling to make sure we check and output both sets of diagnostics. It would be better to add an optional feild to Diagnostic to handle this:

pub struct Diagnostic {
    pub level: Level,
    pub message: String,
    pub spans: Vec<Span>,
    pub suggestion: Option<String>,
    pub code: Option<&'static str>, // Proposed addition
}

A &'static str should be fine because the set of diagnostic codes are fixed and known at compile time

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions