Skip to content

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

feat: flag "use to" when "used to" is intended (#2975)

Charlie Tonneslan79626413d310
diff --git a/harper-core/src/linting/phrase_set_corrections/mod.rs b/harper-core/src/linting/phrase_set_corrections/mod.rs
index e06035e7e..80578024c 100644
--- a/harper-core/src/linting/phrase_set_corrections/mod.rs
+++ b/harper-core/src/linting/phrase_set_corrections/mod.rs
@@ -570,6 +570,32 @@ pub fn lint_group() -> LintGroup {
"Ensures proper use of the subjunctive mood in counterfactual conditional statements starting with `if only` or `I wish`.",
LintKind::Grammar
),
+ "UseToUsedTo" => (
+ &[
+ // "be" verbs + "use to" -> "used to" (accustomed to)
+ ("am use to", "am used to"),
+ ("are use to", "are used to"),
+ ("is use to", "is used to"),
+ ("was use to", "was used to"),
+ ("were use to", "were used to"),
+ ("be use to", "be used to"),
+ // contractions of "be"
+ ("i'm use to", "i'm used to"),
+ ("we're use to", "we're used to"),
+ ("you're use to", "you're used to"),
+ ("they're use to", "they're used to"),
+ ("he's use to", "he's used to"),
+ ("she's use to", "she's used to"),
+ ("it's use to", "it's used to"),
+ // "get" forms + "use to" -> "used to" (becoming accustomed)
+ ("getting use to", "getting used to"),
+ ("get use to", "get used to"),
+ ("got use to", "got used to"),
+ ],
+ "The correct form is `used to`, not `use to`.",
+ "Corrects `use to` to `used to` when meaning accustomed to (after forms of `be` or `get`).",
+ LintKind::Grammar
+ ),
"WreakHavoc" => (
&[
("wreck havoc", "wreak havoc"),
diff --git a/harper-core/src/linting/phrase_set_corrections/tests.rs b/harper-core/src/linting/phrase_set_corrections/tests.rs
index afadeff3a..a31f55fa3 100644
--- a/harper-core/src/linting/phrase_set_corrections/tests.rs
+++ b/harper-core/src/linting/phrase_set_corrections/tests.rs
@@ -1834,6 +1834,45 @@ fn i_wish_it_was() {
);
}
+// UseToUsedTo
+
+#[test]
+fn corrects_getting_use_to() {
+ assert_suggestion_result(
+ "I'm getting use to it slowly.",
+ lint_group(),
+ "I'm getting used to it slowly.",
+ );
+}
+
+#[test]
+fn corrects_are_use_to() {
+ assert_suggestion_result(
+ "If you are use to Ubuntu, then the way sudo works should not be strange.",
+ lint_group(),
+ "If you are used to Ubuntu, then the way sudo works should not be strange.",
+ );
+}
+
+#[test]
+fn corrects_im_use_to() {
+ assert_suggestion_result(
+ "I'm use to doing a lot of work.",
+ lint_group(),
+ "I'm used to doing a lot of work.",
+ );
+}
+
+#[test]
+fn allows_use_to_as_verb() {
+ assert_no_lints("This is the editor I use to write code.", lint_group());
+}
+
+#[test]
+fn allows_used_to() {
+ assert_no_lints("I used to develop with objects in JS.", lint_group());
+}
+
// WreakHavoc
#[test]