deno-lint-plugin-neverthrow
π A Deno Lint Plugin to enforce proper handling of neverthrow Result values.
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 lintExample 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.