@putout/plugin-remove-useless-arguments 
🐊Putout plugin adds ability to find and remove useless arguments
.
Install
npm i @putout/plugin-remove-useless-arguments
Rules
- ✅ arguments;
- ✅ destructuring;
- ✅ method;
- ✅ unused;
- ✅ json-parse;
Config
{
"rules": {
"remove-useless-arguments/arguments": "on",
"remove-useless-arguments/destructuring": "on",
"remove-useless-arguments/method": "on",
"remove-useless-arguments/unused": "on",
"remove-useless-arguments/json-parse": "on"
}
}
arguments
❌ Example of incorrect code
const sum = (a, b) => {}; // destructuring
sum(a, b, c);
✅ Example of correct code
const sum = (a, b) => {};
sum(a, b);
destructuring
❌ Example of incorrect code
onIfStatement({
push,
generate,
abc,
helloworld,
});
function onIfStatement({push}) {}
✅ Example of correct code
onIfStatement({
push,
});
function onIfStatement({push}) {}
method
Check it out in 🐊Putout Editor.
❌ Example of incorrect code
class Parser {
parseStatement(context, topLevel, exports) {
this.parseGuard(a, b);
}
parseGuard() {}
}
✅ Example of correct code
class Parser {
parseStatement(context, topLevel, exports) {
this.parseGuard();
}
parseGuard() {}
}
unused
Check it out in 🐊Putout Editor.
❌ Example of incorrect code
member += compute(member, list[i]);
function compute(member, current) {
return String(current);
}
✅ Example of correct code
member += compute(list[i]);
function compute(current) {
return String(current);
}
json-parse
The
JSON.parse()
static method parses a JSON string, constructing the JavaScript value or object described by the string. An optional reviver function can be provided to perform a transformation on the resulting object before it is returned.(c) MDN
Check it out in 🐊Putout Editor.
❌ Example of incorrect code
import {operator} from 'putout';
const {fromJS} = operator;
JSON.parse(fromJS(print(ast)), null, 4);
✅ Example of correct code
import {operator} from 'putout';
const {fromJS} = operator;
JSON.parse(fromJS(print(ast)));
License
MIT