πPutout plugin adds ability to find and remove useless arguments
npm install @putout/plugin-arguments[NPMIMGURL]: https://img.shields.io/npm/v/@putout/plugin-arguments.svg?style=flat&longCache=true
[NPMURL]: https://npmjs.org/package/@putout/plugin-arguments "npm"
πPutout plugin adds ability to find and remove useless arguments.
```
npm i @putout/plugin-arguments
- β
apply-json-parse;
- β
apply-rest;
- β
convert-expressiont-to-arguments;
- β
remove-duplicate;
- β
remove-useless;
- β
remove-useless-from-method;
- β
remove-unused;
- β
remove-empty;
`json`
{
"rules": {
"arguments/apply-json-parse": "on",
"arguments/apply-rest": "on",
"arguments/convert-expressiont-to-arguments": "on",
"arguments/remove-duplicate": "on",
"arguments/remove-useless": "on",
"arguments/remove-useless-from-method": "on",
"arguments/remove-unused": "on",
"arguments/remove-empty": "on"
}
}
> 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.
`js
import {operator} from 'putout';
const {fromJS} = operator;
JSON.parse(fromJS(print(ast)), null, 4);
`
`js
import {operator} from 'putout';
const {fromJS} = operator;
JSON.parse(fromJS(print(ast)));
`
> 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
`js`
function hello() {
console.log(arguments);
}
`js`
function hello(...args) {
console.log(args);
}
> Uncaught SyntaxError: Malformed arrow function parameter list occurs when your function declaration is missing valid parameters.
>
> (c) MDN
πPutout plugin adds ability to fix SyntaxError: missing formal parameter .
Checkout in πPutout Editor.
``
(a(hello, world)) => (b + a);
(a + b) => (b + a);
(a || b) => (b + a);
`js`
(a, hello, world) => a;
(a, b) => b + a;
(a, b) => b + a;
> The JavaScript exception duplicate formal argument x or duplicate argument names not allowed in this context occurs when a function creates two or more parameter bindings with the same name, and the function is not a non-strict function with only simple parameters.
>
> (c) MDN
Checkout in πPutout Editor.
`diff`
-const sum = (a, a) => {}
+const sum = (a) => {}
Linter | Rule | Fix
----------------|-------|------------|
π Putout | arguments/remove-duplicate | β
β£ ESLint | no-dupe-args | β
π¦ Deno | no-dupe-args | β
`js`
const sum = (a, b) => {};
sum(a, b, c);
`js`
const sum = (a, b) => {};
sum(a, b);
Check it out in πPutout Editor.
`js`
class Parser {
parseStatement(context, topLevel, exports) {
this.parseGuard(a, b);
}
parseGuard() {}
}
`js`
class Parser {
parseStatement(context, topLevel, exports) {
this.parseGuard();
}
parseGuard() {}
}
Check it out in πPutout Editor.
`js
member += compute(member, list[i]);
function compute(member, current) {
return String(current);
}
`
`js
member += compute(list[i]);
function compute(current) {
return String(current);
}
`
> Uncaught SyntaxError: Unexpected token ','
>
> (c) MDN
Check it out in πPutout Editor.
`diff``
-renameFileWithLog('hello', ,'world');
+renameFileWithLog('hello', 'world');
MIT