Skip to content

Commit

Permalink
Change to improve message
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Sep 8, 2023
1 parent 0803bf2 commit 57c5f10
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 27 deletions.
3 changes: 2 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ export default function retextPassive(options) {
const start = pointStart(match[0])
const end = pointEnd(match[match.length - 1])

const message = file.message('Don’t use the passive voice', {
const message = file.message('Unexpected use of the passive voice', {
ancestors: [parent],
/* c8 ignore next -- hard to test */
place: start && end ? {start, end} : undefined,
source: 'retext-passive',
Expand Down
52 changes: 26 additions & 26 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,34 @@ test('retext-passive', async function (t) {
const file = await retext().use(retextPassive).process(doc)

await t.test('should emit a message w/ metadata', async function () {
assert.deepEqual(JSON.parse(JSON.stringify(file.messages[0])), {
column: 8,
fatal: false,
message: 'Don’t use the passive voice',
line: 1,
name: '1:8-1:16',
place: {
start: {line: 1, column: 8, offset: 7},
end: {line: 1, column: 16, offset: 15}
},
reason: 'Don’t use the passive voice',
ruleId: 'withheld',
source: 'retext-passive',
actual: 'withheld',
expected: [],
url: 'https://github.com/retextjs/retext-passive#readme'
})
assert.deepEqual(
JSON.parse(JSON.stringify({...file.messages[0], ancestors: []})),
{
ancestors: [],
column: 8,
fatal: false,
message: 'Unexpected use of the passive voice',
line: 1,
name: '1:8-1:16',
place: {
start: {line: 1, column: 8, offset: 7},
end: {line: 1, column: 16, offset: 15}
},
reason: 'Unexpected use of the passive voice',
ruleId: 'withheld',
source: 'retext-passive',
actual: 'withheld',
expected: [],
url: 'https://github.com/retextjs/retext-passive#readme'
}
)
})

await t.test('should emit messasges', async function () {
assert.deepEqual(
file.messages.map(String),
[
'1:8-1:16: Don’t use the passive voice',
'1:37-1:40: Don’t use the passive voice'
],
'should work'
)
assert.deepEqual(file.messages.map(String), [
'1:8-1:16: Unexpected use of the passive voice',
'1:37-1:40: Unexpected use of the passive voice'
])
})

await t.test('should `ignore`', async function () {
Expand All @@ -50,7 +50,7 @@ test('retext-passive', async function (t) {
.process(doc)

assert.deepEqual(file.messages.map(String), [
'1:8-1:16: Don’t use the passive voice'
'1:8-1:16: Unexpected use of the passive voice'
])
})
})

0 comments on commit 57c5f10

Please sign in to comment.