mirror of
https://github.com/denoland/deno.git
synced 2024-11-28 16:20:57 -05:00
fix(lint): allow to use --rules with --rules-tags (#19754)
This commit is contained in:
parent
2b73ea9b16
commit
4f8f258851
3 changed files with 36 additions and 4 deletions
|
@ -1584,7 +1584,6 @@ Ignore linting a file by adding an ignore comment at the top of the file:
|
|||
.num_args(1..)
|
||||
.action(ArgAction::Append)
|
||||
.use_value_delimiter(true)
|
||||
.conflicts_with("rules")
|
||||
.help("Use set of rules with a tag"),
|
||||
)
|
||||
.arg(
|
||||
|
@ -4154,6 +4153,32 @@ mod tests {
|
|||
}
|
||||
);
|
||||
|
||||
let r = flags_from_vec(svec![
|
||||
"deno",
|
||||
"lint",
|
||||
"--rules",
|
||||
"--rules-tags=recommended"
|
||||
]);
|
||||
assert_eq!(
|
||||
r.unwrap(),
|
||||
Flags {
|
||||
subcommand: DenoSubcommand::Lint(LintFlags {
|
||||
files: FileFlags {
|
||||
include: vec![],
|
||||
ignore: vec![],
|
||||
},
|
||||
rules: true,
|
||||
maybe_rules_tags: Some(svec!["recommended"]),
|
||||
maybe_rules_include: None,
|
||||
maybe_rules_exclude: None,
|
||||
json: false,
|
||||
compact: false,
|
||||
watch: Default::default(),
|
||||
}),
|
||||
..Flags::default()
|
||||
}
|
||||
);
|
||||
|
||||
let r = flags_from_vec(svec![
|
||||
"deno",
|
||||
"lint",
|
||||
|
|
|
@ -140,7 +140,10 @@ async fn run_subcommand(flags: Flags) -> Result<i32, AnyError> {
|
|||
DenoSubcommand::Lsp => spawn_subcommand(async { lsp::start().await }),
|
||||
DenoSubcommand::Lint(lint_flags) => spawn_subcommand(async {
|
||||
if lint_flags.rules {
|
||||
tools::lint::print_rules_list(lint_flags.json);
|
||||
tools::lint::print_rules_list(
|
||||
lint_flags.json,
|
||||
lint_flags.maybe_rules_tags,
|
||||
);
|
||||
Ok(())
|
||||
} else {
|
||||
tools::lint::lint(flags, lint_flags).await
|
||||
|
|
|
@ -202,8 +202,12 @@ fn collect_lint_files(files: &FilesConfig) -> Result<Vec<PathBuf>, AnyError> {
|
|||
.collect_files(&files.include)
|
||||
}
|
||||
|
||||
pub fn print_rules_list(json: bool) {
|
||||
let lint_rules = rules::get_recommended_rules();
|
||||
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,
|
||||
});
|
||||
|
||||
if json {
|
||||
let json_rules: Vec<serde_json::Value> = lint_rules
|
||||
|
|
Loading…
Reference in a new issue