@putout/plugin-putout 11.14.0 β 12.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -1
- package/lib/apply-declare/index.js +8 -0
- package/lib/check-replace-code/generate-code.js +3 -1
- package/lib/check-replace-code/index.js +3 -2
- package/lib/declare/index.js +8 -4
- package/lib/index.js +1 -0
- package/lib/move-require-on-top-level/index.js +2 -1
- package/lib/replace-test-message/index.js +0 -1
- package/package.json +3 -4
- package/lib/declare/declarations.js +0 -12
package/README.md
CHANGED
|
@@ -20,6 +20,7 @@ npm i @putout/plugin-putout -D
|
|
|
20
20
|
"putout/apply-processors-destructuring": "on",
|
|
21
21
|
"putout/apply-async-formatter": "on",
|
|
22
22
|
"putout/apply-remove": "on",
|
|
23
|
+
"putout/apply-declare": "on",
|
|
23
24
|
"putout/add-args": "on",
|
|
24
25
|
"putout/add-push": "on",
|
|
25
26
|
"putout/convert-putout-test-to-create-test": "on",
|
|
@@ -93,6 +94,32 @@ export const fix = (path) => {
|
|
|
93
94
|
};
|
|
94
95
|
```
|
|
95
96
|
|
|
97
|
+
## apply-declare
|
|
98
|
+
|
|
99
|
+
Better to use [`Declareator`](https://github.com/coderaiser/putout/tree/master/packages/engine-runner#declarator) instead of `operator.declare()`.
|
|
100
|
+
Check out in π[**Putout Editor**](https://putout.cloudcmd.io/#/gist/cf35de5e80e8f7aad866358a50c5eded/0af6142fc9c9e71ac2a2aa96cb85613dd95c9fbf).
|
|
101
|
+
|
|
102
|
+
### β Example of incorrect code
|
|
103
|
+
|
|
104
|
+
```js
|
|
105
|
+
const {operator} = require('putout');
|
|
106
|
+
const {declare} = operator;
|
|
107
|
+
|
|
108
|
+
module.exports = declare({
|
|
109
|
+
tryCatch: `import tryCatch from 'try-catch'`,
|
|
110
|
+
tryToCatch: `import tryToCatch from 'try-to-catch'`,
|
|
111
|
+
});
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### β
Example of correct code
|
|
115
|
+
|
|
116
|
+
```js
|
|
117
|
+
module.exports.declare = () => ({
|
|
118
|
+
tryCatch: `import tryCatch from 'try-catch'`,
|
|
119
|
+
tryToCatch: `import tryToCatch from 'try-to-catch'`,
|
|
120
|
+
});
|
|
121
|
+
```
|
|
122
|
+
|
|
96
123
|
## apply-async-formatter
|
|
97
124
|
|
|
98
125
|
### β Example of incorrect code
|
|
@@ -444,7 +471,7 @@ This is additional tests, if you forget to test some case (from a big list of ru
|
|
|
444
471
|
## declare
|
|
445
472
|
|
|
446
473
|
Depends on [@putout/convert-esm-to-commonjs](https://github.com/coderaiser/putout/tree/master/packages/plugin-convert-esm-to-commonjs#readme) and
|
|
447
|
-
[@putout/declare
|
|
474
|
+
[@putout/declare](https://github.com/coderaiser/putout/tree/master/packages/plugin-declare#readme).
|
|
448
475
|
|
|
449
476
|
### β Example of incorrect code
|
|
450
477
|
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
const putout = require('putout');
|
|
4
4
|
const tryCatch = require('try-catch');
|
|
5
5
|
|
|
6
|
+
const noop = () => {};
|
|
7
|
+
|
|
6
8
|
const {types, operator} = putout;
|
|
7
9
|
const {replaceWith} = operator;
|
|
8
10
|
const {
|
|
@@ -19,7 +21,7 @@ module.exports = (rootPath, key) => {
|
|
|
19
21
|
isTS: true,
|
|
20
22
|
plugins: [
|
|
21
23
|
['generate', {
|
|
22
|
-
report:
|
|
24
|
+
report: noop,
|
|
23
25
|
include: () => [
|
|
24
26
|
'Identifier',
|
|
25
27
|
'StringLiteral',
|
|
@@ -5,8 +5,9 @@ const tryCatch = require('try-catch');
|
|
|
5
5
|
|
|
6
6
|
const generateCode = require('./generate-code');
|
|
7
7
|
|
|
8
|
-
const
|
|
8
|
+
const noop = () => {};
|
|
9
9
|
|
|
10
|
+
const {operator} = putout;
|
|
10
11
|
const {
|
|
11
12
|
compare,
|
|
12
13
|
extract,
|
|
@@ -80,7 +81,7 @@ module.exports.traverse = ({push}) => ({
|
|
|
80
81
|
isTS: true,
|
|
81
82
|
plugins: [
|
|
82
83
|
['evaluate', {
|
|
83
|
-
report:
|
|
84
|
+
report: noop,
|
|
84
85
|
replace: () => ({
|
|
85
86
|
[key]: template,
|
|
86
87
|
}),
|
package/lib/declare/index.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const {declare} = operator;
|
|
3
|
+
const types = require('./types');
|
|
4
|
+
const operator = require('./operator');
|
|
6
5
|
|
|
7
|
-
module.exports =
|
|
6
|
+
module.exports.declare = () => ({
|
|
7
|
+
template: `import {template} from 'putout'`,
|
|
8
|
+
createTest: `import {createTest} from '@putout/test'`,
|
|
9
|
+
...operator,
|
|
10
|
+
...types,
|
|
11
|
+
});
|
|
8
12
|
|
package/lib/index.js
CHANGED
|
@@ -9,6 +9,7 @@ module.exports.rules = {
|
|
|
9
9
|
...getRule('apply-async-formatter'),
|
|
10
10
|
...getRule('apply-create-test'),
|
|
11
11
|
...getRule('apply-remove'),
|
|
12
|
+
...getRule('apply-declare'),
|
|
12
13
|
...getRule('convert-putout-test-to-create-test'),
|
|
13
14
|
...getRule('convert-to-no-transform-code'),
|
|
14
15
|
...getRule('convert-find-to-traverse'),
|
|
@@ -22,13 +22,14 @@ const {
|
|
|
22
22
|
Identifier,
|
|
23
23
|
isIdentifier,
|
|
24
24
|
isObjectExpression,
|
|
25
|
+
isMemberExpression,
|
|
25
26
|
} = types;
|
|
26
27
|
|
|
27
28
|
module.exports.report = () => 'Move require on top level';
|
|
28
29
|
|
|
29
30
|
module.exports.match = () => ({
|
|
30
31
|
[TEST]: ({__b}) => !isIdentifier(__b),
|
|
31
|
-
[TRANSFORM]: ({__b}) => !isIdentifier(__b) && !isObjectExpression(__b),
|
|
32
|
+
[TRANSFORM]: ({__b}) => !isIdentifier(__b) && !isObjectExpression(__b) && !isMemberExpression(__b),
|
|
32
33
|
});
|
|
33
34
|
|
|
34
35
|
module.exports.replace = () => ({
|
package/package.json
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/plugin-putout",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "12.0.1",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "πPutout plugin helps with plugins development",
|
|
7
7
|
"homepage": "https://github.com/coderaiser/putout/tree/master/packages/plugin-putout#readme",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
|
-
"commitType": "colon",
|
|
10
9
|
"release": false,
|
|
11
10
|
"tag": false,
|
|
12
11
|
"changelog": false,
|
|
@@ -37,7 +36,7 @@
|
|
|
37
36
|
"putout"
|
|
38
37
|
],
|
|
39
38
|
"devDependencies": {
|
|
40
|
-
"@putout/test": "^
|
|
39
|
+
"@putout/test": "^6.0.0",
|
|
41
40
|
"c8": "^7.5.0",
|
|
42
41
|
"eslint": "^8.0.1",
|
|
43
42
|
"eslint-plugin-n": "^15.2.4",
|
|
@@ -48,7 +47,7 @@
|
|
|
48
47
|
"nodemon": "^2.0.1"
|
|
49
48
|
},
|
|
50
49
|
"peerDependencies": {
|
|
51
|
-
"putout": ">=
|
|
50
|
+
"putout": ">=29"
|
|
52
51
|
},
|
|
53
52
|
"license": "MIT",
|
|
54
53
|
"engines": {
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const types = require('./types');
|
|
4
|
-
const operator = require('./operator');
|
|
5
|
-
|
|
6
|
-
module.exports = {
|
|
7
|
-
template: `import {template} from 'putout'`,
|
|
8
|
-
createTest: `import {createTest} from '@putout/test'`,
|
|
9
|
-
...operator,
|
|
10
|
-
...types,
|
|
11
|
-
};
|
|
12
|
-
|