# unicorn/consistent-assert

> Require `assert.ok(value)` instead of `assert(value)` with `node:assert`

`assert(value)` and `assert.ok(value)` do the same thing. Every other check in `node:assert` is a method, such as `assert.equal()` or `assert.throws()`, so the bare call is the odd one out in a list of assertions.

The rule looks at the default import of `assert`, `node:assert`, `assert/strict` and `node:assert/strict`, and at the `strict` export of the first two.

`--fix` adds `.ok`.

{/* Generated by src/codegen/lint-rule-docs.ts. Do not edit this section. */}

## Configure

Off by default. To turn it on:

```toml bunfig.toml
[lint.rules]
"unicorn/consistent-assert" = "error" # or "warn"
```

{/* End of the generated section. */}

## Examples

Reported:

{/* bad */}
```js
import assert from "node:assert";

assert(user.isActive);
assert.equal(user.name, "Ada");
```

{/* bad */}
```js
import { strict as assert } from "node:assert";

assert(user.isActive);
```

Not reported:

{/* good */}
```js
import assert from "node:assert";

assert.ok(user.isActive);
assert.equal(user.name, "Ada");
```

An `assert` that comes from anywhere else is left alone, and so is one loaded with `require()`:

{/* good */}
```js
import { assert } from "chai";
const nodeAssert = require("node:assert");

assert(user.isActive);
nodeAssert(user.isActive);
```
