💼 This rule is enabled in the ✅ recommended
config.
🔧 This rule is automatically fixable by the --fix
CLI option.
Mocha testing framework provides a structured way of writing tests using functions like describe
, it
, before
, after
, beforeEach
, and afterEach
. As a convention, it is very common to add some spacing between these calls. It's unfortunately also quite common that this spacing is applied inconsistently.
Example:
describe('MyComponent', function () {
beforeEach(function () {
// setup code
});
it('should behave correctly', function () {
// test code
});
afterEach(function () {
// teardown code
});
});
In this example, there are no line breaks between Mocha function calls, making the code harder to read.
This rule enforces a line break between calls to Mocha functions (before, after, describe, it, beforeEach, afterEach) within describe blocks.
The following patterns are considered errors:
describe('MyComponent', function () {
beforeEach(function () {
// setup code
});
it('should behave correctly', function () {
// test code
});
});
These patterns would not be considered errors:
describe('MyComponent', function () {
beforeEach(function () {
// setup code
});
it('should behave correctly', function () {
// test code
});
afterEach(function () {
// teardown code
});
});
If you don't prefer this convention.