mirror of
https://github.com/denoland/deno.git
synced 2024-12-23 15:49:44 -05:00
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.
This commit is contained in:
parent
e1fe31508c
commit
916ddcef6d
1 changed files with 18 additions and 7 deletions
|
@ -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!();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue