📝 Disallow the use of hooks from ancestor modules.
💼 This rule is enabled in the ✅ recommended config.
When a QUnit module is used with a nested callback, the callback provides a hooks
object as its first argument. This allows calling hooks.beforeEach and hooks.afterEach
within that callback's body.
More deeply nested module uses should use their own callback's provided hooks argument
and not one from an ancestor module.
The following patterns are considered warnings:
QUnit.module("outer module", function(hooks) {
QUnit.module("inner module", function() {
hooks.beforeEach(function() {});
});
});
QUnit.module("outer module", function(outerHooks) {
QUnit.module("inner module", function(innerHooks) {
outerHooks.beforeEach(function() {});
});
});The following patterns are not warnings:
QUnit.module("example module", function(hooks) {
hooks.beforeEach(function() {});
});
QUnit.module("outer module", function() {
QUnit.module("inner module", function(hooks) {
hooks.beforeEach(function() {});
});
});This rule may be safely disabled if you are working in a legacy codebase that will not migrate to QUnit 2.0.