From d93570a6195d2be5fe448bb0d33d4f64e839676e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Fri, 3 Sep 2021 17:01:58 +0200 Subject: feat(lint): add support for config file and CLI flags for rules (#11776) This commit adds support for following flags in deno lint subcommand: --config - allows to load configuration file and parses "lint" object --rules-tags= - allows specifying which set of tagged rules should be run --rules-include= - allow specifying which rules should be run --rules-exclude= - allow specifying which rules should not be run --- cli/main.rs | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) (limited to 'cli/main.rs') diff --git a/cli/main.rs b/cli/main.rs index b68539ad8..8c1d219ec 100644 --- a/cli/main.rs +++ b/cli/main.rs @@ -489,10 +489,14 @@ async fn lsp_command() -> Result<(), AnyError> { lsp::start().await } +#[allow(clippy::too_many_arguments)] async fn lint_command( - _flags: Flags, + flags: Flags, files: Vec, list_rules: bool, + rules_tags: Vec, + rules_include: Vec, + rules_exclude: Vec, ignore: Vec, json: bool, ) -> Result<(), AnyError> { @@ -501,7 +505,24 @@ async fn lint_command( return Ok(()); } - tools::lint::lint_files(files, ignore, json).await + let program_state = ProgramState::build(flags.clone()).await?; + let maybe_lint_config = + if let Some(config_file) = &program_state.maybe_config_file { + config_file.to_lint_config()? + } else { + None + }; + + tools::lint::lint_files( + maybe_lint_config, + rules_tags, + rules_include, + rules_exclude, + files, + ignore, + json, + ) + .await } async fn cache_command( @@ -1183,9 +1204,22 @@ fn get_subcommand( DenoSubcommand::Lint { files, rules, + rules_tags, + rules_include, + rules_exclude, ignore, json, - } => lint_command(flags, files, rules, ignore, json).boxed_local(), + } => lint_command( + flags, + files, + rules, + rules_tags, + rules_include, + rules_exclude, + ignore, + json, + ) + .boxed_local(), DenoSubcommand::Repl { eval } => run_repl(flags, eval).boxed_local(), DenoSubcommand::Run { script } => run_command(flags, script).boxed_local(), DenoSubcommand::Test { -- cgit v1.2.3