Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions harper-core/src/linting/missing_preposition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::expr::OwnedExprExt;
use crate::expr::SequenceExpr;
use crate::patterns::AnyPattern;
use crate::patterns::UPOSSet;
use crate::{Token, TokenStringExt};
use crate::{Token, TokenKind, TokenStringExt};

use super::{ExprLinter, Lint, LintKind};
use crate::linting::expr_linter::Chunk;
Expand All @@ -26,7 +26,10 @@ impl Default for MissingPreposition {
)
.then(UPOSSet::new(&[UPOS::NOUN, UPOS::PRON, UPOS::PROPN]))
.t_ws()
.then(UPOSSet::new(&[UPOS::AUX]))
// The missing-preposition construction is copular (subject + be-verb +
// adjective + object). Keep the original AUX constraint while excluding
// modal auxiliaries such as "can" and non-copular verbs such as "has".
.then_kind_both(|kind| kind.is_upos(UPOS::AUX), TokenKind::is_linking_verb)
.t_ws()
.then(UPOSSet::new(&[UPOS::ADJ]))
.t_ws()
Expand Down Expand Up @@ -146,4 +149,25 @@ mod tests {
MissingPreposition::default(),
);
}

#[test]
fn allows_issue_1585_public_examples() {
// See https://github.com/Automattic/harper/issues/1585
assert_no_lints(
"Once the installation is done, you can open your project folder.",
MissingPreposition::default(),
);
assert_no_lints(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Harper has always had a strong preference for one assert per test.

"It has several validation levels:",
MissingPreposition::default(),
);
assert_no_lints(
"You can close it if you prefer and if any of these show up again I'll reopen and for any new ones I'll open fresh issues.",
MissingPreposition::default(),
);
assert_no_lints(
"Her foot, that there was hardly room to open her mouth.",
MissingPreposition::default(),
);
}
}
Loading