Offline, privacy-first grammar checker. Fast, open-source, Rust-powered
fix: don't flag "to" before "only" in ToTwoToo (#3093)
Joaquin Hui2e0ab60381f8
diff --git a/harper-core/src/linting/to_two_too/mod.rs b/harper-core/src/linting/to_two_too/mod.rsindex 699632e7f..6e63fe566 100644--- a/harper-core/src/linting/to_two_too/mod.rs+++ b/harper-core/src/linting/to_two_too/mod.rs@@ -463,4 +463,17 @@ mod tests {fn still_lints_positive_adjective_end() {assert_lint_count("The room felt to cold.", ToTwoToo::default(), 1);}++ #[test]+ fn no_lint_to_only() {+ assert_no_lints(+ "The dog was restricted to only one can of food.",+ ToTwoToo::default(),+ );+ }++ #[test]+ fn no_lint_to_only_at_end() {+ assert_no_lints("limited to only", ToTwoToo::default());+ }}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.rsindex 846850f0d..b25c73c92 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@@ -20,7 +20,7 @@ impl Default for ToTooAdjectiveEnd {.then_kind_is_but_is_not_except(TokenKind::is_adjective,TokenKind::is_verb,- &["standard"],+ &["standard", "only"],).then_optional(WhitespacePattern).then_optional(SequenceExpr::any_word())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.rsindex 1df3f0e17..b1fe905c4 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@@ -20,7 +20,7 @@ impl Default for ToTooAdjectivePunct {.then_kind_is_but_is_not_except(TokenKind::is_adjective,TokenKind::is_verb,- &["standard"],+ &["standard", "only"],).then_optional(WhitespacePattern).then_sentence_terminator();diff --git a/harper-core/src/linting/to_two_too/to_too_adverb.rs b/harper-core/src/linting/to_two_too/to_too_adverb.rsindex d87282356..66efe2dab 100644--- a/harper-core/src/linting/to_two_too/to_too_adverb.rs+++ b/harper-core/src/linting/to_two_too/to_too_adverb.rs@@ -17,7 +17,11 @@ impl Default for ToTooAdverb {let expr = SequenceExpr::default().t_aco("to").t_ws()- .then_kind_is_but_is_not_except(TokenKind::is_adverb, TokenKind::is_determiner, &["as"])+ .then_kind_is_but_is_not_except(+ TokenKind::is_adverb,+ TokenKind::is_determiner,+ &["as", "only"],+ ).then_optional(WhitespacePattern).then_any_of(vec![Box::new(SequenceExpr::default().then_kind_is_but_is_not_except(