Skip to content

Commit

Permalink
Add more info to messages
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Jun 6, 2019
1 parent 3605264 commit 1099830
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
7 changes: 4 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ var patterns = require('./list')

module.exports = passive

var source = 'retext-passive'

var verbs = ['am', 'are', 'were', 'being', 'is', 'been', 'was', 'be']

function passive(options) {
Expand Down Expand Up @@ -41,12 +43,11 @@ function passive(options) {
start: position.start(match[0]),
end: position.end(match[match.length - 1])
},
phrase.replace(/\s+/g, '-').toLowerCase()
[source, phrase.replace(/\s+/g, '-').toLowerCase()].join(':')
)

message.source = 'retext-passive'
message.actual = toString(match)
message.expected = null
message.expected = []
}
}
}
23 changes: 22 additions & 1 deletion test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var retext = require('retext')
var passive = require('.')

test('passive', function(t) {
t.plan(2)
t.plan(3)

var doc = [
'He was withheld while we were being fed.',
Expand All @@ -27,6 +27,27 @@ test('passive', function(t) {
],
'should work'
)

t.deepEqual(
file.messages[0],
{
message: 'Don’t use the passive voice',
name: '1:8-1:16',
reason: 'Don’t use the passive voice',
line: 1,
column: 8,
location: {
start: {line: 1, column: 8, offset: 7},
end: {line: 1, column: 16, offset: 15}
},
source: 'retext-passive',
ruleId: 'withheld',
fatal: false,
actual: 'withheld',
expected: []
},
'should emit messages'
)
})

retext()
Expand Down

0 comments on commit 1099830

Please sign in to comment.