Automattic / Automattic/harper

bug: Missing Oxford commas are not identified in some contexts

Open
#659 4 comments 0 reactions 0 assignees View on GitHub
linting punctuation
Dominant language
Rust
Stars
15.4k
Forks
627
Avg merge
1d 15h
Merged PRs (30d)
106

Description

**Describe the bug**
Some missing Oxford commas are flagged, and others are not. I suspect the underlying grammar parsing.

**To Reproduce**
Steps to reproduce the behavior:
1. Copy and paste this text into an editor that supports Harper:
> A dog, a cat, and a pig.
> A bat, a rat, and a hog.
> A dog, a cat and a pig.
> A bat, a rat and a hog.
>
> The dog, the cat, and the pig.
> The bat, the rat, and the hog.
> The dog, the cat and the pig.
> The bat, the rat and the hog.
>
> Dogs, cats, and pigs.
> Bats, rats, and hogs.
> Dogs, cats and pigs.
> Bats, rats and hogs.
>
> One dog, one cat, and one pig.
> One bat, one rat, and one hog.
> One dog, one cat and one pig.
> One bat, one rat and one hog.
2. Notice that each group of four lines has two with Oxford commas then two without, with different nouns.
3. In line 3, see no squiggly under "cat" where there should be one.
4. In line 4, see a squiggly under the "and" instead of "rat".
5. See the same for lines 8 and 9.
6. See that both lines 13 and 14 get it right.
7. Then see the wrong behaviour returns for lines 18 and 19.

**Expected behavior**
Consistently applying squiggles under the cats and rats in every line without Oxford comma.

**Screenshots**
Image

**Platform**
VS Code, Windsurf

**Additional context**
More examples:
Image
Image

Cut and paste this text to test:

This dog, this cat, and this pig.
This bat, this rat, and this hog.
This dog, this cat and this pig.
This bat, this rat and this hog.

That dog, that cat, and that pig.
That bat, that rat, and that hog.
That dog, that cat and that pig.
That bat, that rat and that hog.

Some dog, some cat, and some pig.
Some bat, some rat, and some hog.
Some dog, some cat and some pig.
Some bat, some rat and some hog.

Some dogs, some cats, and some pigs.
Some bats, some rats, and some hogs.
Some dogs, some cats and some pigs.
Some bats, some rats and some hogs.

All dogs, all cats, and all pigs.
All bats, all rats, and all hogs.
All dogs, all cats and all pigs.
All bats, all rats and all hogs.

Big dogs, big cats, and big pigs.
Big bats, big rats, and big hogs.
Big dogs, big cats and big pigs.
Big bats, big rats and big hogs.

Several dogs, several cats, and several pigs.
Several bats, several rats, and several hogs.
Several dogs, several cats and several pigs.
Several bats, several rats and several hogs.

Enough dogs, enough cats, and enough pigs.
Enough bats, enough rats, and enough hogs.
Enough dogs, enough cats and enough pigs.
Enough bats, enough rats and enough hogs.

Plenty of dogs, plenty of cats, and plenty of pigs.
Plenty of bats, plenty of rats, and plenty of hogs.
Plenty of dogs, plenty of cats and plenty of pigs.
Plenty of bats, plenty of rats and plenty of hogs.

Another dog, another cat, and another pig.
Another bat, another rat, and another hog.
Another dog, another cat and another pig.
Another bat, another rat and another hog.

A few dogs, a few cats, and a few pigs.
A few bats, a few rats, and a few hogs.
A few dogs, a few cats and a few pigs.
A few bats, a few rats and a few hogs.

A lot of dogs, a lot of cats, and a lot of pigs.
A lot of bats, a lot of rats, and a lot of hogs.
A lot of dogs, a lot of cats and a lot of pigs.
A lot of bats, a lot of rats and a lot of hogs.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the listed Oxford-comma examples in a Harper-supported editor, then trace the grammar-parsing rule that handles these noun phrases. Add regression coverage for the cases that currently miss or misplace the squiggle, and verify that every line without an Oxford comma is flagged consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.