Skip to content

Commit 2fe92b7

Browse files
authored
Docs: elaborate on output assertion requirement and benefits in consistent-output rule doc (#123)
1 parent 72fc89d commit 2fe92b7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

docs/rules/consistent-output.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
When writing tests for a fixable rule with `RuleTester`, you can assert the autofix output of your test cases. However, it can be easy to forget to assert the output of a particular test case.
44

5+
[As of ESLint 7](https://eslint.org/docs/user-guide/migrating-to-7.0.0#additional-validation-added-to-the-ruletester-class), test cases that trigger an autofix are required to provide the `output` property.
6+
7+
Even test that do not trigger an autofix can benefit from asserting that they have no autofix using `output: null`.
8+
59
## Rule Details
610

711
This rule aims to ensure that if any invalid test cases have output assertions, then all test cases have output assertions.
@@ -48,7 +52,7 @@ new RuleTester().run('example-rule', rule, {
4852
},
4953
{
5054
code: 'foo',
51-
output: null,
55+
output: null, // asserts that there is no autofix
5256
errors: ['baz']
5357
}
5458
]

0 commit comments

Comments
 (0)