no-skip-without-return

July 2, 2026 Β· View on GitHub

πŸ“ Disallow t.skip()/t.todo() without returning afterwards.

πŸ’ΌπŸš« This rule is enabled in the βœ… recommended config. This rule is disabled in the β˜‘οΈ unopinionated config.

πŸ’‘ This rule is manually fixable by editor suggestions.

t.skip() and t.todo() mark the test as skipped or todo, but they do not stop execution β€” any code after them still runs. From the Node.js docs: the call "does not terminate execution of the test function." So assertions placed after a conditional t.skip() run even when the test was meant to be skipped, often failing or causing side effects.

This rule reports a t.skip()/t.todo() call that is followed by reachable code. The suggestion inserts a return after it. Where a test should always be skipped, prefer the {skip: true} / {todo: true} option instead, which never runs the test body.

Examples

import test from 'node:test';

// ❌
test('x', t => {
	if (notReady) {
		t.skip('dependency unavailable');
	}

	assert.ok(compute()); // runs even when skipped
});

// βœ…
test('x', t => {
	if (notReady) {
		t.skip('dependency unavailable');
		return;
	}

	assert.ok(compute());
});

// βœ… (always skipped β€” body never runs)
test('x', {skip: 'dependency unavailable'}, t => {
	assert.ok(compute());
});