@chejholloway/eslint-plugin-result-guard
v0.1.2
Published
ESLint rule that flags a neverthrow Result/ResultAsync value that's silently dropped instead of checked, chained, or explicitly discarded.
Maintainers
Readme
eslint-plugin-result-guard
Flags a neverthrow Result/ResultAsync value that's dropped without being checked, chained, awaited-and-checked, or explicitly discarded.
TypeScript's type system won't force you to look at the Err branch — there's nothing like Rust's #[must_use]. This rule is that enforcement.
Install
npm install -D eslint-plugin-result-guardUsage
// eslint.config.js
import resultGuard from "eslint-plugin-result-guard";
export default [
{
plugins: { "result-guard": resultGuard },
rules: {
"result-guard/no-unhandled-result": "error",
},
},
];Requires type-aware linting (parserOptions.projectService or parserOptions.project pointing at a real tsconfig.json), since the rule checks the actual TypeScript type of each expression, not just its syntax.
doWork(id); // flagged: Result value never checked
const result = doWork(id); // fine — captured for later handling
void doWork(id); // fine — explicit, intentional discard
doWork(id).match(onOk, onErr); // fine — handled inlineWhat this doesn't catch (yet)
const result = doWork(id); console.log(result.value); — captured but never checked before an unsafe access. Catching that needs real control-flow analysis and is planned as a separate rule.
License
MIT
