Skip to content

Commit

Permalink
Merge pull request #445 from Automattic/nor-oxford-comma
Browse files Browse the repository at this point in the history
fix(core): the Oxford comma applies to `nor` as well
  • Loading branch information
elijah-potter authored Jan 22, 2025
2 parents 9966d2a + 39b7fa0 commit 280aaea
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions harper-core/src/linting/oxford_comma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ impl OxfordComma {
))
.then_noun_phrase()
.then_whitespace()
.then(Box::new(WordSet::all(&["and", "or"])))
.then(Box::new(WordSet::all(&["and", "or", "nor"])))
.then_whitespace()
.then_noun_phrase(),
}
Expand Down Expand Up @@ -81,7 +81,7 @@ impl Linter for OxfordComma {
}

fn description(&self) -> &str {
"The Oxford comma is one of the more controversial rules in common use today. Enabling this lint checks that there is a comma before `and` or `or` when listing out more than two ideas."
"The Oxford comma is one of the more controversial rules in common use today. Enabling this lint checks that there is a comma before `and`, `or`, or `nor` when listing out more than two ideas."
}
}

Expand Down Expand Up @@ -150,4 +150,13 @@ mod tests {
"They enjoy playing soccer, basketball, or tennis.",
);
}

#[test]
fn nor_vegetables() {
assert_suggestion_result(
"I like carrots, kale nor broccoli.",
OxfordComma::default(),
"I like carrots, kale, nor broccoli.",
);
}
}

0 comments on commit 280aaea

Please sign in to comment.