Repository: denoland/deno
File: cli/tools/lint/mod.rs (Rust)

Code before:
      reporter_lock,
      workspace_module_graph: None,
      has_error: Default::default(),
      file_count: 0,
    }
  }

  pub async fn lint_files(
    &mut self,
    cli_options: &Arc<CliOptions>,
    lint_options: LintOptions,
    member_dir: WorkspaceDirectory,
    paths: Vec<PathBuf>,
  ) -> Result<(), AnyError> {
    self.file_count += paths.len();

    let exclude = lint_options.rules.exclude.clone();

    let plugin_specifiers = lint_options.plugins.clone();
    let lint_rules = self.lint_rule_provider.resolve_lint_rules(
      lint_options.rules,
      member_dir.maybe_deno_json().map(|c| c.as_ref()),
    );
    if lint_rules.rules.is_empty() && plugin_specifiers.is_empty() {
      bail!("No rules have been configured")
    }

    let mut maybe_incremental_cache = None;

    // TODO(bartlomieju): for now we don't support incremental caching if plugins are being used.
    // https://github.com/denoland/deno/issues/28025
    if lint_rules.supports_incremental_cache() && plugin_specifiers.is_empty() {
      let mut hasher = FastInsecureHasher::new_deno_versioned();
      hasher.write_hashable(lint_rules.incremental_cache_state());
      if !plugin_specifiers.is_empty() {
        hasher.write_hashable(&plugin_specifiers);
      }
      let state_hash = hasher.finish();

      maybe_incremental_cache = Some(Arc::new(IncrementalCache::new(
        self.caches.lint_incremental_cache_db(),
        CacheDBHash::new(state_hash),
        &paths,
      )));
    }

    #[allow(clippy::print_stdout)]
    #[allow(clippy::print_stderr)]
    fn logger_printer(msg: &str, is_err: bool) {
      if is_err {
        eprint!("{}", msg);

Review comment (bug):
I think we should do that on line 340 after the plugins are actually resolved, but maybe it's an edge case not worth exploring

Code after:
      reporter_lock,
      workspace_module_graph: None,
      has_error: Default::default(),
      file_count: 0,
    }
  }

  pub async fn lint_files(
    &mut self,
    cli_options: &Arc<CliOptions>,
    lint_options: LintOptions,
    member_dir: WorkspaceDirectory,
    paths: Vec<PathBuf>,
  ) -> Result<(), AnyError> {
    self.file_count += paths.len();

    let exclude = lint_options.rules.exclude.clone();

    let plugin_specifiers = lint_options.plugins.clone();
    let lint_rules = self.lint_rule_provider.resolve_lint_rules(
      lint_options.rules,
      member_dir.maybe_deno_json().map(|c| c.as_ref()),
    );

    let mut maybe_incremental_cache = None;

    // TODO(bartlomieju): for now we don't support incremental caching if plugins are being used.
    // https://github.com/denoland/deno/issues/28025
    if lint_rules.supports_incremental_cache() && plugin_specifiers.is_empty() {
      let mut hasher = FastInsecureHasher::new_deno_versioned();
      hasher.write_hashable(lint_rules.incremental_cache_state());
      if !plugin_specifiers.is_empty() {
        hasher.write_hashable(&plugin_specifiers);
      }
      let state_hash = hasher.finish();

      maybe_incremental_cache = Some(Arc::new(IncrementalCache::new(
        self.caches.lint_incremental_cache_db(),
        CacheDBHash::new(state_hash),
        &paths,
      )));
    }

    #[allow(clippy::print_stdout)]
    #[allow(clippy::print_stderr)]
    fn logger_printer(msg: &str, is_err: bool) {
      if is_err {
        eprint!("{}", msg);
      } else {
        print!("{}", msg);
      }