Skip to content

fix(harper-core): keep possessive its unflagged after prepositions - #4437

Merged
elijah-potter merged 3 commits into
Automattic:masterfrom
Punisheroot:fix/js/its-contraction-preposition
Sep 30, 2026
Merged

elijah-potter merged 3 commits into
Automattic:masterfrom
Punisheroot:fix/js/its-contraction-preposition

Conversation

@Punisheroot

Copy link
Copy Markdown
Contributor

AI disclosure: tests were drafted with AI assistance; implementation and checks were done and verified by me.

Fixes

Fixes #4435

ItsContraction flagged its before a gerund (e.g. in its reading) because the gerund is tagged as a verb and the following word is neither a noun nor an auxiliary.

This is a false positive: after a preposition, its is possessive in it's reading is not valid English.

Changes

  • harper-core/src/linting/its_contraction/general.rs: skip the lint when the possessive is introduced by a preposition, via new is_preposition helper. True positives like its been, its got, its had remain flagged.
  • harper-core/src/linting/its_contraction/mod.rs: added 2 regression tests.

Testing

  • cargo test -p harper-core → 6564 passed, 0 failed
  • cargo test -p harper-core its_contraction → 58 passed
  • cargo fmt --check clean
  • Manual CLI check: the reported in its reading case no longer produces a lint, while Its been months since we spoke. still does.

`ItsContraction` flagged phrases like "in its reading" when the gerund was
tagged as a verb and the following word was neither a noun nor an auxiliary.
A possessive `its` introduced by a preposition is part of a noun phrase, so
skip the lint in that context while keeping strong predicative verbs such as
"its been" and "its got" flagged.

Fixes Automattic#4435
@Punisheroot Punisheroot reopened this Sep 21, 2026
@Punisheroot
Punisheroot marked this pull request as ready for review September 21, 2026 13:41
Comment on lines +261 to +281
fn is_preposition(word: &str) -> bool {
matches!(
word,
"at" | "by"
| "for"
| "from"
| "in"
| "into"
| "of"
| "on"
| "onto"
| "over"
| "through"
| "to"
| "under"
| "upon"
| "with"
| "within"
| "without"
)
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You should be able to perform this check with functions that already exist in core. Try maybe using is_upos or check the word metadata.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

addressed in 04b92a7

@elijah-potter elijah-potter left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good. Thanks!

@elijah-potter
elijah-potter added this pull request to the merge queue Sep 30, 2026
Merged via the queue into Automattic:master with commit 0759a1b Sep 30, 2026
13 checks passed
jvoisin pushed a commit to jvoisin/harper that referenced this pull request Oct 17, 2026
…utomattic#4437)

* fix(harper-core): keep possessive "its" unflagged after prepositions

`ItsContraction` flagged phrases like "in its reading" when the gerund was
tagged as a verb and the following word was neither a noun nor an auxiliary.
A possessive `its` introduced by a preposition is part of a noun phrase, so
skip the lint in that context while keeping strong predicative verbs such as
"its been" and "its got" flagged.

Fixes Automattic#4435

* fix(core): use token metadata for its preposition check

---------

Co-authored-by: Elijah Potter <me@elijahpotter.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

False positive: ItsContraction

3 participants