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

chore(lint): update to the new deno_lint API #27323

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions cli/tools/lint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ pub fn print_rules_list(json: bool, maybe_rules_tags: Option<Vec<String>>) {
.map(|rule| {
serde_json::json!({
"code": rule.code(),
"tags": rule.tags(),
"tags": rule.tags().iter().map(|t| t.to_string()).collect::<Vec<String>>(),
"docs": rule.docs(),
})
})
Expand All @@ -479,7 +479,9 @@ pub fn print_rules_list(json: bool, maybe_rules_tags: Option<Vec<String>>) {
if rule.tags().is_empty() {
println!();
} else {
println!(" [{}]", colors::gray(rule.tags().join(", ")))
let tags: Vec<String> =
rule.tags().iter().map(ToString::to_string).collect();
println!(" [{}]", colors::gray(tags.join(", ")));
}
println!(
"{}",
Expand Down
5 changes: 3 additions & 2 deletions cli/tools/lint/rules/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use deno_core::error::AnyError;
use deno_graph::ModuleGraph;
use deno_lint::diagnostic::LintDiagnostic;
use deno_lint::rules::LintRule;
use deno_lint::tags;

use crate::resolver::CliSloppyImportsResolver;

Expand All @@ -25,7 +26,7 @@ pub use no_slow_types::collect_no_slow_type_diagnostics;
pub trait PackageLintRule: std::fmt::Debug + Send + Sync {
fn code(&self) -> &'static str;

fn tags(&self) -> &'static [&'static str] {
fn tags(&self) -> tags::Tags {
&[]
}

Expand Down Expand Up @@ -74,7 +75,7 @@ impl CliLintRule {
}
}

pub fn tags(&self) -> &'static [&'static str] {
pub fn tags(&self) -> tags::Tags {
use CliLintRuleKind::*;
match &self.0 {
DenoLint(rule) => rule.tags(),
Expand Down
5 changes: 3 additions & 2 deletions cli/tools/lint/rules/no_sloppy_imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use deno_lint::diagnostic::LintDiagnosticRange;
use deno_lint::diagnostic::LintFix;
use deno_lint::diagnostic::LintFixChange;
use deno_lint::rules::LintRule;
use deno_lint::tags;
use deno_resolver::sloppy_imports::SloppyImportsResolution;
use deno_resolver::sloppy_imports::SloppyImportsResolutionKind;
use text_lines::LineAndColumnIndex;
Expand Down Expand Up @@ -166,8 +167,8 @@ impl LintRule for NoSloppyImportsRule {
include_str!("no_sloppy_imports.md")
}

fn tags(&self) -> &'static [&'static str] {
&["recommended"]
fn tags(&self) -> tags::Tags {
&[tags::RECOMMENDED]
}
}

Expand Down
5 changes: 3 additions & 2 deletions cli/tools/lint/rules/no_slow_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use deno_graph::ModuleGraph;
use deno_lint::diagnostic::LintDiagnostic;
use deno_lint::diagnostic::LintDiagnosticDetails;
use deno_lint::diagnostic::LintDiagnosticRange;
use deno_lint::tags;

use super::PackageLintRule;

Expand All @@ -22,8 +23,8 @@ impl PackageLintRule for NoSlowTypesRule {
CODE
}

fn tags(&self) -> &'static [&'static str] {
&["jsr"]
fn tags(&self) -> tags::Tags {
&[tags::JSR]
}

fn docs(&self) -> &'static str {
Expand Down
Loading