diff --git a/crates/typos-cli/src/bin/typos-cli/report.rs b/crates/typos-cli/src/bin/typos-cli/report.rs index 3f86f51..8f3970a 100644 --- a/crates/typos-cli/src/bin/typos-cli/report.rs +++ b/crates/typos-cli/src/bin/typos-cli/report.rs @@ -89,7 +89,7 @@ impl<'r> MessageStatus<'r> { impl<'r> Report for MessageStatus<'r> { fn report(&self, msg: Message) -> Result<(), std::io::Error> { - if msg.is_correction() { + if msg.is_typo() { self.typos_found.store(true, atomic::Ordering::Relaxed); } if msg.is_error() { diff --git a/crates/typos-cli/src/report.rs b/crates/typos-cli/src/report.rs index e11ac52..06aee50 100644 --- a/crates/typos-cli/src/report.rs +++ b/crates/typos-cli/src/report.rs @@ -20,10 +20,10 @@ pub enum Message<'m> { } impl<'m> Message<'m> { - pub fn is_correction(&self) -> bool { + pub fn is_typo(&self) -> bool { match self { Message::BinaryFile(_) => false, - Message::Typo(c) => c.corrections.is_correction(), + Message::Typo(c) => !c.corrections.is_valid(), Message::FileType(_) => false, Message::File(_) => false, Message::Parse(_) => false, diff --git a/crates/typos-cli/tests/cmd/config-disallowed.in/_typos.toml b/crates/typos-cli/tests/cmd/config-disallowed.in/_typos.toml new file mode 100644 index 0000000..56a17b6 --- /dev/null +++ b/crates/typos-cli/tests/cmd/config-disallowed.in/_typos.toml @@ -0,0 +1,2 @@ +[default.extend-identifiers] +hello = "" diff --git a/crates/typos-cli/tests/cmd/config-disallowed.in/file b/crates/typos-cli/tests/cmd/config-disallowed.in/file new file mode 100644 index 0000000..b4cfe09 --- /dev/null +++ b/crates/typos-cli/tests/cmd/config-disallowed.in/file @@ -0,0 +1 @@ +hello `hello` diff --git a/crates/typos-cli/tests/cmd/config-disallowed.toml b/crates/typos-cli/tests/cmd/config-disallowed.toml new file mode 100644 index 0000000..3185611 --- /dev/null +++ b/crates/typos-cli/tests/cmd/config-disallowed.toml @@ -0,0 +1,18 @@ +bin.name = "typos" +status.code = 2 +stdin = "" +stdout = """ +error: `hello` is disallowed + --> ./file:1:1 + | +1 | hello `hello` + | ^^^^^ + | +error: `hello` is disallowed + --> ./file:1:8 + | +1 | hello `hello` + | ^^^^^ + | +""" +stderr = ""