npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

eslint-plugin-error-cause

v1.2.10

Published

ESLint rules to detect swallowed error causes when rethrowing exceptions.

Downloads

1,494

Readme

Rule has migrated 🎉

This rule has been added to eslint project, and the docs can be found here. This repo is no longer maintained and is archived.

eslint-plugin-error-cause

An ESLint plugin with rules to report loss of original error cause, when re-throwing errors.

code-art

Table of Contents

Background

From MDN docs

The cause data property of an Error instance indicates the specific original cause of the error.

It is used when catching and re-throwing an error with a more-specific or useful error message in order to still have access to the original error.

This property was only added to Node in its 16.9.0 release, before which JavaScript developers used to rely on workarounds like including the cause error message in the symptom error message like so:

catch(error) {
    // NO LONGER NEEDED ❌
    throw new Error(`Failed to perform operation xyz: ${error.message}`);
}

The modern way to do this is by explicitly specifying the cause error in the symptom error constructor, essentially chaining the two errors which has been a common pattern in other languages like Java.

catch(error) {
    throw new Error(`Failed to perform operation xyz`, {
        cause: error // The right way ✅
    });
}

Installation

Install eslint and this plugin as dev dependencies.

pnpm add -D eslint eslint-plugin-error-cause

Configuration (ESLint v8.23.0+ Flat Config)

From v8.21.0, eslint announced a new config system. In the new system, .eslintrc* is no longer used. eslint.config.js would be the default config file name. In eslint v8, the legacy system (.eslintrc*) would still be supported, while in eslint v9, only the new system would be supported.

And from v8.23.0, eslint CLI starts to look up eslint.config.js. This plugin only supports the new config system, so if your eslint is >=8.23.0, you're 100% ready to use the new config system.

You could either use the preset recommended config exported from this project or enable the rule manually.

Recommended

This enables no-swallowed-error-cause rule with a warn severity level.

import errorCause from "eslint-plugin-error-cause";
import { defineConfig } from "eslint/config";

export default defineConfig([errorCause.configs.recommended]);

Manual Config

This is particularly useful if you want to set a different severity level than warn.

import errorCause from "eslint-plugin-error-cause";
import { defineConfig } from "eslint/config";

export default defineConfig([
    {
        plugins: {
            "error-cause": errorCause,
        },
        rules: {
            "error-cause/no-swallowed-error-cause": "warn",
        },
    },
]);

List of supported rules

🔧 Automatically fixable by the --fix CLI option.

| Name                     | Description | 🔧 | | :----------------------------------------------------------------- | :--------------------------------------------------------------------- | :- | | no-swallowed-error-cause | disallow losing original error cause when re-throwing custom errors. | 🔧 |

Contributing

Got an idea for a new rule, or found a bug that needs to be fixed?

Its time to file an issue!

Make sure to read CONTRIBUTING.md for more details.

References

License

eslint-plugin-error-cause is licensed under the MIT License.