The eslint-plugin-neverthrow ensures that Result and ResultAsync values are properly handled in your codebase, preventing unhandled errors from slipping through.
Created by mdbetancourt as part of NeverThrow’s bounty program, this ESLint plugin enforces that errors are not left unhandled.This plugin is essentially a porting of Rust’s must-use attribute to TypeScript/JavaScript.
import { Result } from 'neverthrow'function getUser(id: string): Result<User, Error> { // ...}// Valid: Using match to handle both casesgetUser('123').match( (user) => console.log('Success:', user), (error) => console.error('Error:', error))
import { Result } from 'neverthrow'function getUser(id: string): Result<User, Error> { // ...}// ❌ Invalid: Result is not consumedgetUser('123')// ❌ Invalid: Mapped but final result not consumedgetUser('123').map(user => user.name)
// ❌ Invalid: Only handles ok case with mapgetUser('123').map(user => { console.log('User:', user)})// Must use .match() or .unwrapOr() to explicitly handle errors