mirror of
https://github.com/denoland/deno.git
synced 2024-10-29 08:58:01 -04:00
fix(lint): use recommended tags when no tags specified in config, but includes or excludes are (#12700)
This commit is contained in:
parent
66974a8794
commit
45425c1146
1 changed files with 34 additions and 1 deletions
|
@ -530,7 +530,7 @@ pub(crate) fn get_configured_rules(
|
|||
};
|
||||
|
||||
let configured_rules = rules::get_filtered_rules(
|
||||
maybe_configured_tags,
|
||||
maybe_configured_tags.or_else(|| Some(vec!["recommended".to_string()])),
|
||||
maybe_configured_exclude,
|
||||
maybe_configured_include,
|
||||
);
|
||||
|
@ -541,3 +541,36 @@ pub(crate) fn get_configured_rules(
|
|||
|
||||
Ok(configured_rules)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use deno_lint::rules::get_recommended_rules;
|
||||
|
||||
use super::*;
|
||||
use crate::config_file::LintRulesConfig;
|
||||
|
||||
#[test]
|
||||
fn recommended_rules_when_no_tags_in_config() {
|
||||
let lint_config = LintConfig {
|
||||
rules: LintRulesConfig {
|
||||
exclude: Some(vec!["no-debugger".to_string()]),
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
};
|
||||
let rules =
|
||||
get_configured_rules(Some(&lint_config), None, None, None).unwrap();
|
||||
let mut rule_names = rules
|
||||
.into_iter()
|
||||
.map(|r| r.code().to_string())
|
||||
.collect::<Vec<_>>();
|
||||
rule_names.sort();
|
||||
let mut recommended_rule_names = get_recommended_rules()
|
||||
.into_iter()
|
||||
.map(|r| r.code().to_string())
|
||||
.filter(|n| n != "no-debugger")
|
||||
.collect::<Vec<_>>();
|
||||
recommended_rule_names.sort();
|
||||
assert_eq!(rule_names, recommended_rule_names);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue