Offline, privacy-first grammar checker. Fast, open-source, Rust-powered
feat: I didn't realize passenger drones were already here! (#3636)
Andrew Dunbar500b1f80b299
diff --git a/harper-core/default_config.json b/harper-core/default_config.jsonindex 9f50385ec..c69e2a291 100644--- a/harper-core/default_config.json+++ b/harper-core/default_config.json@@ -5109,6 +5109,13 @@"state": true,"label": "As How"}+ },+ {+ "Bool": {+ "name": "LeavingInDroves",+ "state": true,+ "label": "Leaving In Droves"+ }}]}diff --git a/harper-core/src/linting/leaving_in_droves.rs b/harper-core/src/linting/leaving_in_droves.rsnew file mode 100644index 000000000..f9684fa57--- /dev/null+++ b/harper-core/src/linting/leaving_in_droves.rs@@ -0,0 +1,100 @@+use crate::{+ Lint, Token,+ expr::{Expr, SequenceExpr},+ linting::{ExprLinter, LintKind, Suggestion, expr_linter::Chunk},+};++pub struct LeavingInDroves {+ expr: SequenceExpr,+}++impl Default for LeavingInDroves {+ fn default() -> Self {+ Self {+ expr: SequenceExpr::word_set(&["leave", "leaves", "leaving", "left"])+ .t_ws()+ .t_aco("in")+ .t_ws()+ .t_aco("drones"),+ }+ }+}++impl ExprLinter for LeavingInDroves {+ type Unit = Chunk;++ fn match_to_lint(&self, toks: &[Token], _src: &[char]) -> Option<Lint> {+ let span = toks.last()?.span;++ Some(Lint {+ span,+ lint_kind: LintKind::Eggcorn,+ suggestions: vec![Suggestion::replace_with_match_case_str(+ "droves",+ span.get_content(_src),+ )],+ message: "`Drones` is an eggcorn. The correct word is `droves`.".to_owned(),+ ..Default::default()+ })+ }++ fn expr(&self) -> &dyn Expr {+ &self.expr+ }++ fn description(&self) -> &str {+ "Corrects `leaving in drones` to `leaving in droves`."+ }+}++#[cfg(test)]+mod tests {+ use crate::linting::tests::assert_suggestion_result;++ use super::LeavingInDroves;++ #[test]+ fn jobs() {+ assert_suggestion_result(+ "Jobs are leaving in drones out of the country.",+ LeavingInDroves::default(),+ "Jobs are leaving in droves out of the country.",+ );+ }++ #[test]+ fn wealthy() {+ assert_suggestion_result(+ "Yet they are amongst some of the loudest promoters of the notion that the wealthy will leave in drones.",+ LeavingInDroves::default(),+ "Yet they are amongst some of the loudest promoters of the notion that the wealthy will leave in droves.",+ );+ }++ #[test]+ fn employees() {+ assert_suggestion_result(+ "consider the damage that will be caused when employees start leaving in drones as if we didn't have enough people leave already in the past 2 years.",+ LeavingInDroves::default(),+ "consider the damage that will be caused when employees start leaving in droves as if we didn't have enough people leave already in the past 2 years.",+ );+ }++ #[test]+ fn pastors() {+ assert_suggestion_result(+ "Why Are Nigerian Pastors Leaving In Drones?",+ LeavingInDroves::default(),+ "Why Are Nigerian Pastors Leaving In Droves?",+ );+ }++ #[test]+ fn left() {+ assert_suggestion_result(+ "I have remained at the place while my coworkers have left in drones.",+ LeavingInDroves::default(),+ "I have remained at the place while my coworkers have left in droves.",+ );+ }+}diff --git a/harper-core/src/linting/lint_group/mod.rs b/harper-core/src/linting/lint_group/mod.rsindex dc1bb6531..f7c8fe0c7 100644--- a/harper-core/src/linting/lint_group/mod.rs+++ b/harper-core/src/linting/lint_group/mod.rs@@ -122,6 +122,7 @@ use super::its_possessive::ItsPossessive;use super::jealous_of::JealousOf;use super::johns_hopkins::JohnsHopkins;use super::lead_rise_to::LeadRiseTo;+use super::leaving_in_droves::LeavingInDroves;use super::left_right_hand::LeftRightHand;use super::less_worse::LessWorse;use super::let_to_do::LetToDo;@@ -685,6 +686,7 @@ impl LintGroup {insert_expr_rule!(JealousOf, true);insert_expr_rule!(JohnsHopkins, true);insert_expr_rule!(LeadRiseTo, true);+ insert_expr_rule!(LeavingInDroves, true);insert_expr_rule!(LeftRightHand, true);insert_expr_rule!(LessWorse, true);insert_expr_rule!(LetToDo, true);diff --git a/harper-core/src/linting/mod.rs b/harper-core/src/linting/mod.rsindex e3cd64810..d95e902ac 100644--- a/harper-core/src/linting/mod.rs+++ b/harper-core/src/linting/mod.rs@@ -124,6 +124,7 @@ mod its_possessive;mod jealous_of;mod johns_hopkins;mod lead_rise_to;+mod leaving_in_droves;mod left_right_hand;mod less_worse;mod let_to_do;