🐊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;
{
"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.
import {operator} from 'putout';
const {fromJS} = operator;
JSON.parse(fromJS(print(ast)), null, 4);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
function hello() {
console.log(arguments);
}function hello(...args) {
console.log(args);
}
Uncaught SyntaxError: Malformed arrow function parameter listoccurs 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);
(a, hello, world) => a;
(a, b) => b + a;
(a, b) => b + a;The JavaScript exception
duplicate formal argument xorduplicate argument names not allowed in this contextoccurs 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.
-const sum = (a, a) => {}
+const sum = (a) => {}| Linter | Rule | Fix |
|---|---|---|
| 🐊 Putout | arguments/remove-duplicate |
✅ |
| ⏣ ESLint | no-dupe-args |
❌ |
| 🦕 Deno | no-dupe-args |
❌ |
const sum = (a, b) => {};
sum(a, b, c);const sum = (a, b) => {};
sum(a, b);Check it out in 🐊Putout Editor.
class Parser {
parseStatement(context, topLevel, exports) {
this.parseGuard(a, b);
}
parseGuard() {}
}class Parser {
parseStatement(context, topLevel, exports) {
this.parseGuard();
}
parseGuard() {}
}Check it out in 🐊Putout Editor.
member += compute(member, list[i]);
function compute(member, current) {
return String(current);
}member += compute(list[i]);
function compute(current) {
return String(current);
}
Uncaught SyntaxError: Unexpected token ','(c) MDN
Check it out in 🐊Putout Editor.
-renameFileWithLog('hello', ,'world');
+renameFileWithLog('hello', 'world');MIT