Skip to content

Commit

Permalink
Remove support for decades
Browse files Browse the repository at this point in the history
…apostrophes in numbers aren’t always decades, so the previous support
caused false-positives.

Closes GH-7.
  • Loading branch information
wooorm committed Jun 8, 2019
1 parent 3ff0bc0 commit 003f7a1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
9 changes: 1 addition & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ var straightId = 'smart-apostrophe'
var smartId = 'straight-apostrophe'

// Regex to match an elided decade.
var decadeExpression = /^\d\ds$/
var apostropheExpression = /['’]/g
var apostrophe = "'"
var rightSingleQuotationMark = '’'

var own = {}.hasOwnProperty
Expand All @@ -40,15 +38,10 @@ function contractions(options) {
var expected
var message

// Suggest if either the straightened version is listed, or if this is a
// decade (80’s and 80s > ’80s).
// Suggest if the straightened version is listed.
if (own.call(data, normal)) {
expected = data[normal]
} else if (decadeExpression.test(normal)) {
expected = apostrophe + normal
}

if (expected) {
if (!straight) {
expected = smarten(expected)
}
Expand Down
7 changes: 2 additions & 5 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,8 @@ test('contractions(value)', function(t) {
['It was acceptable in the 80s, I mean 80’s, no wait?'].join('\n')
)
.messages.map(String),
[
'1:26-1:29: Expected an apostrophe in `80s`, like this: `’80s`',
'1:38-1:42: Expected the apostrophe in `80’s` to be like this: `’80s`'
],
'should catch decades'
[],
'should ignore decades (GH-7)'
)

t.deepEqual(
Expand Down

0 comments on commit 003f7a1

Please sign in to comment.