Skip to content

assertStyles

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

✅ This rule is included in the node stylistic and stylisticStrict presets.

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
function assert(value: unknown, message?: string | Error): asserts value

An alias of

assert.ok

.

@sincev0.5.9

@paramvalue The input that is checked for being truthy.

assert
from "node:assert";
function assert(value: unknown, message?: string | Error): asserts value

An alias of

assert.ok

.

@sincev0.5.9

@paramvalue The input that is checked for being truthy.

assert
(
any
divide
(10, 2) === 5);
import {
function assert.strict(value: unknown, message?: string | Error): asserts value
namespace assert.strict
export assert.strict
strict
as
function assert(value: unknown, message?: string | Error): asserts value
assert
} from "node:assert";
function assert(value: unknown, message?: string | Error): asserts value
assert
(
any
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 ❤️‍🔥 around the world by the Flint team and contributors.