@putout/plugin-arguments
v1.1.2
Published
🐊Putout plugin adds ability to find and remove useless arguments
Maintainers
Readme
@putout/plugin-arguments 
🐊Putout plugin adds ability to find and remove useless arguments.
Install
npm i @putout/plugin-argumentsRules
- ✅ apply-json-parse;
- ✅ apply-rest;
- ✅ remove-useless;
- ✅ remove-useless-from-method;
- ✅ destructuring;
- ✅ remove-unused;
Config
{
"rules": {
"arguments/apply-json-parse": "on",
"arguments/apply-rest": "on",
"arguments/remove-useless": "on",
"arguments/remove-useless-from-method": "on",
"arguments/destructuring": "on",
"arguments/remove-unused": "on"
}
}apply-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)));apply-rest
The rest parameter syntax allows a function to accept an indefinite number of arguments as an
array, providing a way to represent variadic functions in JavaScript.(c) MDN
❌ Example of incorrect code
function hello() {
console.log(arguments);
}✅ Example of correct code
function hello(...args) {
console.log(args);
}remove-useless
❌ Example of incorrect code
const sum = (a, b) => {};
sum(a, b, c);✅ Example of correct code
const sum = (a, b) => {};
sum(a, b);remove-useless-from-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() {}
}remove-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);
}License
MIT
