Skip to content

Commit

Permalink
Merge pull request #762 from epage/config
Browse files Browse the repository at this point in the history
fix(config): Force-skip config files
  • Loading branch information
epage authored Jun 22, 2023
2 parents 4ccd3cb + 5f1d3c2 commit 2868856
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 19 deletions.
6 changes: 3 additions & 3 deletions crates/typos-cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand All @@ -17,9 +19,7 @@ pub struct Config {

impl Config {
pub fn from_dir(cwd: &std::path::Path) -> Result<Option<Self>, 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 {
Expand Down
6 changes: 6 additions & 0 deletions crates/typos-cli/src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
5 changes: 0 additions & 5 deletions crates/typos-cli/tests/cmd/extend-builtin-dict.in/_typos.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,3 @@ check-filename = false

[default.extend-words]
foo = "bar"

[files]
extend-exclude = [
"_typos.toml"
]
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[files]
extend-exclude = ["_typos.toml"]

[default.extend-identifiers]
hello = "goodbye"

Expand Down
3 changes: 0 additions & 3 deletions crates/typos-cli/tests/cmd/extend-ignore-re.in/_typos.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[files]
extend-exclude = ["_typos.toml"]

[default]
extend-ignore-re = ["`.*`"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,3 @@ check-file = false

[default.extend-words]
foo = "bar"

[files]
extend-exclude = [
"_typos.toml"
]

0 comments on commit 2868856

Please sign in to comment.