Skip to content

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

feat(core): add linter for #346 (#1407)

Elijah Potter0fb45f57b29f
diff --git a/harper-core/src/linting/phrase_corrections/mod.rs b/harper-core/src/linting/phrase_corrections/mod.rs
index 5e3809155..41e2eb978 100644
--- a/harper-core/src/linting/phrase_corrections/mod.rs
+++ b/harper-core/src/linting/phrase_corrections/mod.rs
@@ -1317,6 +1317,18 @@ pub fn lint_group() -> LintGroup {
"Use `worst` for the extreme case. (`Worse` is for comparing)",
"Corrects `worse ever` to `worst ever` for proper comparative usage."
),
+ "IAmAgreement" => (
+ ["I are"],
+ ["I am"],
+ "The first-person singular pronoun `I` requires the verb form `am`; `are` belongs to second-person or plural contexts.",
+ "Corrects `I are` to `I am`."
+ ),
+ "IDo" => (
+ ["I does"],
+ ["I do"],
+ "`I` pairs with the bare verb `do`; the –s inflection `does` is reserved for third-person singular subjects.",
+ "Corrects `I does` to `I do`."
+ ),
});
group.set_all_rules_to(Some(true));
diff --git a/harper-core/src/linting/phrase_corrections/tests.rs b/harper-core/src/linting/phrase_corrections/tests.rs
index 61b08dc49..d3a49cb1e 100644
--- a/harper-core/src/linting/phrase_corrections/tests.rs
+++ b/harper-core/src/linting/phrase_corrections/tests.rs
@@ -1918,3 +1918,21 @@ fn detect_worst_ever_real_world() {
fn now_on_hold() {
assert_lint_count("Those are now on hold for month.", lint_group(), 0);
}
+
+#[test]
+fn corrects_i_are() {
+ assert_suggestion_result(
+ "I are really happy about this release.",
+ lint_group(),
+ "I am really happy about this release.",
+ );
+}
+
+#[test]
+fn corrects_i_does() {
+ assert_suggestion_result(
+ "I does enjoy writing Rust.",
+ lint_group(),
+ "I do enjoy writing Rust.",
+ );
+}