Skip to content

Offline, privacy-first grammar checker. Fast, open-source, Rust-powered

fix(core): adjust ToTwoToo linter to ignore transitions (#2761)

Elijah Potterc32bfbf854b1
diff --git a/harper-core/src/linting/to_two_too/mod.rs b/harper-core/src/linting/to_two_too/mod.rs
index bdd1fcb62..699632e7f 100644
--- a/harper-core/src/linting/to_two_too/mod.rs
+++ b/harper-core/src/linting/to_two_too/mod.rs
@@ -448,4 +448,19 @@ mod tests {
fn no_lint_prone_to_melancholy() {
assert_no_lints("He wasn’t a man prone to melancholy.", ToTwoToo::default());
}
+
+ #[test]
+ fn no_lint_superlative_range() {
+ assert_no_lints("Sort speeds from slowest to fastest.", ToTwoToo::default());
+ }
+
+ #[test]
+ fn no_lint_comparative_range() {
+ assert_no_lints("We rank tasks from harder to easier.", ToTwoToo::default());
+ }
+
+ #[test]
+ fn still_lints_positive_adjective_end() {
+ assert_lint_count("The room felt to cold.", ToTwoToo::default(), 1);
+ }
}
diff --git a/harper-core/src/linting/to_two_too/to_too_adjective_end.rs b/harper-core/src/linting/to_two_too/to_too_adjective_end.rs
index 099439a1a..94104b226 100644
--- a/harper-core/src/linting/to_two_too/to_too_adjective_end.rs
+++ b/harper-core/src/linting/to_two_too/to_too_adjective_end.rs
@@ -53,7 +53,10 @@ impl ExprLinter for ToTooAdjectiveEnd {
while idx < tokens.len() && tokens[idx].kind.is_whitespace() {
idx += 1;
}
- if idx >= tokens.len() || !tokens[idx].kind.is_adjective() {
+ if idx >= tokens.len()
+ || !tokens[idx].kind.is_adjective()
+ || !tokens[idx].kind.is_positive_adjective()
+ {
return None;
}
let prev_non_ws = tokens[..to_index].iter().rfind(|t| !t.kind.is_whitespace());
diff --git a/harper-core/src/linting/to_two_too/to_too_adjective_punct.rs b/harper-core/src/linting/to_two_too/to_too_adjective_punct.rs
index 141eeec61..4267dc954 100644
--- a/harper-core/src/linting/to_two_too/to_too_adjective_punct.rs
+++ b/harper-core/src/linting/to_two_too/to_too_adjective_punct.rs
@@ -53,7 +53,7 @@ impl ExprLinter for ToTooAdjectivePunct {
return None;
}
let adjective = &tokens[idx];
- if !adjective.kind.is_adjective() {
+ if !adjective.kind.is_adjective() || !adjective.kind.is_positive_adjective() {
return None;
}
if adjective.kind.is_preposition() {