Skip to content

Commit

Permalink
fix(deno-lint): Replace WalkBuilder.add_ignore with WalkBuilder.overr…
Browse files Browse the repository at this point in the history
…ides (#646)

Fix the support of files.exclude from .denolint.json.

It did not work at all. Neither with a directory, nor with a patern.
Printing the errors from add_ignore revealed it:

    lib/: line 1: Is a directory (os error 21)
    lib/*.js: No such file or directory (os error 2)

Overrides are supposed to handle both directories and patterns.
  • Loading branch information
prantlf committed Jan 3, 2023
1 parent 000c6d7 commit a785bec
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions packages/deno-lint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use std::str;
use deno_ast::MediaType;
use deno_lint::linter::LinterBuilder;
use deno_lint::rules::{get_all_rules, get_recommended_rules};
use ignore::overrides::OverrideBuilder;
use ignore::types::TypesBuilder;
use ignore::WalkBuilder;
use napi::bindgen_prelude::*;
Expand Down Expand Up @@ -133,13 +134,24 @@ fn denolint(__dirname: String, config_path: String) -> Result<bool> {
Err(_) => __dirname.as_str(),
},
};
let mut dir_walker = WalkBuilder::new(cwd);
let mut dir_walker = WalkBuilder::new(cwd.clone());
dir_walker
.add_custom_ignore_filename(ignore_file_path)
.types(types)
.follow_links(true);
for i in cfg_ignore_files {
dir_walker.add_ignore(i);
if !cfg_ignore_files.is_empty() {
let mut overrides = OverrideBuilder::new(cwd);
for f in cfg_ignore_files {
let mut r = "!".to_string();
r.push_str(&f);
overrides
.add(&r)
.unwrap_or_else(|_| panic!("Adding excluded file {:?} failed", f));
}
let o = overrides
.build()
.unwrap_or_else(|_| panic!("Applying files.exclude from {:?} failed", config_path));
dir_walker.overrides(o);
}
for entry in dir_walker.build().filter_map(|v| v.ok()) {
let p = entry.path();
Expand Down

0 comments on commit a785bec

Please sign in to comment.