diff --git a/crates/typos-cli/src/config.rs b/crates/typos-cli/src/config.rs index 8a753b2..b1eb7c7 100644 --- a/crates/typos-cli/src/config.rs +++ b/crates/typos-cli/src/config.rs @@ -2,6 +2,8 @@ use std::collections::HashMap; use kstring::KString; +pub const SUPPORTED_FILE_NAMES: &[&str] = &["typos.toml", "_typos.toml", ".typos.toml"]; + #[derive(Debug, Clone, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[serde(deny_unknown_fields)] #[serde(default)] @@ -17,9 +19,7 @@ pub struct Config { impl Config { pub fn from_dir(cwd: &std::path::Path) -> Result, anyhow::Error> { - let config = if let Some(path) = - find_project_file(cwd, &["typos.toml", "_typos.toml", ".typos.toml"]) - { + let config = if let Some(path) = find_project_file(cwd, SUPPORTED_FILE_NAMES) { log::debug!("Loading {}", path.display()); Some(Self::from_file(&path)?) } else { diff --git a/crates/typos-cli/src/file.rs b/crates/typos-cli/src/file.rs index 17fdbf6..8c1b8bf 100644 --- a/crates/typos-cli/src/file.rs +++ b/crates/typos-cli/src/file.rs @@ -684,6 +684,12 @@ fn walk_entry( return Ok(()); } }; + if crate::config::SUPPORTED_FILE_NAMES + .iter() + .any(|n| *n == entry.file_name()) + { + return Ok(()); + } if entry.file_type().map(|t| t.is_file()).unwrap_or(true) { let explicit = entry.depth() == 0; let (path, lookup_path) = if entry.is_stdin() { diff --git a/crates/typos-cli/tests/cmd/extend-builtin-dict.in/_typos.toml b/crates/typos-cli/tests/cmd/extend-builtin-dict.in/_typos.toml index c82050d..3886286 100644 --- a/crates/typos-cli/tests/cmd/extend-builtin-dict.in/_typos.toml +++ b/crates/typos-cli/tests/cmd/extend-builtin-dict.in/_typos.toml @@ -3,8 +3,3 @@ check-filename = false [default.extend-words] foo = "bar" - -[files] -extend-exclude = [ - "_typos.toml" -] diff --git a/crates/typos-cli/tests/cmd/extend-ignore-identifiers-re.in/_typos.toml b/crates/typos-cli/tests/cmd/extend-ignore-identifiers-re.in/_typos.toml index ac8e24c..0ccaa43 100644 --- a/crates/typos-cli/tests/cmd/extend-ignore-identifiers-re.in/_typos.toml +++ b/crates/typos-cli/tests/cmd/extend-ignore-identifiers-re.in/_typos.toml @@ -1,6 +1,3 @@ -[files] -extend-exclude = ["_typos.toml"] - [default.extend-identifiers] hello = "goodbye" diff --git a/crates/typos-cli/tests/cmd/extend-ignore-re.in/_typos.toml b/crates/typos-cli/tests/cmd/extend-ignore-re.in/_typos.toml index f248fcb..e1192cb 100644 --- a/crates/typos-cli/tests/cmd/extend-ignore-re.in/_typos.toml +++ b/crates/typos-cli/tests/cmd/extend-ignore-re.in/_typos.toml @@ -1,6 +1,3 @@ -[files] -extend-exclude = ["_typos.toml"] - [default] extend-ignore-re = ["`.*`"] diff --git a/crates/typos-cli/tests/cmd/override-default-type.in/_typos.toml b/crates/typos-cli/tests/cmd/override-default-type.in/_typos.toml index 9128c76..a059000 100644 --- a/crates/typos-cli/tests/cmd/override-default-type.in/_typos.toml +++ b/crates/typos-cli/tests/cmd/override-default-type.in/_typos.toml @@ -4,8 +4,3 @@ check-file = false [default.extend-words] foo = "bar" - -[files] -extend-exclude = [ - "_typos.toml" -]