Skip to content

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

fix(core): fix problems with the `NeedToNoun` rule (#2287)

Elijah Potterfc87bd518bb9
diff --git a/harper-core/dictionary.dict b/harper-core/dictionary.dict
index 2efc39a36..5580d5f4d 100644
--- a/harper-core/dictionary.dict
+++ b/harper-core/dictionary.dict
@@ -36986,7 +36986,7 @@ overcharge/VdGSNg
overclock/VGdSN
overcloud/VSGd
overcoat/NgSV
-overcome/~VGSN
+overcome/~VGS
overcompensate/VdSGn
overcompensation/Nmg
overconfidence/Nmg
diff --git a/harper-core/src/linting/need_to_noun.rs b/harper-core/src/linting/need_to_noun.rs
index b7eb9a84c..779777654 100644
--- a/harper-core/src/linting/need_to_noun.rs
+++ b/harper-core/src/linting/need_to_noun.rs
@@ -18,8 +18,13 @@ pub struct NeedToNoun {
impl Default for NeedToNoun {
fn default() -> Self {
let postfix_exceptions = LongestMatchOf::new(vec![
- Box::new(|tok: &Token, _: &[char]| tok.kind.is_adverb() || tok.kind.is_determiner()),
- Box::new(WordSet::new(&["about"])),
+ Box::new(|tok: &Token, _: &[char]| {
+ tok.kind.is_adverb()
+ || tok.kind.is_determiner()
+ || tok.kind.is_unlintable()
+ || tok.kind.is_pronoun()
+ }),
+ Box::new(WordSet::new(&["about", "it"])),
]);
let exceptions = SequenceExpr::default()
@@ -421,4 +426,28 @@ mod tests {
fn allows_issue_2252() {
assert_no_lints("Things I need to do today:", NeedToNoun::default());
}
+
+ #[test]
+ fn allows_install() {
+ assert_no_lints(
+ "You need to install it separately, as it's a standalone application.",
+ NeedToNoun::default(),
+ );
+ }
+
+ #[test]
+ fn allows_lay() {
+ assert_no_lints(
+ "Okay, this is a long one, but I feel like I need to lay everything out.",
+ NeedToNoun::default(),
+ );
+ }
+
+ #[test]
+ fn allows_overcome() {
+ assert_no_lints(
+ "We believe every family deserves the opportunity to flourish, and we are committed to providing the resources they need to overcome adversity.",
+ NeedToNoun::default(),
+ );
+ }
}
diff --git a/harper-core/tests/run_tests.rs b/harper-core/tests/run_tests.rs
index 56bc279e0..1bf1627e5 100644
--- a/harper-core/tests/run_tests.rs
+++ b/harper-core/tests/run_tests.rs
@@ -94,6 +94,7 @@ create_test!(issue_2054_clean.md, 0, Dialect::British);
create_test!(issue_1873.md, 0, Dialect::British);
create_test!(issue_2246.md, 0, Dialect::American);
create_test!(issue_2233.md, 0, Dialect::American);
+create_test!(issue_2240.md, 0, Dialect::American);
// It just matters that it is > 1
create_test!(issue_2151.md, 4, Dialect::British);
diff --git a/harper-core/tests/test_sources/issue_2240.md b/harper-core/tests/test_sources/issue_2240.md
new file mode 100644
index 000000000..599f9575e
--- /dev/null
+++ b/harper-core/tests/test_sources/issue_2240.md
@@ -0,0 +1 @@
+There is no more need to run `git`.
diff --git a/harper-core/tests/text/tagged/Alice's Adventures in Wonderland.md b/harper-core/tests/text/tagged/Alice's Adventures in Wonderland.md
index 0bd253b71..5e48171db 100644
--- a/harper-core/tests/text/tagged/Alice's Adventures in Wonderland.md
+++ b/harper-core/tests/text/tagged/Alice's Adventures in Wonderland.md
@@ -5543,7 +5543,7 @@
> work very diligently to write out a history of the accident , all except the
# N🅪Sg/VB J/R R P NSg/VB NSg/VB/J/R/P D/P N🅪Sg P D NSg/J+ . NSg/I/J/C/Dq VB/C/P D
> Lizard , who seemed too much overcome to do anything but sit with its mouth open ,
-# NSg . NPr/I+ VP/J R NSg/I/J/R/Dq NSg/VB P VXB NSg/I/VB+ NSg/C/P NSg/VB P ISg/D$+ NSg/VB+ NSg/VB/J .
+# NSg . NPr/I+ VP/J R NSg/I/J/R/Dq VB P VXB NSg/I/VB+ NSg/C/P NSg/VB P ISg/D$+ NSg/VB+ NSg/VB/J .
> gazing up into the roof of the court .
# Nᴹ/Vg/J NSg/VB/J/P P D NSg/VB P D N🅪Sg/VB/J+ .
>
diff --git a/harper-core/tests/text/tagged/Difficult sentences.md b/harper-core/tests/text/tagged/Difficult sentences.md
index 5784b2e2c..b336333af 100644
--- a/harper-core/tests/text/tagged/Difficult sentences.md
+++ b/harper-core/tests/text/tagged/Difficult sentences.md
@@ -919,7 +919,7 @@
> The sailors were infected with malaria .
# D+ NPl+ NSg/VPt NSg/VP/J P Nᴹ+ .
> overcome with happiness
-# NSg/VB P Nᴹ+
+# VB P Nᴹ+
> green with envy ; flushed with success
# NPr🅪Sg/VB/J P NSg/VB+ . VP/J P N🅪Sg+
> She was with Acme for twenty years before retiring last fall .