diff --git a/docs/rules/no-skip-test.md b/docs/rules/no-skip-test.md index 57c41ee..32c4042 100644 --- a/docs/rules/no-skip-test.md +++ b/docs/rules/no-skip-test.md @@ -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 }] +``` diff --git a/rules/no-skip-test.js b/rules/no-skip-test.js index b32e0a7..f5bb945 100644 --- a/rules/no-skip-test.js +++ b/rules/no-skip-test.js @@ -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({ @@ -16,19 +18,31 @@ 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: { @@ -36,6 +50,7 @@ module.exports = { url: util.getDocsUrl(__filename) }, fixable: 'code', - type: 'suggestion' + type: 'suggestion', + schema } }; diff --git a/test/no-skip-test.js b/test/no-skip-test.js index f3de151..5dd257c 100644 --- a/test/no-skip-test.js +++ b/test/no-skip-test.js @@ -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(); });',