Skip to content

fix(core): the Oxford comma applies to nor as well #445

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 22, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.",
);
}
}
Loading