Skip to content

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

feat: accuse as → accuse of (#4700)

Andrew Dunbar0aab1a9c4830
diff --git a/harper-core/src/linting/accuse_of.rs b/harper-core/src/linting/accuse_of.rs
index 04cfdd7dd..51001ae49 100644
--- a/harper-core/src/linting/accuse_of.rs
+++ b/harper-core/src/linting/accuse_of.rs
@@ -15,7 +15,7 @@ impl Default for AccuseOf {
.t_set(["accuse", "accused", "accuses", "accusing"])
.then_optional(SequenceExpr::whitespace().then_object_pronoun())
.t_ws()
- .t_aco("for")
+ .t_set(["for", "as"])
.but_not(SequenceExpr::word_seq(&["the", "accused"])),
}
}
@@ -58,7 +58,7 @@ impl ExprLinter for AccuseOf {
"of",
span.get_content(src),
)],
- message: "The correct preposition is `of`, not `for`.".to_owned(),
+ message: "The correct preposition is `of`, not `for` or `as`.".to_owned(),
..Default::default()
})
}
@@ -68,7 +68,7 @@ impl ExprLinter for AccuseOf {
}
fn description(&self) -> &str {
- "Corrects `accuse for` to `accuse of`."
+ "Corrects `accuse for/as` to `accuse of`."
}
}
@@ -159,6 +159,15 @@ mod tests {
);
}
+ #[test]
+ fn fix_accused_as() {
+ assert_suggestion_result(
+ "The website collected controversy as those studies were accused as not being very impartial and potentially misleading.",
+ AccuseOf::default(),
+ "The website collected controversy as those studies were accused of not being very impartial and potentially misleading.",
+ );
+ }
+
// Potential false positives
#[test]