Skip to content

Commit

Permalink
Re-write DateNumbers
Browse files Browse the repository at this point in the history
Fixes #25.
  • Loading branch information
jdkato committed Oct 15, 2019
1 parent 7b2dcf1 commit 0470c19
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
35 changes: 34 additions & 1 deletion Microsoft/DateNumbers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,38 @@ message: "Don't use ordinal numbers for dates."
link: https://docs.microsoft.com/en-us/style-guide/numbers#numbers-in-dates
level: error
nonword: true
ignorecase: true
raw:
- \b(?:Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)|May|Jun(?:e)|Jul(?:y)|Aug(?:ust)|Sep(?:tember)?|Oct(?:ober)|Nov(?:ember)?|Dec(?:ember)?)\b\s*
tokens:
- '(?:Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)|May|Jun(?:e)|Jul(?:y)|Aug(?:ust)|Sep(?:tember)?|Oct(?:ober)|Nov(?:ember)?|Dec(?:ember)?) [a-z-]+\b'
- first
- second
- third
- fourth
- fifth
- sixth
- seventh
- eighth
- ninth
- tenth
- eleventh
- twelfth
- thirteenth
- fourteenth
- fifteenth
- sixteenth
- seventeenth
- eighteenth
- nineteenth
- twentieth
- twenty-first
- twenty-second
- twenty-third
- twenty-fourth
- twenty-fifth
- twenty-sixth
- twenty-seventh
- twenty-eighth
- twenty-ninth
- thirtieth
- thirty-first
3 changes: 2 additions & 1 deletion features/rules.feature
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,9 @@ Feature: Rules
Then the output should contain exactly:
"""
test.md:3:6:Microsoft.DateFormat:Use 'July 31, 2016' format, not '12 Mar 2016'.
test.md:5:18:Microsoft.DateNumbers:Don't use ordinal numbers for dates.
test.md:5:16:Microsoft.DateNumbers:Don't use ordinal numbers for dates.
test.md:7:14:Microsoft.DateOrder:Always spell out the name of the month.
test.md:13:7:Microsoft.DateNumbers:Don't use ordinal numbers for dates.
"""

Scenario: Use of punctuation
Expand Down
6 changes: 5 additions & 1 deletion fixtures/DateFormat/test.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@

It's 12 Mar 2016. This is okay: 15 and 2017

It happenened on October twenty-eighth.
It happened on October twenty-eighth.

For example, 6/12/2017 might be June 12, 2017 or December 6, 2017.

Users may see the following behavior.

The project started in May of 2013.

Is it June first?

0 comments on commit 0470c19

Please sign in to comment.