diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2021-09-03 17:01:58 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-03 17:01:58 +0200 |
commit | d93570a6195d2be5fe448bb0d33d4f64e839676e (patch) | |
tree | a44431235693f484308aad70cda66827605f4568 /cli/main.rs | |
parent | c3001fe280add8c695c288fe26b8f81b5f2f0261 (diff) |
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=<tags> - allows specifying which set of tagged rules should be run
--rules-include=<rules> - allow specifying which rules should be run
--rules-exclude=<rules> - allow specifying which rules should not be run
Diffstat (limited to 'cli/main.rs')
-rw-r--r-- | cli/main.rs | 40 |
1 files changed, 37 insertions, 3 deletions
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<PathBuf>, list_rules: bool, + rules_tags: Vec<String>, + rules_include: Vec<String>, + rules_exclude: Vec<String>, ignore: Vec<PathBuf>, 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 { |