Offline, privacy-first grammar checker. Fast, open-source, Rust-powered
feat(core): make `overnight` a special rule
Elijah Pottere4420cecfcaf
diff --git a/harper-core/src/linting/closed_compounds.rs b/harper-core/src/linting/closed_compounds.rsindex fd7e652f5..fb45c9aac 100644--- a/harper-core/src/linting/closed_compounds.rs+++ b/harper-core/src/linting/closed_compounds.rs@@ -89,7 +89,6 @@ create_closed_compound_linter!(Widespread, "wide spread", "widespread");create_closed_compound_linter!(Notwithstanding, "not with standing", "notwithstanding");create_closed_compound_linter!(Anyhow, "any how", "anyhow");create_closed_compound_linter!(Nonetheless, "none the less", "nonetheless");-create_closed_compound_linter!(Hereafter, "here after", "hereafter");create_closed_compound_linter!(Thereupon, "there upon", "thereupon");create_closed_compound_linter!(Forthwith, "forth with", "forthwith");create_closed_compound_linter!(Insofar, "in so far", "insofar");@@ -97,11 +96,12 @@ create_closed_compound_linter!(Whereupon, "where upon", "whereupon");create_closed_compound_linter!(Upward, "up ward", "upward");create_closed_compound_linter!(Henceforth, "hence forth", "henceforth");create_closed_compound_linter!(Regardless, "regard less", "regardless");+create_closed_compound_linter!(Overnight, "over night", "overnight");#[cfg(test)]mod tests {use super::{- Anyhow, Forthwith, Henceforth, Hereafter, Insofar, Nonetheless, Notwithstanding,+ Anyhow, Forthwith, Henceforth, Insofar, Nonetheless, Notwithstanding, Overnight,Regardless, Thereupon, Upward, Whereupon, Widespread,};use super::{@@ -200,13 +200,6 @@ mod tests {assert_suggestion_result(test_sentence, Nonetheless::default(), expected);}- #[test]- fn here_after() {- let test_sentence = "He promised to abide by the rules here after the meeting.";- let expected = "He promised to abide by the rules hereafter the meeting.";- assert_suggestion_result(test_sentence, Hereafter::default(), expected);- }-#[test]fn there_upon() {let test_sentence = "A decision was made there upon reviewing the data.";@@ -255,4 +248,11 @@ mod tests {let expected = "The decision was made, regardless of the opposition.";assert_suggestion_result(test_sentence, Regardless::default(), expected);}++ #[test]+ fn over_night() {+ let test_sentence = "They set off on their journey over night.";+ let expected = "They set off on their journey overnight.";+ assert_suggestion_result(test_sentence, Overnight::default(), expected);+ }}diff --git a/harper-core/src/linting/compound_nouns.rs b/harper-core/src/linting/compound_nouns.rsindex 7c7f6df9b..4ec73425e 100644--- a/harper-core/src/linting/compound_nouns.rs+++ b/harper-core/src/linting/compound_nouns.rs@@ -2,7 +2,9 @@ use std::sync::Arc;use itertools::Itertools;-use crate::{CharString, CharStringExt, Dictionary, Document, FstDictionary, Span, TokenStringExt};+use crate::{+ CharString, CharStringExt, Dictionary, Document, FstDictionary, Span, TokenKind, TokenStringExt,+};use super::{Lint, LintKind, Linter, Suggestion};@@ -38,7 +40,10 @@ impl CompoundNouns {span: Span::default(),lint_kind: LintKind::Spelling,suggestions: vec![Suggestion::ReplaceWith(buffer.to_vec())],- message: format!("Did you mean the closed compound “{}”?", buffer.to_string()),+ message: format!(+ "Did you mean the closed compound noun “{}”?",+ buffer.to_string()+ ),priority: 63,})} else {@@ -115,7 +120,7 @@ impl Linter for CompoundNouns {#[cfg(test)]mod tests {use super::CompoundNouns;- use crate::linting::tests::{assert_lint_count, assert_suggestion_result};+ use crate::linting::tests::assert_suggestion_result;#[test]fn lap_top() {@@ -316,13 +321,6 @@ mod tests {assert_suggestion_result(test_sentence, CompoundNouns::default(), expected);}- #[test]- fn over_night() {- let test_sentence = "They set off on their journey over night.";- let expected = "They set off on their journey overnight.";- assert_suggestion_result(test_sentence, CompoundNouns::default(), expected);- }-#[test]fn every_one() {let test_sentence = "Every one should have access to quality education.";diff --git a/harper-core/src/linting/lint_group.rs b/harper-core/src/linting/lint_group.rsindex 3a56567e7..f2b0e964b 100644--- a/harper-core/src/linting/lint_group.rs+++ b/harper-core/src/linting/lint_group.rs@@ -5,11 +5,12 @@ use super::an_a::AnA;use super::avoid_curses::AvoidCurses;use super::boring_words::BoringWords;use super::capitalize_personal_pronouns::CapitalizePersonalPronouns;+use super::closed_compounds::Overnight;use super::closed_compounds::{- Anybody, Anyhow, Anywhere, Backplane, Devops, Everywhere, Henceforth, Hereafter, However,- Insofar, Instead, Intact, Into, Itself, Middleware, Misunderstand, Misunderstood, Misuse,- Misused, Multicore, Multimedia, Multithreading, Myself, Nonetheless, Nothing, Notwithstanding,- Overall, Overclocking, Overload, Postpone, Proofread, Regardless, Somebody, Somehow, Somewhere,+ Anybody, Anyhow, Anywhere, Backplane, Devops, Everywhere, Henceforth, However, Insofar,+ Instead, Intact, Into, Itself, Middleware, Misunderstand, Misunderstood, Misuse, Misused,+ Multicore, Multimedia, Multithreading, Myself, Nonetheless, Nothing, Notwithstanding, Overall,+ Overclocking, Overload, Postpone, Proofread, Regardless, Somebody, Somehow, Somewhere,Therefore, Thereupon, Underclock, Upset, Upward, Whereupon, Widespread, Worldwide,};use super::compound_nouns::CompoundNouns;@@ -172,6 +173,7 @@ macro_rules! create_lint_group_config {}create_lint_group_config!(+ Overnight => true,Hereby => true,Likewise => true,CompoundNouns => true,@@ -181,7 +183,6 @@ create_lint_group_config!(Whereupon => true,Insofar => true,Thereupon => true,- Hereafter => true,Nonetheless => true,Anyhow => true,Notwithstanding => true,diff --git a/harper-core/src/linting/mod.rs b/harper-core/src/linting/mod.rsindex 463faad26..0907f067e 100644--- a/harper-core/src/linting/mod.rs+++ b/harper-core/src/linting/mod.rs@@ -53,11 +53,12 @@ pub use an_a::AnA;pub use avoid_curses::AvoidCurses;pub use boring_words::BoringWords;pub use capitalize_personal_pronouns::CapitalizePersonalPronouns;+pub use closed_compounds::Overnight;pub use closed_compounds::{- Anybody, Anyhow, Anywhere, Backplane, Devops, Everywhere, Henceforth, Hereafter, However,- Insofar, Instead, Intact, Into, Itself, Middleware, Misunderstand, Misunderstood, Misuse,- Misused, Multicore, Multimedia, Multithreading, Myself, Nonetheless, Nothing, Notwithstanding,- Overall, Overclocking, Overload, Postpone, Proofread, Regardless, Somebody, Somehow, Somewhere,+ Anybody, Anyhow, Anywhere, Backplane, Devops, Everywhere, Henceforth, However, Insofar,+ Instead, Intact, Into, Itself, Middleware, Misunderstand, Misunderstood, Misuse, Misused,+ Multicore, Multimedia, Multithreading, Myself, Nonetheless, Nothing, Notwithstanding, Overall,+ Overclocking, Overload, Postpone, Proofread, Regardless, Somebody, Somehow, Somewhere,Therefore, Thereupon, Underclock, Upset, Upward, Whereupon, Widespread, Worldwide,};pub use compound_nouns::CompoundNouns;