Oxford Comma Detection

This rule checks for lists of items where the Oxford comma (also known as the serial comma) might be missing. The Oxford comma is the final comma that comes before "and" in a list of three or more items. Using the Oxford comma helps prevent ambiguity and ensures clarity in your writing.

The rule specifically searches for patterns where there is at least one comma followed by a word, then "and" without a comma in between. This pattern often indicates a missing Oxford comma.

Examples:

Will flag:

  • "I like apples, bananas and oranges"
  • "The company focuses on software development, cloud services and consulting"
  • "We need paper, pens, notebooks and staplers"

Won't flag:

  • "I like apples, bananas, and oranges"
  • "The company focuses on software development, cloud services, and consulting"
  • "I like cats and dogs" (only two items)

The rule helps maintain consistency with style guides like Microsoft's that recommend using the Oxford comma to prevent misinterpretation and enhance readability.

Rule Source

This rule comes from: https://github.com/mesosphere/dcos-docs-site

Rule Definition

extends: existence
message: "Use the Oxford comma in '%s'."
link: https://docs.microsoft.com/en-us/style-guide/punctuation/commas
scope: sentence
level: warning
tokens:
  - '(?:[^,]+,){1,}\s\w+\sand'