1.5.4 • Published 9 months ago

eslint-plugin-exception-handling v1.5.4

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

image

no-unhandledmight-throwuse-error-cause
no-unhandledmight-throwcause

Installation

yarn add -D eslint-plugin-exception-handling
npm i -D eslint-plugin-exception-handling
pnpm add -D eslint-plugin-exception-handling

Usage

Sample eslint.config.js:

For TypeScript:

// @ts-check

import eslint from "@eslint/js";
import tseslint from "typescript-eslint";
import { plugin as ex } from "eslint-plugin-exception-handling";

export default tseslint.config(
  eslint.configs.recommended,
  ...tseslint.configs.recommended,
  { plugins: { ex }, rules: { "ex/no-unhandled": "error" } }
);

For JavaScript:

import globals from "globals";
import pluginJs from "@eslint/js";
import { plugin as ex } from "eslint-plugin-exception-handling";

export default [
  { files: ["**/*.js"], languageOptions: { sourceType: "commonjs" } },
  { languageOptions: { globals: globals.browser } },
  pluginJs.configs.recommended,
  { plugins: { ex } },
  { rules: { "ex/no-unhandled": "error" } },
];

Limitations & Caveats

  • This plugin only checks for functions that might throw exceptions. It does not check for functions that might return a rejected promise.
  • Currently, only user-defined functions are checked. This means that built-in functions that might throw exceptions are not yet linted. I'm working on a feature for that, but it's quite a grind to list all the built-in functions that might throw exceptions. If you want to help feel free to open a PR.

Rules

Name           Description
might-throwWarns about function calls that might throw exceptions.
no-unhandledWarns about function calls that might throw exceptions and are not handled at all further up the stack.
use-error-causeOn Error re-thrown, forces the use of cause property in order to preserve stack traces. See: Error: cause
1.5.4

9 months ago

1.5.3

9 months ago

1.5.2

10 months ago

1.5.1

10 months ago

1.4.4

10 months ago

1.4.3

11 months ago

1.4.2

11 months ago

1.4.0

11 months ago

1.3.1

1 year ago

1.2.0

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.2.1

1 year ago

1.0.2

1 year ago

1.0.0

1 year ago