Skip to content

Commit b8fedb3

Browse files
committed
feature: @putout/plugin-putout-config: apply-spread: add
1 parent 6d1db22 commit b8fedb3

File tree

9 files changed

+101
-3
lines changed

9 files changed

+101
-3
lines changed

packages/plugin-putout-config/README.md

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ npm i @putout/plugin-putout-config -D
1818
-[apply-conditions](#apply-conditions);
1919
-[apply-destructuring](#apply-destructuring);
2020
-[apply-esm](#apply-esm);
21-
-[apply-return](#apply-return);
22-
-[apply-parens](#apply-parens);
2321
-[apply-for-of](#apply-for-of);
22+
-[apply-parens](#apply-parens);
23+
-[apply-return](#apply-return);
24+
-[apply-spread](#apply-spread);
2425
-[apply-labels](#apply-labels);
2526
-[apply-math](#apply-math);
2627
-[apply-nodejs](#apply-nodejs);
@@ -51,10 +52,11 @@ npm i @putout/plugin-putout-config -D
5152
"putout-config/apply-nodejs": "on",
5253
"putout-config/apply-optional-chaining": "on",
5354
"putout-config/apply-parens": "on",
55+
"putout-config/apply-promises": "on",
5456
"putout-config/apply-return": "on",
57+
"putout-config/apply-spread": "on",
5558
"putout-config/apply-tape": "on",
5659
"putout-config/apply-types": "on",
57-
"putout-config/apply-promises": "on",
5860
"putout-config/convert-boolean-to-string": "on",
5961
"putout-config/move-formatter-up": "on",
6062
"putout-config/remove-empty": "on",
@@ -236,6 +238,27 @@ Apply [`optional-chaining`](https://github.com/coderaiser/putout/tree/master/pac
236238
}
237239
```
238240

241+
## apply-spread
242+
243+
Apply [`spread`](https://github.com/coderaiser/putout/tree/master/packages/plugin-spread#readme) according to:
244+
245+
- 🐊[**Putout v41**](https://github.com/coderaiser/putout/releases/tag/v41.0.0):
246+
247+
```diff
248+
{
249+
"rules": {
250+
- "remove-useless-spread": "on",
251+
- "remove-useless-spread/array": "on",
252+
- "remove-useless-spread/object": "on",
253+
- "remove-useless-spread/nested": "on"
254+
+ "spread": "on",
255+
+ "spread/remove-useless-array": "on",
256+
+ "spread/remove-useless-object": "on",
257+
+ "spread/simplify-nested": "on"
258+
}
259+
}
260+
```
261+
239262
## apply-conditions
240263

241264
Apply [`conditions`](https://github.com/coderaiser/putout/tree/master/packages/plugin-conditions#readme) according to:
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
__putout_processor_json({
2+
rules: {
3+
"spread": "off",
4+
"spread/simplify-nested": "off",
5+
"spread/remove-useless-array": "off",
6+
"spread/remove-useless-object": "off"
7+
}
8+
});
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
__putout_processor_json({
2+
rules: {
3+
"remove-useless-spread": "off",
4+
"remove-useless-spread/nested": "off",
5+
"remove-useless-spread/array": "off",
6+
"remove-useless-spread/object": "off",
7+
}
8+
});
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import {createRenameProperty} from '../rename-property.js';
2+
3+
const v41 = [
4+
['remove-useless-spread', 'spread'],
5+
['remove-useless-spread/nested', 'spread/simplify-nested'],
6+
['remove-useless-spread/array', 'spread/remove-useless-array'],
7+
['remove-useless-spread/object', 'spread/remove-useless-object'],
8+
];
9+
10+
const versions = [
11+
...v41,
12+
];
13+
14+
export const {
15+
report,
16+
fix,
17+
traverse,
18+
} = createRenameProperty(versions);
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import {createTest} from '@putout/test';
2+
import * as plugin from './index.js';
3+
4+
const test = createTest(import.meta.url, {
5+
plugins: [
6+
['apply-spread', plugin],
7+
],
8+
});
9+
10+
test('putout-config: apply-spread: report', (t) => {
11+
t.report('apply-spread', `Rename property: 'remove-useless-spread' -> 'spread'`);
12+
t.end();
13+
});
14+
15+
test('putout-config: apply-spread: transform', (t) => {
16+
t.transform('apply-spread');
17+
t.end();
18+
});

packages/plugin-putout-config/lib/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import * as applyLabels from './apply-labels/index.js';
1111
import * as applyMath from './apply-math/index.js';
1212
import * as applyNodejs from './apply-nodejs/index.js';
1313
import * as applyPromises from './apply-promises/index.js';
14+
import * as applySpread from './apply-spread/index.js';
1415
import * as applyTape from './apply-tape/index.js';
1516
import * as applyTypes from './apply-types/index.js';
1617
import * as convertBooleanToString from './convert-boolean-to-string/index.js';
@@ -33,6 +34,7 @@ export const rules = {
3334
'apply-parens': applyParens,
3435
'apply-promises': applyPromises,
3536
'apply-return': applyReturn,
37+
'apply-spread': applySpread,
3638
'apply-tape': applyTape,
3739
'apply-types': applyTypes,
3840
'convert-boolean-to-string': convertBooleanToString,
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
__putout_processor_json({
2+
rules: {
3+
"spread": "off",
4+
"spread/simplify-nested": "off",
5+
"spread/remove-useless-array": "off",
6+
"spread/remove-useless-object": "off"
7+
}
8+
});
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
__putout_processor_json({
2+
rules: {
3+
"remove-useless-spread": "off",
4+
"remove-useless-spread/nested": "off",
5+
"remove-useless-spread/array": "off",
6+
"remove-useless-spread/object": "off",
7+
}
8+
});

packages/plugin-putout-config/test/putout-config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ test('plugin-putout-config: transform: apply-arguments', (t) => {
9797
t.end();
9898
});
9999

100+
test('plugin-putout-config: transform: apply-spread', (t) => {
101+
t.transform('apply-spread');
102+
t.end();
103+
});
104+
100105
test('plugin-putout-config: no transform: remove-empty-file', (t) => {
101106
t.noTransform('remove-empty-file');
102107
t.end();

0 commit comments

Comments
 (0)