Skip to content

unicorn/consistent-assert Pedantic

🛠️ An auto-fix is available for this rule.

What it does

Enforces consistent usage of the assert module.

Why is this bad?

Inconsistent usage of the assert module can lead to confusion and errors.

Examples

Examples of incorrect code for this rule:

js
import assert from "node:assert";

assert(divide(10, 2) === 5);

Examples of correct code for this rule:

js
import assert from "node:assert";

assert.ok(divide(10, 2) === 5);

How to use

To enable this rule in the CLI or using the config file, you can use:

bash
oxlint --deny unicorn/consistent-assert
json
{
  "rules": {
    "unicorn/consistent-assert": "error"
  }
}

References

Released under the MIT License.