For AI agents: the complete documentation index is available at https://rslint.rs/llms.txt, the full documentation bundle is available at https://rslint.rs/llms-full.txt, and this page is available as Markdown at https://rslint.rs/rules/unicorn/consistent-assert.md.
close

consistent-assert

Unreleased

Configuration

PresetConfigured Value
✅ unicornPlugin.configs.recommended"error"
rslint.config.ts
import { defineConfig, unicornPlugin } from '@rslint/core';

export default defineConfig([
  unicornPlugin.configs.recommended,
  {
    rules: {
      'unicorn/consistent-assert': 'error',
    },
  },
]);

Rule Details

Enforce the explicit node:assert assertion style by preferring assert.ok(value) over calling an imported assert function directly.

Examples of incorrect code:

import assert from 'node:assert/strict';

assert(value);

Examples of correct code:

import assert from 'node:assert/strict';

assert.ok(value);

The rule recognizes default imports from assert, node:assert, assert/strict, and node:assert/strict. It also recognizes default named imports and strict imported from assert or node:assert.

Only direct calls to the imported binding are changed. Other references, namespace imports, type-only imports, and shadowed bindings are left alone.

Original Documentation