Skip to content

Commit 0e2cc84

Browse files
committed
feature: @putout/plugin-arguments: apply-rest
1 parent 3f9473f commit 0e2cc84

File tree

27 files changed

+93
-210
lines changed

27 files changed

+93
-210
lines changed

packages/plugin-arguments/README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ npm i @putout/plugin-arguments
1313

1414
## Rules
1515

16+
-[apply-rest](#apply-rest);
1617
-[remove-useless](#remove-useless);
1718
-[remove-useless-from-method](#remove-useless-from-method);
1819
-[destructuring](#destructring);
@@ -24,6 +25,7 @@ npm i @putout/plugin-arguments
2425
```json
2526
{
2627
"rules": {
28+
"arguments/apply-rest": "on",
2729
"arguments/remove-useless": "on",
2830
"arguments/remove-useless-from-method": "on",
2931
"arguments/destructuring": "on",
@@ -127,6 +129,32 @@ const {fromJS} = operator;
127129
JSON.parse(fromJS(print(ast)));
128130
```
129131

132+
## apply-rest
133+
134+
> 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.
135+
>
136+
> (c) [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters)
137+
138+
### ❌ Example of incorrect code
139+
140+
```js
141+
function hello() {
142+
console.log(arguments);
143+
}
144+
```
145+
146+
### ✅ Example of correct code
147+
148+
```js
149+
function hello(...args) {
150+
console.log(args);
151+
}
152+
```
153+
154+
## License
155+
156+
MIT
157+
130158
## License
131159

132160
MIT

packages/plugin-convert-arguments-to-rest/test/fixture/arguments-fix.js renamed to packages/plugin-arguments/lib/apply-rest/fixture/apply-rest-fix.js

File renamed without changes.

packages/plugin-convert-arguments-to-rest/test/fixture/arguments.js renamed to packages/plugin-arguments/lib/apply-rest/fixture/apply-rest.js

File renamed without changes.

packages/plugin-convert-arguments-to-rest/test/fixture/args-fix.js renamed to packages/plugin-arguments/lib/apply-rest/fixture/args-fix.js

File renamed without changes.

packages/plugin-convert-arguments-to-rest/test/fixture/args.js renamed to packages/plugin-arguments/lib/apply-rest/fixture/args.js

File renamed without changes.

packages/plugin-convert-arguments-to-rest/test/fixture/iife-fix.js renamed to packages/plugin-arguments/lib/apply-rest/fixture/iife-fix.js

File renamed without changes.

packages/plugin-convert-arguments-to-rest/test/fixture/iife.js renamed to packages/plugin-arguments/lib/apply-rest/fixture/iife.js

File renamed without changes.

packages/plugin-convert-arguments-to-rest/test/fixture/params-fix.js renamed to packages/plugin-arguments/lib/apply-rest/fixture/params-fix.js

File renamed without changes.

packages/plugin-convert-arguments-to-rest/test/fixture/params.js renamed to packages/plugin-arguments/lib/apply-rest/fixture/params.js

File renamed without changes.

packages/plugin-convert-arguments-to-rest/test/fixture/strict.js renamed to packages/plugin-arguments/lib/apply-rest/fixture/strict.js

File renamed without changes.

0 commit comments

Comments
 (0)