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

Add LintDiagnostic::severity #1274

Open
bartlomieju opened this issue May 12, 2024 · 1 comment
Open

Add LintDiagnostic::severity #1274

bartlomieju opened this issue May 12, 2024 · 1 comment
Labels
feature a new feature help wanted Extra attention is needed

Comments

@bartlomieju
Copy link
Member

Other popular linters like ESLint allow to customize the severity of diagnostics - either "warning" or "error". Currently deno_lint treats all diagnostics all "error".

To allow for severity customization there are two major parts that need to happen:

  1. Add severity field to LintDiagnostic struct so it can be properly formatted during printing
  2. Add configuration options that would allow to customize the severity of each lint rule.

To handle point 1 following things need to happen:

  1. Add LintDiagnosticSeverity enum like so:
#[derive(Debug, Default, Clone, Copy)]
pub enum LintDiagnosticSeverity {
  #[default]
  Error,
  Warning,
}
  1. Update LintDiagnostic struct and add severity: LintDiagnosticSeverity field to it
  2. Update necessary APIs to accept severity: LintDiagnosticSeverity argument in following order:
  • Context::create_diagnostic
  • Context::add_diagnostic_with_fixes
  • Context::add_diagnostic_with_hint
  • Context::add_diagnostic
  1. Update LintDiagnostic::level() to convert LintDiagnosticSeverity into deno_ast::DiagnosticLevel.

These changes should be enough to be able to apply different formatting based on severity and can be first applied in examples/dlint/diagnostics.rs in print_compact and print_pretty.

Handling point 2 is more involved and requires further discussion as the current lint configuration is rather bare-bones - it allows to specify a list of lints to run, but not customize them one-by-one.

If someone picks up this issue I can provide more details on how to handle that, but mind that it require changes across several repositories - deno_lint, deno_config and deno itself.

@bartlomieju bartlomieju added help wanted Extra attention is needed feature a new feature labels May 12, 2024
@eryue0220
Copy link

Could I have a try for this one if no one take it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a new feature help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants