
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
babel-plugin-transform-prune-unused-imports
Advanced tools
Using npm:
npm install babel-plugin-transform-prune-unused-imports --save-dev
or using yarn:
yarn add babel-plugin-transform-prune-unused-imports --dev
By default, only true
and false
identifiers are considered truthy/falsy.
falsyExpressions
: Array<string>
- Expressions (in addition to false
) to be treated as falsytruthyExpressions
: Array<string>
- Expressions (in addition to true
) to be treated as truthy{
"plugins": [
[
"transform-prune-unused-imports",
{
"falsyExpressions": ["process.env.NODE_ENV !=='production'"]
}
]
]
}
{
"plugins": [
[
"transform-prune-unused-imports",
{
"falsyExpressions": ["__NODE__"],
"truthyExpressions": ["__BROWSER__"]
}
]
]
}
This plugin is able identify unused imports in the following scenarios:
import { unreachable, reachable } from "some-pkg";
if (false) {
unreachable;
}
if (true) {
reachable;
} else {
unreachable;
}
true ? reachable : unreachable;
false ? unreachable : reachable;
import { unreachable } from "some-pkg";
foo && false && bar && unreachable;
Variable scope is correctly handled.
// Before
import { unused } from "some-pkg";
function foo(unused) {
unused;
}
// After
function foo(unused) {
unused;
}
While this plugin works for most use cases, the static analysis is performed by this plugin is ultimately limited and won't work in some scenarios.
Currently this plugin will not prune unused imports that are assigned to variables, even if those new variables are unused. For example:
import { unreachable } from "some-pkg";
const foo = unreachable;
if (false) {
foo;
}
FAQs
## Install
The npm package babel-plugin-transform-prune-unused-imports receives a total of 216 weekly downloads. As such, babel-plugin-transform-prune-unused-imports popularity was classified as not popular.
We found that babel-plugin-transform-prune-unused-imports demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.