@putout/plugin-printer 6.0.0 → 7.1.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
CHANGED
|
@@ -16,6 +16,7 @@ npm i @putout/plugin-printer -D
|
|
|
16
16
|
- ✅ [add-args](#add-args);
|
|
17
17
|
- ✅ [apply-breakline](#apply-breakline);
|
|
18
18
|
- ✅ [apply-computed-print](#apply-computed-print);
|
|
19
|
+
- ✅ [apply-create-test-url](#apply-create-test-url);
|
|
19
20
|
- ✅ [apply-linebreak](#apply-linebreak);
|
|
20
21
|
- ✅ [apply-types](#apply-types);
|
|
21
22
|
- ✅ [declare](#declare);
|
|
@@ -31,6 +32,7 @@ npm i @putout/plugin-printer -D
|
|
|
31
32
|
"printer/apply-breakline": "on",
|
|
32
33
|
"printer/apply-linebreak": "on",
|
|
33
34
|
"printer/apply-computed-print": "on",
|
|
35
|
+
"printer/apply-create-test-url": "on",
|
|
34
36
|
"printer/apply-types": "on",
|
|
35
37
|
"printer/declare": "on",
|
|
36
38
|
"printer/remove-args": "on"
|
|
@@ -104,6 +106,24 @@ print(path.get('block'));
|
|
|
104
106
|
print('__block');
|
|
105
107
|
```
|
|
106
108
|
|
|
109
|
+
## apply-create-test-url
|
|
110
|
+
|
|
111
|
+
Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/ddf1425ace2a53e9010b82ded1dd1012/3e56365b58d01ebe8abba46caf04ed5e51043feb).
|
|
112
|
+
|
|
113
|
+
### ❌ Example of incorrect code
|
|
114
|
+
|
|
115
|
+
```js
|
|
116
|
+
import {createTest} from '#test';
|
|
117
|
+
const {test, fixture} = createTest(__dirname);
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### ✅ Example of correct code
|
|
121
|
+
|
|
122
|
+
```js
|
|
123
|
+
import {createTest} from '#test';
|
|
124
|
+
const {test, fixture} = createTest(import.meta.url);
|
|
125
|
+
```
|
|
126
|
+
|
|
107
127
|
## remove-args
|
|
108
128
|
|
|
109
129
|
### ❌ Example of incorrect code
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {operator} from 'putout';
|
|
2
|
+
|
|
3
|
+
const {isESM} = operator;
|
|
4
|
+
|
|
5
|
+
export const report = () => `Use 'import.meta.url' instead of '__dirname'`;
|
|
6
|
+
|
|
7
|
+
export const match = () => ({
|
|
8
|
+
'const {test, fixture} = createTest(__dirname)': (vars, path) => isESM(path),
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export const replace = () => ({
|
|
12
|
+
'const {test, fixture} = createTest(__dirname)': 'const {test, fixture} = createTest(import.meta.url)',
|
|
13
|
+
});
|
package/lib/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as applyCreateTestUrl from './apply-create-test-url/index.js';
|
|
1
2
|
import * as removeArgs from './remove-args/index.js';
|
|
2
3
|
import * as applyBreakline from './apply-breakline/index.js';
|
|
3
4
|
import * as applyLinebreak from './apply-linebreak/index.js';
|
|
@@ -16,4 +17,5 @@ export const rules = {
|
|
|
16
17
|
declare,
|
|
17
18
|
'apply-types': applyTypes,
|
|
18
19
|
'remove-legacy-test-declaration': removeLegacyTestDeclaration,
|
|
20
|
+
'apply-create-test-url': applyCreateTestUrl,
|
|
19
21
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {operator} from 'putout';
|
|
2
2
|
|
|
3
|
-
const {
|
|
4
|
-
|
|
3
|
+
const {compare} = operator;
|
|
5
4
|
const EXTEND = `
|
|
6
5
|
const test = extend({
|
|
7
6
|
print: printExtension,
|
|
@@ -25,13 +24,15 @@ export const replace = () => ({
|
|
|
25
24
|
});
|
|
26
25
|
|
|
27
26
|
function check(vars, path) {
|
|
28
|
-
let is = true;
|
|
29
27
|
const programPath = path.scope.getProgramParent().path;
|
|
30
28
|
|
|
31
|
-
|
|
32
|
-
'module.exports.createTest = (__args) => __body'
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
29
|
+
for (const current of programPath.node.body) {
|
|
30
|
+
if (compare(current, 'module.exports.createTest = (__args) => __body'))
|
|
31
|
+
return false;
|
|
32
|
+
|
|
33
|
+
if (compare(current, 'export const createTest = (__args) => __body'))
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return true;
|
|
37
38
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/plugin-printer",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "🐊Putout plugin adds support of transformations for @putout/printer",
|
|
@@ -34,25 +34,25 @@
|
|
|
34
34
|
"printer"
|
|
35
35
|
],
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@putout/eslint-flat": "^
|
|
37
|
+
"@putout/eslint-flat": "^4.0.0",
|
|
38
38
|
"@putout/plugin-declare-before-reference": "*",
|
|
39
39
|
"@putout/plugin-for-of": "*",
|
|
40
40
|
"@putout/plugin-remove-nested-blocks": "*",
|
|
41
|
-
"@putout/test": "^
|
|
41
|
+
"@putout/test": "^15.0.0",
|
|
42
42
|
"c8": "^10.0.0",
|
|
43
|
-
"eslint": "^
|
|
43
|
+
"eslint": "^10.0.0-alpha.0",
|
|
44
44
|
"eslint-plugin-n": "^17.0.0",
|
|
45
|
-
"eslint-plugin-putout": "^
|
|
46
|
-
"madrun": "^
|
|
45
|
+
"eslint-plugin-putout": "^30.0.0",
|
|
46
|
+
"madrun": "^12.0.0",
|
|
47
47
|
"montag": "^1.2.1",
|
|
48
48
|
"nodemon": "^3.0.1"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"putout": ">=
|
|
51
|
+
"putout": ">=41"
|
|
52
52
|
},
|
|
53
53
|
"license": "MIT",
|
|
54
54
|
"engines": {
|
|
55
|
-
"node": ">=
|
|
55
|
+
"node": ">=22"
|
|
56
56
|
},
|
|
57
57
|
"publishConfig": {
|
|
58
58
|
"access": "public"
|