🐊Putout plugin adds ability to find and remove useless variables
.
npm i @putout/plugin-remove-useless-variables -D
- ✅ declaration;
- ✅ destruct;
- ✅ duplicate;
- ✅ remove;
- ✅ rename;
{
"rules": {
"remove-useless-variables/rename": "on",
"remove-useless-variables/remove": "on",
"remove-useless-variables/destruct": "on",
"remove-useless-variables/declaration": ["on", {
"maxLength": 20
}],
"remove-useless-variables/duplicate": "on"
}
}
function hi(a) {
const b = a;
}
function hi(b) {}
function hi(c) {
const {a, b} = c;
}
function hi({a, b}) {}
const child_process = require('node:child_process');
const {exec, spawn} = child_process;
const {exec, spawn} = require('node:child_process');
Check it out in 🐊Putout Editor.
const a = 5;
const b = a;
const c = 5;
d = c;
const b = 5;
d = 5;
Check it out in 🐊Putout Editor.
function x() {
const a = 5;
return a;
}
const z = b.c.replace('x', 'y');
b.c = z;
function x() {
return 5;
}
b.c = b.c.replace('x', 'y');
Check it out in 🐊Putout Editor.
const DestructuringErrors = function DestructuringErrors(a, b) {
return [a, b];
};
function DestructuringErrors(a, b) {
return [a, b];
}
bc = b.c.replace('x', 'y');
MIT