harper-core: flag 'few' in more time contexts#2660
Open
LouisLau-art wants to merge 1 commit intoAutomattic:masterfrom
Open
harper-core: flag 'few' in more time contexts#2660LouisLau-art wants to merge 1 commit intoAutomattic:masterfrom
LouisLau-art wants to merge 1 commit intoAutomattic:masterfrom
Conversation
hippietrail
reviewed
Feb 5, 2026
Collaborator
hippietrail
left a comment
There was a problem hiding this comment.
So cool to see someone working on this! I made the original few_units_of_time_ago linter before I added match_to_lint_with_context()
| | "your" | ||
| | "his" | ||
| | "her" | ||
| | "their" |
Collaborator
There was a problem hiding this comment.
See if .is_determiner() on TokenKind works here.
| // inserting an article would be incorrect. | ||
| if matches!( | ||
| prev_word.as_deref(), | ||
| Some("too" | "very" | "so" | "quite" | "how") |
Collaborator
There was a problem hiding this comment.
See if .is_degree_adverb() on TokenKind works here.
Collaborator
There was a problem hiding this comment.
I think this PR is close, but I am also interested if that method would work instead. @LouisLau-art, would you give it whirl?
Author
|
Thanks for the context — really appreciate you building the original linter! I used the existing behavior as a baseline and tried to keep the new context checks minimal + well-covered by tests. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1114.
What changed
FewUnitsOfTimeAgorule from only matchingfew <time unit> agoto matchingfew <time unit>and then using surrounding context to decide whether it should be corrected toa few.After few minutes ...andFew minutes after ....Heuristics (intentionally conservative)
Triggers when
few <time unit>is followed byago/after/before/lateror preceded byafter/before/in/within/for/since.Skips when it already has an article (
a/an/the) or whenfewis clearly negative (too/very/so/quite/how few).Tests
after few minutes/few minutes after.the few ...,too few ...,past few ...).