Skip to content

Commit 0470c19

Browse files
committed
Re-write DateNumbers
Fixes #25.
1 parent 7b2dcf1 commit 0470c19

File tree

3 files changed

+41
-3
lines changed

3 files changed

+41
-3
lines changed

Microsoft/DateNumbers.yml

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,38 @@ message: "Don't use ordinal numbers for dates."
33
link: https://docs.microsoft.com/en-us/style-guide/numbers#numbers-in-dates
44
level: error
55
nonword: true
6+
ignorecase: true
7+
raw:
8+
- \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*
69
tokens:
7-
- '(?: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'
10+
- first
11+
- second
12+
- third
13+
- fourth
14+
- fifth
15+
- sixth
16+
- seventh
17+
- eighth
18+
- ninth
19+
- tenth
20+
- eleventh
21+
- twelfth
22+
- thirteenth
23+
- fourteenth
24+
- fifteenth
25+
- sixteenth
26+
- seventeenth
27+
- eighteenth
28+
- nineteenth
29+
- twentieth
30+
- twenty-first
31+
- twenty-second
32+
- twenty-third
33+
- twenty-fourth
34+
- twenty-fifth
35+
- twenty-sixth
36+
- twenty-seventh
37+
- twenty-eighth
38+
- twenty-ninth
39+
- thirtieth
40+
- thirty-first

features/rules.feature

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,9 @@ Feature: Rules
119119
Then the output should contain exactly:
120120
"""
121121
test.md:3:6:Microsoft.DateFormat:Use 'July 31, 2016' format, not '12 Mar 2016'.
122-
test.md:5:18:Microsoft.DateNumbers:Don't use ordinal numbers for dates.
122+
test.md:5:16:Microsoft.DateNumbers:Don't use ordinal numbers for dates.
123123
test.md:7:14:Microsoft.DateOrder:Always spell out the name of the month.
124+
test.md:13:7:Microsoft.DateNumbers:Don't use ordinal numbers for dates.
124125
"""
125126

126127
Scenario: Use of punctuation

fixtures/DateFormat/test.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22

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

5-
It happenened on October twenty-eighth.
5+
It happened on October twenty-eighth.
66

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

99
Users may see the following behavior.
10+
11+
The project started in May of 2013.
12+
13+
Is it June first?

0 commit comments

Comments
 (0)