Skip to content

assertStyles

Prefer assert.ok() over assert() for explicit intent and better readability.

✅ This rule is included in the node stylistic preset.

Using assert.ok() aligns with other assert methods, ensuring consistency and making code easier to maintain and understand. The explicit method call clarifies the assertion’s purpose, making it immediately clear that a boolean check is being performed.

import assert from "node:assert";
assert(divide(10, 2) === 5);
import { strict as assert } from "node:assert";
assert(value);

This rule is not configurable.

If you have a strong preference for the shorter assert() syntax and find it clear enough in your codebase, you might choose not to enable this rule.

Made with ❤️‍🔥 in Boston by Josh Goldberg and contributors.