7.0.0-beta.2 • Published 7 years ago

babel-plugin-codemod-optional-catch-binding v7.0.0-beta.2

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

babel-plugin-codemod-optional-catch-binding

If the argument bound to the catch block is not referenced in the catch block, that argument and the catch binding is removed.

Examples

try {
  throw 0;
} catch (err) {
  console.log("it failed, but this code executes");
}

Is transformed to:

try {
  throw 0;
} catch {
  console.log("it failed, but this code executes");
}

Installation

npm install --save-dev babel-plugin-codemod-optional-catch-binding

Usage

Via .babelrc (Recommended)

.babelrc

{
  "plugins": ["codemod-optional-catch-binding"]
}

Via CLI

babel --plugins codemod-optional-catch-binding script.js

Via Node API

require("babel-core").transform("code", {
  plugins: ["codemod-optional-catch-binding"]
});

References

This codemod updates your source code in line with the following proposal: