summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsigmaSd <bedisnbiba@gmail.com>2023-08-27 10:17:41 +0100
committerGitHub <noreply@github.com>2023-08-27 11:17:41 +0200
commit916ddcef6d55edbf2478cae507e49e55ef3a62ad (patch)
tree38d5ccacff891deba81a3bb54ad913516f11ec82
parente1fe31508c471eeb7c30916abd780b3930f7e42b (diff)
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.
-rw-r--r--cli/tools/lint.rs25
1 files changed, 18 insertions, 7 deletions
diff --git a/cli/tools/lint.rs b/cli/tools/lint.rs
index e1830fb92..753a9c08b 100644
--- a/cli/tools/lint.rs
+++ b/cli/tools/lint.rs
@@ -204,11 +204,11 @@ fn collect_lint_files(files: &FilesConfig) -> Result<Vec<PathBuf>, AnyError> {
}
pub fn print_rules_list(json: bool, maybe_rules_tags: Option<Vec<String>>) {
- 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<serde_json::Value> = lint_rules
@@ -228,8 +228,19 @@ pub fn print_rules_list(json: bool, maybe_rules_tags: Option<Vec<String>>) {
// 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!();
}
}