From 916ddcef6d55edbf2478cae507e49e55ef3a62ad Mon Sep 17 00:00:00 2001 From: sigmaSd Date: Sun, 27 Aug 2023 10:17:41 +0100 Subject: [PATCH] feat(lint): --rules print all rules (#20256) The motivation is If I'm using deno lint --rules, I want to see all the rules especially the one that have no tags, since the recommend ones are already active This change also prints the tags associated with the rule inline. --- cli/tools/lint.rs | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/cli/tools/lint.rs b/cli/tools/lint.rs index e1830fb92c..753a9c08b6 100644 --- a/cli/tools/lint.rs +++ b/cli/tools/lint.rs @@ -204,11 +204,11 @@ fn collect_lint_files(files: &FilesConfig) -> Result, AnyError> { } pub fn print_rules_list(json: bool, maybe_rules_tags: Option>) { - let lint_rules = get_configured_rules(LintRulesConfig { - exclude: None, - include: None, - tags: maybe_rules_tags, - }); + let lint_rules = if maybe_rules_tags.is_none() { + rules::get_all_rules() + } else { + rules::get_filtered_rules(maybe_rules_tags, None, None) + }; if json { let json_rules: Vec = lint_rules @@ -228,8 +228,19 @@ pub fn print_rules_list(json: bool, maybe_rules_tags: Option>) { // so use `println!` here instead of `info!`. println!("Available rules:"); for rule in lint_rules.iter() { - println!(" - {}", rule.code()); - println!(" help: https://lint.deno.land/#{}", rule.code()); + print!(" - {}", colors::cyan(rule.code())); + if rule.tags().is_empty() { + println!(); + } else { + println!(" [{}]", colors::gray(rule.tags().join(", "))) + } + println!( + "{}", + colors::gray(format!( + " help: https://lint.deno.land/#{}", + rule.code() + )) + ); println!(); } }