Skip to content

Commit 1ddf1a6

Browse files
epagephip1611
authored andcommitted
fix(config): Force-skip config files
This doesn't use `extend-exclude` which means that `typos typos.toml` will stil be skipped This doesn't just skip the currently loaded config but any file name that looks like a config, which might be a big aggressive but allows us to do layered config in the future.... We've been saying that for a while. Fixes crate-ci#711
1 parent 4058bd1 commit 1ddf1a6

File tree

6 files changed

+9
-19
lines changed

6 files changed

+9
-19
lines changed

crates/typos-cli/src/config.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ use std::collections::HashMap;
22

33
use kstring::KString;
44

5+
pub const SUPPORTED_FILE_NAMES: &[&str] = &["typos.toml", "_typos.toml", ".typos.toml"];
6+
57
#[derive(Debug, Clone, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
68
#[serde(deny_unknown_fields)]
79
#[serde(default)]
@@ -17,9 +19,7 @@ pub struct Config {
1719

1820
impl Config {
1921
pub fn from_dir(cwd: &std::path::Path) -> Result<Option<Self>, anyhow::Error> {
20-
let config = if let Some(path) =
21-
find_project_file(cwd, &["typos.toml", "_typos.toml", ".typos.toml"])
22-
{
22+
let config = if let Some(path) = find_project_file(cwd, SUPPORTED_FILE_NAMES) {
2323
log::debug!("Loading {}", path.display());
2424
Some(Self::from_file(&path)?)
2525
} else {

crates/typos-cli/src/file.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,12 @@ fn walk_entry(
684684
return Ok(());
685685
}
686686
};
687+
if crate::config::SUPPORTED_FILE_NAMES
688+
.iter()
689+
.any(|n| *n == entry.file_name())
690+
{
691+
return Ok(());
692+
}
687693
if entry.file_type().map(|t| t.is_file()).unwrap_or(true) {
688694
let explicit = entry.depth() == 0;
689695
let (path, lookup_path) = if entry.is_stdin() {

crates/typos-cli/tests/cmd/extend-builtin-dict.in/_typos.toml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,3 @@ check-filename = false
33

44
[default.extend-words]
55
foo = "bar"
6-
7-
[files]
8-
extend-exclude = [
9-
"_typos.toml"
10-
]

crates/typos-cli/tests/cmd/extend-ignore-identifiers-re.in/_typos.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
[files]
2-
extend-exclude = ["_typos.toml"]
3-
41
[default.extend-identifiers]
52
hello = "goodbye"
63

crates/typos-cli/tests/cmd/extend-ignore-re.in/_typos.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
[files]
2-
extend-exclude = ["_typos.toml"]
3-
41
[default]
52
extend-ignore-re = ["`.*`"]
63

crates/typos-cli/tests/cmd/override-default-type.in/_typos.toml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,3 @@ check-file = false
44

55
[default.extend-words]
66
foo = "bar"
7-
8-
[files]
9-
extend-exclude = [
10-
"_typos.toml"
11-
]

0 commit comments

Comments
 (0)