@putout/plugin-putout-config 4.1.0 → 5.0.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.
|
@@ -1,42 +1,60 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const {operator} = require('putout');
|
|
3
|
+
const {operator, types} = require('putout');
|
|
4
|
+
const {ObjectProperty} = types;
|
|
4
5
|
const {
|
|
5
6
|
insertAfter,
|
|
6
7
|
remove,
|
|
7
8
|
getProperties,
|
|
8
|
-
|
|
9
|
+
__json,
|
|
9
10
|
} = operator;
|
|
10
11
|
|
|
11
12
|
module.exports.report = () => `Move 'formatter' up`;
|
|
12
13
|
|
|
13
14
|
module.exports.match = () => ({
|
|
14
|
-
|
|
15
|
+
[__json]: (vars, path) => {
|
|
15
16
|
const objectPath = path.get('arguments.0');
|
|
16
|
-
const
|
|
17
|
+
const {
|
|
18
|
+
formatterPath,
|
|
19
|
+
parserPath,
|
|
20
|
+
printerPath,
|
|
21
|
+
} = getProperties(objectPath, ['formatter', 'parser', 'printer']);
|
|
17
22
|
|
|
18
23
|
if (!formatterPath)
|
|
19
24
|
return false;
|
|
20
25
|
|
|
21
|
-
const next = formatterPath.getNextSibling()
|
|
22
|
-
const prev = formatterPath.getPrevSibling()
|
|
26
|
+
const next = formatterPath.getNextSibling();
|
|
27
|
+
const prev = formatterPath.getPrevSibling();
|
|
23
28
|
|
|
24
|
-
|
|
29
|
+
if (prev === parserPath)
|
|
30
|
+
return false;
|
|
31
|
+
|
|
32
|
+
if (prev === printerPath)
|
|
33
|
+
return false;
|
|
34
|
+
|
|
35
|
+
return !next.node && prev.node;
|
|
25
36
|
},
|
|
26
37
|
});
|
|
27
38
|
|
|
28
39
|
module.exports.replace = () => ({
|
|
29
|
-
|
|
40
|
+
[__json]: (vars, path) => {
|
|
30
41
|
const objectPath = path.get('arguments.0');
|
|
31
|
-
const {
|
|
42
|
+
const {
|
|
43
|
+
formatterPath,
|
|
44
|
+
parserPath,
|
|
45
|
+
printerPath,
|
|
46
|
+
} = getProperties(objectPath, ['formatter', 'parser', 'printer']);
|
|
32
47
|
|
|
33
|
-
const {
|
|
48
|
+
const {key, value} = formatterPath.node;
|
|
49
|
+
const node = ObjectProperty(key, value);
|
|
34
50
|
|
|
35
51
|
remove(formatterPath);
|
|
36
52
|
|
|
37
|
-
if (!parserPath)
|
|
53
|
+
if (!parserPath && !printerPath)
|
|
38
54
|
objectPath.node.properties.unshift(node);
|
|
39
|
-
else if (!
|
|
55
|
+
else if (printerPath && !printerPath.getPrevSibling().node)
|
|
56
|
+
insertAfter(printerPath, node);
|
|
57
|
+
else if (parserPath && !parserPath.getPrevSibling().node)
|
|
40
58
|
insertAfter(parserPath, node);
|
|
41
59
|
|
|
42
60
|
return path;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/plugin-putout-config",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "🐊Putout plugin helps to maintain putout config",
|
|
@@ -32,21 +32,21 @@
|
|
|
32
32
|
"config"
|
|
33
33
|
],
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@putout/test": "^
|
|
35
|
+
"@putout/test": "^8.0.0",
|
|
36
36
|
"c8": "^8.0.0",
|
|
37
37
|
"eslint": "^8.0.1",
|
|
38
38
|
"eslint-plugin-n": "^16.0.0",
|
|
39
|
-
"eslint-plugin-putout": "^
|
|
39
|
+
"eslint-plugin-putout": "^22.0.0",
|
|
40
40
|
"lerna": "^6.0.1",
|
|
41
|
-
"madrun": "^
|
|
41
|
+
"madrun": "^10.0.0",
|
|
42
42
|
"nodemon": "^3.0.1"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"putout": ">=
|
|
45
|
+
"putout": ">=34"
|
|
46
46
|
},
|
|
47
47
|
"license": "MIT",
|
|
48
48
|
"engines": {
|
|
49
|
-
"node": ">=
|
|
49
|
+
"node": ">=18"
|
|
50
50
|
},
|
|
51
51
|
"publishConfig": {
|
|
52
52
|
"access": "public"
|