Skip to content

Commit

Permalink
feat: add fixer to no-inline-assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung committed Jul 3, 2019
1 parent b07ccb5 commit 69144d8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
16 changes: 7 additions & 9 deletions rules/no-inline-assertions.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,6 @@ const {visitIf} = require('enhance-visitors');
const createAvaRule = require('../create-ava-rule');
const util = require('../util');

function report({node, context}) {
context.report({
node,
message: 'The test implementation should not be an inline arrow function.'
});
}

const create = context => {
const ava = createAvaRule();

Expand All @@ -31,7 +24,11 @@ const create = context => {

const {body} = functionArg;
if (body.type === 'CallExpression') {
report({node, context});
context.report({
node,
message: 'The test implementation should not be an inline arrow function.',
fix: fixer => [fixer.insertTextBefore(body, '{'), fixer.insertTextAfter(body, '}')]
});
}
})
});
Expand All @@ -43,6 +40,7 @@ module.exports = {
docs: {
url: util.getDocsUrl(__filename)
},
type: 'suggestion'
type: 'suggestion',
fixable: 'code'
}
};
9 changes: 6 additions & 3 deletions test/no-inline-assertions.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,18 @@ ruleTester.run('no-todo-test', rule, {
invalid: [
{
code: header + 'test("my test name", t => t.skip());',
errors
errors,
output: header + 'test("my test name", t => {t.skip()});'
},
{
code: header + 'test("my test name", t => t.true(fn()));',
errors
errors,
output: header + 'test("my test name", t => {t.true(fn())});'
},
{
code: header + 'test("my test name", t => \n t.true(fn()));',
errors
errors,
output: header + 'test("my test name", t => \n {t.true(fn())});'
}
]
});

0 comments on commit 69144d8

Please sign in to comment.