Skip to main content
Deno 2 is finally here πŸŽ‰οΈ
Learn more

deno-lint-plugin-neverthrow

πŸš€ A Deno Lint Plugin to enforce proper handling of neverthrow Result values.

https://deno.land/x/deno_lint_plugin_neverthrow

This plugin ensures that Result values from neverthrow are properly handled using .match(), .unwrapOr(), or _unsafeUnwrap(), preventing silent failures.

πŸ“Œ Features

βœ… Warns when a Result is created but not handled.
βœ… Allows valid usage like .match(), .unwrapOr(), _unsafeUnwrap(), etc.
βœ… Works seamlessly with deno lint.
βœ… Lightweight and easy to install.


πŸ“¦ Installation

To enable the plugin in your Deno project, add it to deno.json:

{
  "lint": {
    "plugins": ["https://deno.land/x/deno_lint_plugin_neverthrow/mod.ts"]
  }
}

πŸš€ Usage

After installation, simply run:

deno lint

Example Code

❌ Incorrect (Unhandled Result)

This will trigger an error because the Result is unused.

import { ok } from "npm:neverthrow";

ok(42); // ❌ Error: "Result must be handled with `match`, `unwrapOr`, or `_unsafeUnwrap`."

βœ… Correct (Handled Result)

This is valid because the Result is properly used.

import { ok } from "npm:neverthrow";

const result = ok(42);
result.match(
  (value) => console.log(value), 
  (err) => console.error(err)
);

πŸ”§ Configuration

By default, the rule is enabled. However, you can manually configure it in deno.json:

{
  "lint": {
    "rules": {
      "include": ["must-use-result"]
    },
    "plugins": ["https://deno.land/x/deno_lint_plugin_neverthrow/mod.ts"]
  }
}

πŸ“œ License

This project is licensed under the MIT License. See LICENSE for details.