Ordinal Numbers as Words

Description

This rule enforces the spelling out of ordinal numbers in text instead of using their numeric form. This practice enhances readability and maintains a more formal, professional tone in documentation. Writing ordinal numbers as words is particularly important in technical documentation as it reduces potential confusion and follows common style guide recommendations, including Google's Developer Documentation Style Guide.

Examples

This rule flags ordinal numbers written in numeric form with their suffixes. Here are some examples:

Flagged (incorrect):

  • 1st (should be "first")
  • 2nd (should be "second")
  • 3rd (should be "third")
  • 4th (should be "fourth")
  • 21st (should be "twenty-first")

Correct usage:

  • first
  • second
  • third
  • fourth
  • twenty-first

The rule uses a regular expression pattern (\d+(?:st|nd|rd|th)) to identify any number followed by ordinal suffixes (st, nd, rd, th) and flags them as errors.

Rule Source

This rule comes from: https://github.com/jump-dev/JuMP.jl

Rule Definition

extends: existence
message: "Spell out all ordinal numbers ('%s') in text."
link: 'https://developers.google.com/style/numbers'
level: error
nonword: true
tokens:
  - \d+(?:st|nd|rd|th)