Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option to avoid fixing no-skip-test #324

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions docs/rules/no-skip-test.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,15 @@ test('bar', t => {
t.pass();
});
```

## Options

The rule takes the following options:

* `fix`: whether to fix violations (default true)

You can set the option in configuration like this:

```js
"ava/no-skip-test": ["error", { fix: false }]
```
31 changes: 23 additions & 8 deletions rules/no-skip-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ const createAvaRule = require('../create-ava-rule');
const util = require('../util');

const create = context => {
const [options] = context.options;
const {fix = true} = (options || {});
const ava = createAvaRule();

return ava.merge({
Expand All @@ -16,26 +18,39 @@ const create = context => {
context.report({
node: propertyNode,
message: 'No tests should be skipped.',
fix: fixer => {
return fixer.replaceTextRange.apply(null, util.removeTestModifier({
modifier: 'skip',
node,
context
}));
}
...(fix && {
fix: fixer => {
return fixer.replaceTextRange.apply(null, util.removeTestModifier({
modifier: 'skip',
node,
context
}));
}
})
});
}
})
});
};

const schema = [{
type: 'object',
properties: {
fix: {
type: 'boolean',
default: true
}
}
}];

module.exports = {
create,
meta: {
docs: {
url: util.getDocsUrl(__filename)
},
fixable: 'code',
type: 'suggestion'
type: 'suggestion',
schema
}
};
13 changes: 13 additions & 0 deletions test/no-skip-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@ ruleTester.run('no-skip-test', rule, {
column: 6
}]
},
{
code: header + 'test.skip(t => { t.pass(); });',
output: header + 'test.skip(t => { t.pass(); });',
options: [{
fix: false
}],
errors: [{
message,
type: 'Identifier',
line: 2,
column: 6
}]
},
{
code: header + 'test.cb.skip(t => { t.pass(); t.end(); });',
output: header + 'test.cb(t => { t.pass(); t.end(); });',
Expand Down