
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
babel-plugin-remove-unused-reference
Advanced tools
Babel plugin, remove unused reference.
when const isX = false;
, change const x = isX ? A : B;
-> const x = B;
when const isX = false;
, change if (isX) { A } else { B }
-> { B }
when false
, support (isX && ...)
, (... && isX)
(left ... is normal data type without slide effetcs)
support const x = false ? A : B
-> const x = B
and if (false) A else B
-> B
when const isX = true;
, change const x = isX ? A : B;
-> const x = A;
when const isX = true;
, change if (isX) { A } else { B }
-> { A }
when true
, support (isX || ...)
, (... || isX)
(left ... is normal data type without slide effetcs)
support const x = true ? A : B
-> const x = A
and if (true) A else B
-> A
Input:
test(`
// 测试变量 const isX = false 时,条件表达式中 isX 相应逻辑的剔除
const isX = false;
const A = isX ? { a } : {};
const A2 = isX && x && 2 && true && fn() ? { a2 } : {};
const A3 = x && isX ? { a3 } : {};
const A4 = x && 2 && true && '2' && isX ? { a4 } : {};
const A0 = fn() && isX ? {} : { a0 };
`);
test(`
// 测试条件表达式中含有 false 字面量时,条件表达式中相应逻辑的剔除
const A = false ? { a } : {};
const A2 = false && x && 2 && '2' && fn() ? { a2 } : {};
const A3 = x && 2 && true && false ? { a3 } : {};
const A0 = fn() && false ? { a0 } : {};
`);
test(`
// 测试变量 const isX = false 时,if 语句中 isX 相应逻辑的剔除
const isX = false;
if (isX) { a } else {}
if (isX && x && 2 && true && fn()) { a2 } else {}
if (x && 2 && true && '2' && isX) { a3 } else {}
if (fn() && isX) { a0 } else {}
`);
test(`
// 测试条件表达式中含有 false 字面量时,if 语句中相应逻辑的剔除
if (false) { a } else {}
if (false && x && 2 && true && fn()) { a2 } else {}
if (x && 2 && true && '2' && false) { a3 } else {}
if (fn() && false) { a0 } else {}
`);
test(`
// 测试条件表达式中含有 const isX = true 时,条件表达式中 isX 相应逻辑的剔除
const isX = true;
const A = isX ? { } : { a };
const A2 = isX || x || 2 || false || fn() ? { } : { a2 };
const A3 = x || isX ? { } : { a3 };
const A4 = x || 2 || isX || false || '2' ? { } : { a4 };
const A0 = fn() || isX ? { } : { a0 };
`);
test(`
// 测试条件表达式中含有 true 字面量时,条件表达式中相应逻辑的剔除
const A = true ? { } : { a };
const A2 = true || x || 2 || '2' || fn() ? { } : { a2 };
const A3 = x || 2 || false || true || '2' || fn() ? { } : { a3 };
const A0 = fn() || true ? { } : { a0 };
`);
test(`
// 测试条件表达式中含有 const isX = true 时,if 语句中 isX 相应逻辑的剔除
const isX = true;
if (isX) { } else { a }
if (isX || x || 2 || false || fn()) { } else { a2 }
if (x || 2 || false || '2' || isX) { } else { a3 }
if (false) { a4 } else if (true) { } else if (isWeb) { a41 } else { a42 }
if (fn() || isX) { } else { a0 }
`);
test(`
// 测试条件表达式中含有 true 字面量时,if 语句中相应逻辑的剔除
if (true) { } else { a }
if (true || x || 2 || false || fn()) { } else { a2 }
if (x || 2 || false || '2' || true) { } else { a3 }
if (false) { a4 } else if (true) { } else { a41 }
if (false) { a5 } else if (x || 2 || true || false || '2') { } else { a51 }
if (fn() || true) { } else { a0 }
`);
output:
> npm run example
> node ./examples/index.js
// 测试变量 const isX = false 时,条件表达式中 isX 相应逻辑的剔除
const isX = false;
const A = {};
const A2 = {};
const A3 = {};
const A4 = {};
const A0 = fn() && isX ? {} : {
a0
};
---------------------------------------
// 测试条件表达式中含有 false 字面量时,条件表达式中相应逻辑的剔除
const A = {};
const A2 = {};
const A3 = {};
const A0 = fn() && false ? {
a0
} : {};
---------------------------------------
// 测试变量 const isX = false 时,if 语句中 isX 相应逻辑的剔除
const isX = false;
{}
{}
{}
if (fn() && isX) {
a0;
} else {}
---------------------------------------
// 测试条件表达式中含有 false 字面量时,if 语句中相应逻辑的剔除
{}
{}
{}
if (fn() && false) {
a0;
} else {}
---------------------------------------
// 测试条件表达式中含有 const isX = true 时,if 语句中 isX 相应逻辑的剔除
const isX = true;
{}
{}
{}
{}
if (fn() || isX) {} else {
a0;
}
---------------------------------------
// 测试条件表达式中含有 true 字面量时,if 语句中相应逻辑的剔除
{}
{}
{}
{}
{}
if (fn() || true) {} else {
a0;
}
---------------------------------------
// 测试条件表达式中含有 const isX = true 时,条件表达式中 isX 相应逻辑的剔除
const isX = true;
const A = {};
const A2 = {};
const A3 = {};
const A4 = {};
const A0 = fn() || isX ? {} : {
a0
};
---------------------------------------
// 测试条件表达式中含有 true 字面量时,条件表达式中相应逻辑的剔除
const A = {};
const A2 = {};
const A3 = {};
const A0 = fn() || true ? {} : {
a0
};
---------------------------------------
npm i babel-plugin-remove-unused-reference
// pnpm add babel-plugin-remove-unused-reference
FAQs
Babel plugin, remove unused references
The npm package babel-plugin-remove-unused-reference receives a total of 0 weekly downloads. As such, babel-plugin-remove-unused-reference popularity was classified as not popular.
We found that babel-plugin-remove-unused-reference demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.