@putout/plugin-printer 4.2.0 → 4.3.0
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 +25 -0
- package/lib/declare/index.js +3 -0
- package/lib/index.js +2 -0
- package/lib/remove-legacy-test-declaration/index.js +38 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,6 +20,7 @@ npm i @putout/plugin-printer -D
|
|
|
20
20
|
- ✅ [apply-types](#apply-types);
|
|
21
21
|
- ✅ [declare](#declare);
|
|
22
22
|
- ✅ [remove-args](#remove-args);
|
|
23
|
+
- ✅ [remove-legacy-test-declaration](#remove-legacy-test-declaration);
|
|
23
24
|
|
|
24
25
|
## Config
|
|
25
26
|
|
|
@@ -123,15 +124,39 @@ print.indent();
|
|
|
123
124
|
|
|
124
125
|
```js
|
|
125
126
|
isIdentifier();
|
|
127
|
+
|
|
128
|
+
test('', (t) => {
|
|
129
|
+
t.print(fixture.returnStatement);
|
|
130
|
+
});
|
|
126
131
|
```
|
|
127
132
|
|
|
128
133
|
### ✅ Example of correct code
|
|
129
134
|
|
|
130
135
|
```js
|
|
131
136
|
const {types} = require('@putout/babel');
|
|
137
|
+
const {createTest} = require('#test');
|
|
138
|
+
|
|
139
|
+
const {test, fixture} = createTest(__dirname);
|
|
132
140
|
const {isIdentifier} = types;
|
|
133
141
|
|
|
134
142
|
isIdentifier();
|
|
143
|
+
|
|
144
|
+
test('', (t) => {
|
|
145
|
+
t.print(fixture.returnStatement);
|
|
146
|
+
});
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## remove-legacy-test-declaration
|
|
150
|
+
|
|
151
|
+
```diff
|
|
152
|
+
-const {printExtension} = require('../../../test/printer');
|
|
153
|
+
-const {readFixtures} = require('../../../test/fixture');
|
|
154
|
+
-
|
|
155
|
+
-const fixture = readFixtures(__dirname);
|
|
156
|
+
-
|
|
157
|
+
-const test = extend({
|
|
158
|
+
- print: printExtension,
|
|
159
|
+
-});
|
|
135
160
|
```
|
|
136
161
|
|
|
137
162
|
## License
|
package/lib/declare/index.js
CHANGED
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
const types = require('@putout/plugin-putout/declare/types');
|
|
4
4
|
|
|
5
5
|
module.exports.declare = () => ({
|
|
6
|
+
createTest: `const {createTest} = require('#test')`,
|
|
7
|
+
test: 'const {test} = createTest(__dirname)',
|
|
8
|
+
fixture: 'const {fixture} = createTest(__dirname)',
|
|
6
9
|
types: `import {types} from '@putout/babel'`,
|
|
7
10
|
...types,
|
|
8
11
|
});
|
package/lib/index.js
CHANGED
|
@@ -7,6 +7,7 @@ const applyComputedPrint = require('./apply-computed-print');
|
|
|
7
7
|
const addArgs = require('./add-args');
|
|
8
8
|
const declare = require('./declare');
|
|
9
9
|
const applyTypes = require('./apply-types');
|
|
10
|
+
const removeLegacyTestDeclaration = require('./remove-legacy-test-declaration');
|
|
10
11
|
|
|
11
12
|
module.exports.rules = {
|
|
12
13
|
'remove-args': removeArgs,
|
|
@@ -16,4 +17,5 @@ module.exports.rules = {
|
|
|
16
17
|
'add-args': addArgs,
|
|
17
18
|
declare,
|
|
18
19
|
'apply-types': applyTypes,
|
|
20
|
+
'remove-legacy-test-declaration': removeLegacyTestDeclaration,
|
|
19
21
|
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const {operator} = require('putout');
|
|
4
|
+
const {traverse} = operator;
|
|
5
|
+
|
|
6
|
+
const EXTEND = `
|
|
7
|
+
const test = extend({
|
|
8
|
+
print: printExtension,
|
|
9
|
+
})
|
|
10
|
+
`;
|
|
11
|
+
|
|
12
|
+
module.exports.report = () => `Remove legacy test declaration`;
|
|
13
|
+
|
|
14
|
+
module.exports.match = () => ({
|
|
15
|
+
'const fixture = __': check,
|
|
16
|
+
'const {printExtension} = __': check,
|
|
17
|
+
'const {readFixtures} = __': check,
|
|
18
|
+
[EXTEND]: check,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
module.exports.replace = () => ({
|
|
22
|
+
'const fixture = __': '',
|
|
23
|
+
'const {printExtension} = __': '',
|
|
24
|
+
'const {readFixtures} = __': '',
|
|
25
|
+
[EXTEND]: '',
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
function check(vars, path) {
|
|
29
|
+
let is = true;
|
|
30
|
+
const programPath = path.scope.getProgramParent().path;
|
|
31
|
+
|
|
32
|
+
traverse(programPath, {
|
|
33
|
+
'module.exports.createTest = (__args) => __body': () => {
|
|
34
|
+
is = false;
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
return is;
|
|
38
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/plugin-printer",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.3.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "🐊Putout plugin adds support of transformations for @putout/printer",
|