Skip to content

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

feat(core): rule for correcting "can't way" to "can't wait" (#3383)

Elijah Potter3b9ccfaceca8
diff --git a/harper-core/default_config.json b/harper-core/default_config.json
index 53390138f..320c3b82a 100644
--- a/harper-core/default_config.json
+++ b/harper-core/default_config.json
@@ -1519,6 +1519,13 @@
"label": "Blu Ray Hyphen"
}
},
+ {
+ "Bool": {
+ "name": "CantWay",
+ "state": true,
+ "label": "Cant Way"
+ }
+ },
{
"Bool": {
"name": "CaseSensitive",
diff --git a/harper-core/src/linting/modal_be_adjective.rs b/harper-core/src/linting/modal_be_adjective.rs
index 14862205e..afe068a71 100644
--- a/harper-core/src/linting/modal_be_adjective.rs
+++ b/harper-core/src/linting/modal_be_adjective.rs
@@ -29,6 +29,7 @@ impl Default for ModalBeAdjective {
&[
"backup", // adjective commonly misused as a verb
"likely", // adjective but with special usage
+ "way", // typo for "wait" in patterns like "can't way to"
] as &[_],
),
}
@@ -156,4 +157,12 @@ mod tests {
ModalBeAdjective::default(),
);
}
+
+ #[test]
+ fn ignore_cant_way() {
+ assert_no_lints(
+ "I can't way for something better to be released.",
+ ModalBeAdjective::default(),
+ );
+ }
}
diff --git a/harper-core/src/linting/weir_rules/CantWay.weir b/harper-core/src/linting/weir_rules/CantWay.weir
new file mode 100644
index 000000000..c15695fcd
--- /dev/null
+++ b/harper-core/src/linting/weir_rules/CantWay.weir
@@ -0,0 +1,36 @@
+expr waitToVerb [be, check, come, experience, get, go, have, hear, learn, meet, play, read, see, start, test, try, use, watch, work]
+expr cantAux [can't, cant, cannot, (can not), couldn't]
+expr doesntAux [doesn't, (does not)]
+
+expr main <([(@cantAux way to @waitToVerb), (@cantAux way [for, until]), (@doesntAux way [for, until])]), way>
+
+let message "Did you mean `wait`?"
+let description "Corrects `way` to `wait` in high-confidence contexts such as `can't way to` and `doesn't way for`."
+let kind "Typo"
+let becomes "wait"
+let strategy "MatchCase"
+
+# True positives
+test "I can't way for something better to be released." "I can't wait for something better to be released."
+test "It doesn't way until completion though." "It doesn't wait until completion though."
+test "Wow, incredible, can't way to try it." "Wow, incredible, can't wait to try it."
+test "Can't way to see things like this come into the project." "Can't wait to see things like this come into the project."
+test "saveTransactionToDb doesn't way for transactions to complete." "saveTransactionToDb doesn't wait for transactions to complete."
+test "If you can't way for 2.10.16, go back to 2.10.12." "If you can't wait for 2.10.16, go back to 2.10.12."
+test "Hehe I can't way for a bevel node to be available." "Hehe I can't wait for a bevel node to be available."
+test "I cannot way to hear the announcement." "I cannot wait to hear the announcement."
+test "We can not way until the migration finishes." "We can not wait until the migration finishes."
+test "They cant way to use the new editor." "They cant wait to use the new editor."
+test "She couldn't way for the build to finish." "She couldn't wait for the build to finish."
+test "The runner does not way for child processes." "The runner does not wait for child processes."
+
+# Guardrails / false positives
+allows "The RFC does not say to ignore it."
+allows "The RFC doesn't say what to do with it."
+allows "I tried create+modify below file but that doesn't work."
+allows "I can't say whether this is simply a way to modify the sleep time."
+allows "I cannot find a way to pass login information via a cookie."
+allows "I can't way to proxy the Strapi URL to the URL where Nuxt is running."
+allows "The potential gain doesn't weigh up against the pain."
+allows "The object doesn't weigh half a ton."
+allows "This is a real way to proxy the URL."