Skip to content

Commit 5b39158

Browse files
committed
feature: @putout/plugin-putout-config: apply-parens
1 parent f64bb95 commit 5b39158

File tree

15 files changed

+157
-1
lines changed

15 files changed

+157
-1
lines changed

packages/plugin-putout-config/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ npm i @putout/plugin-putout-config -D
1515

1616
-[apply-conditions](#apply-conditions);
1717
-[apply-esm](#apply-esm);
18+
-[apply-parens](#apply-parens);
1819
-[apply-for-of](#apply-for-of);
1920
-[apply-labels](#apply-labels);
2021
-[apply-math](#apply-math);
@@ -42,6 +43,7 @@ npm i @putout/plugin-putout-config -D
4243
"putout-config/apply-math": "on",
4344
"putout-config/apply-nodejs": "on",
4445
"putout-config/apply-optional-chaining": "on",
46+
"putout-config/apply-parens": "on",
4547
"putout-config/apply-tape": "on",
4648
"putout-config/apply-types": "on",
4749
"putout-config/apply-promises": "on",
@@ -79,6 +81,21 @@ Apply [`esm`](https://github.com/coderaiser/putout/tree/master/packages/plugin-e
7981
}
8082
```
8183

84+
## apply-parens
85+
86+
Apply [`parens`](https://github.com/coderaiser/putout/tree/master/packages/plugin-parens#readme) according to:
87+
88+
- 🐊[**Putout v37**](https://github.com/coderaiser/putout/releases/tag/v37.0.0):
89+
90+
```diff
91+
{
92+
"rules": {
93+
- "add-missing-parens": "on"
94+
+ "parens/add-missing": "on"
95+
}
96+
}
97+
```
98+
8299
## apply-optional-chaining
83100

84101
Apply [`optional-chaining`](https://github.com/coderaiser/putout/tree/master/packages/plugin-optional-chaining#readme) according to:
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
__putout_processor_json({
2+
"rules": {
3+
"esm/remove-empty-import": "on",
4+
"esm/remove-empty-export": "on",
5+
"esm/group-imports-by-source": "on",
6+
"esm/declare-imports-first": "on",
7+
"esm/remove-quotes-from-import-assertions": "on",
8+
"esm/merge-duplicate-imports": "on"
9+
}
10+
});
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
__putout_processor_json({
2+
"rules": {
3+
"remove-empty/import": "on",
4+
"remove-empty/export": "on",
5+
"group-imports-by-source": "on",
6+
"declare-imports-first": "on",
7+
"remove-quotes-from-import-assertions": "on",
8+
"merge-duplicate-imports": "on"
9+
}
10+
});
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
'use strict';
2+
3+
const {createRenameProperty} = require('../rename-property');
4+
5+
const v37 = [
6+
['remove-empty/import', 'esm/remove-empty-import'],
7+
['remove-empty/export', 'esm/remove-empty-export'],
8+
['group-imports-by-source', 'esm/group-imports-by-source'],
9+
['declare-imports-first', 'esm/declare-imports-first'],
10+
['remove-quotes-from-import-assertions', 'esm/remove-quotes-from-import-assertions'],
11+
['merge-duplicate-imports', 'esm/merge-duplicate-imports'],
12+
];
13+
14+
module.exports = createRenameProperty(v37);
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
'use strict';
2+
3+
const {createTest} = require('@putout/test');
4+
const plugin = require('.');
5+
6+
const test = createTest(__dirname, {
7+
printer: 'putout',
8+
plugins: [
9+
['apply-esm', plugin],
10+
],
11+
});
12+
13+
test('putout-config: apply-esm: report', (t) => {
14+
t.report('apply-esm', `Rename property: 'remove-empty/import' -> 'esm/remove-empty-import'`);
15+
t.end();
16+
});
17+
18+
test('putout-config: apply-esm: transform', (t) => {
19+
t.transform('apply-esm');
20+
t.end();
21+
});
22+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
__putout_processor_json({
2+
"rules": {
3+
"parens/add-missing": "on"
4+
}
5+
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
__putout_processor_json({
2+
"rules": {
3+
"add-missing-parens": "on"
4+
}
5+
});
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
'use strict';
2+
3+
const {createRenameProperty} = require('../rename-property');
4+
5+
const v37 = [
6+
['add-missing-parens', 'parens/add-missing'],
7+
];
8+
9+
module.exports = createRenameProperty(v37);
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
'use strict';
2+
3+
const {createTest} = require('@putout/test');
4+
const plugin = require('.');
5+
6+
const test = createTest(__dirname, {
7+
plugins: [
8+
['apply-parens', plugin],
9+
],
10+
});
11+
12+
test('putout-config: apply-parens: report', (t) => {
13+
t.report('apply-parens', `Rename property: 'add-missing-parens' -> 'parens/add-missing'`);
14+
t.end();
15+
});
16+
17+
test('putout-config: apply-parens: transform', (t) => {
18+
t.transform('apply-parens');
19+
t.end();
20+
});
21+

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
'use strict';
22

33
const applyConditions = require('./apply-conditions');
4+
const applyEsm = require('./apply-esm');
45
const applyOptionalChaining = require('./apply-optional-chaining');
6+
const applyParens = require('./apply-parens');
57
const applyForOf = require('./apply-for-of');
68
const applyLabels = require('./apply-labels');
79
const applyMath = require('./apply-math');
@@ -17,11 +19,13 @@ const removeEmptyFile = require('./remove-empty-file');
1719

1820
module.exports.rules = {
1921
'apply-conditions': applyConditions,
22+
'apply-esm': applyEsm,
2023
'apply-for-of': applyForOf,
2124
'apply-labels': applyLabels,
2225
'apply-math': applyMath,
2326
'apply-nodejs': applyNodejs,
2427
'apply-optional-chaining': applyOptionalChaining,
28+
'apply-parens': applyParens,
2529
'apply-promises': applyPromises,
2630
'apply-tape': applyTape,
2731
'apply-types': applyTypes,

0 commit comments

Comments
 (0)