Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: store error codes in OxcDiagnostic #4333

Closed
DonIsaac opened this issue Jul 17, 2024 · 1 comment
Closed

refactor: store error codes in OxcDiagnostic #4333

DonIsaac opened this issue Jul 17, 2024 · 1 comment
Labels
C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior

Comments

@DonIsaac
Copy link
Collaborator

Instead of inlining error codes into messages (e.g. eslint(eqeqeq): use '===' instead of '=='), they should be stored separately.
This will let us

  • configure codes automatically for lint rules
  • support hyperlinks in the future

Tasks

First, change OxcDiagnosticInner from

pub struct OxcDiagnosticInner {
    pub message: Cow<'static, str>,
    pub labels: Option<Vec<LabeledSpan>>,
    pub help: Option<Cow<'static, str>>,
    pub severity: Severity,
}

To:

pub struct OxcDiagnosticInner {
    pub message: Cow<'static, str>,
    pub labels: Option<Vec<LabeledSpan>>,
    pub help: Option<Cow<'static, str>>,
    pub severity: Severity,
    pub code_scope: Option<Cow<'static, str>>, // eg `eslint`
    pub code_num: Option<Cow<'static, str>>,   // eg `eqeqeq`
}

Next, update LintContext to set code_scope and code_num before running a rule.

Finally, update all lint rule diagnostics to remove their inlined error codes.

@DonIsaac DonIsaac added the C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior label Jul 17, 2024
@mysteryven
Copy link
Member

  • configure codes automatically for lint rules

Could you explain more about this? 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior
Projects
None yet
Development

No branches or pull requests

2 participants