Skip to content

Commit a3c80f2

Browse files
committed
feat(rule): trigger oxford comma rule on clauses
1 parent f366393 commit a3c80f2

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

Prim/OxfordComma.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ level: suggestion
44
scope: sentence
55
nonword: true
66
tokens:
7-
- '\w+(?:,\s*\w+){1,} (?:and|or) \w+[.?!]'
7+
- '\b[\w\s]+?(?:,\s*[\w\s]+){1,}\s+(?:and|or)\s+[\w\s]+[.?!]?'

test/fixtures/OxfordComma/test.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
# Oxford Comma
22

3+
<!-- ❌ trigger on the missing comma before and/or for listing three or more items -->
34
The ingredients for the recipe included flour, sugar, eggs and butter.
4-
<!-- He enjoys reading, playing the guitar and hiking in his free time. -->
5-
Should I unpack my clothes, toiletries or books?
6-
<!-- You can choose to visit the museum, go hiking or relax at home. -->
5+
Should I first unpack my clothes, toiletries or books?
6+
7+
<!-- ❌ trigger on the missing comma before and/or for listing three or more clauses -->
8+
He enjoys reading, playing the guitar and hiking in his free time.
9+
You can choose to visit the museum, go hiking or relax at home.
10+
Why don't you try out fishing on the lake, taking a hike, reading on the beach or just lazing around?
11+
12+
<!-- ✅ ignore on the use of two items around and/or -->
13+
The improvements come in bits and pieces.
14+
You can choose to go fast or go smoothly.

test/snapshots/OxfordComma.log

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1-
test.md:3:41:Prim.OxfordComma:Use the Oxford comma in 'flour, sugar, eggs and butter.'.
2-
test.md:5:20:Prim.OxfordComma:Use the Oxford comma in 'clothes, toiletries or books?'.
1+
test.md:4:1:Prim.OxfordComma:Use the Oxford comma in 'The ingredients for the recipe included flour, sugar, eggs and butter.'.
2+
test.md:5:1:Prim.OxfordComma:Use the Oxford comma in 'Should I first unpack my clothes, toiletries or books?'.
3+
test.md:8:1:Prim.OxfordComma:Use the Oxford comma in 'He enjoys reading, playing the guitar and hiking in his free time.'.
4+
test.md:9:1:Prim.OxfordComma:Use the Oxford comma in 'You can choose to visit the museum, go hiking or relax at home.'.
5+
test.md:10:9:Prim.OxfordComma:Use the Oxford comma in 't you try out fishing on the lake, taking a hike, reading on the beach or just lazing around?'.

0 commit comments

Comments
 (0)