Skip to content

Latest commit

 

History

History
33 lines (22 loc) · 1.11 KB

prefer-output-null.md

File metadata and controls

33 lines (22 loc) · 1.11 KB

Disallow invalid RuleTester test cases where the output matches the code (prefer-output-null)

✔️ The "extends": "plugin:eslint-plugin/recommended" property in a configuration file enables this rule.

⚒️ The --fix option on the command line can automatically fix some of the problems reported by this rule.

Instead of repeating the test case code, using output: null is more concise and makes it easier to distinguish whether a test case provides an autofix.

Rule Details

The rule reports an error if it encounters a test case where the output is the same as the code.

Examples of incorrect code for this rule:

/* eslint eslint-plugin/prefer-output-null: error */

new RuleTester().run('foo', bar, {
  valid: [],
  invalid: [{ code: 'foo', output: 'foo', errors: [{ message: 'bar' }] }],
});

Examples of correct code for this rule:

/* eslint eslint-plugin/prefer-output-null: error */

new RuleTester().run('foo', bar, {
  valid: [],
  invalid: [{ code: 'foo', output: null, errors: [{ message: 'bar' }] }],
});