@putout/plugin-putout-config 5.0.0 → 6.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
@@ -13,9 +13,20 @@ npm i @putout/plugin-putout-config -D
13
13
 
14
14
  ## Rules
15
15
 
16
+ - ✅ [apply-labels][#apply-labels];
17
+ - ✅ [apply-nodejs][#apply-nodejs];
18
+ - ✅ [convert-boolean-to-string][#convert-boolean-to-string];
19
+ - ✅ [move-formatter-up][#move-formatter-up];
20
+ - ✅ [remove-empty][#remove-empty];
21
+ - ✅ [rename-property.js][#rename-property.js];
22
+
23
+ ## Config
24
+
16
25
  ```json
17
26
  {
18
27
  "rules": {
28
+ "putout-config/apply-labels": "on",
29
+ "putout-config/apply-nodejs": "on",
19
30
  "putout-config/convert-boolean-to-string": "on",
20
31
  "putout-config/move-formatter-up": "on",
21
32
  "putout-config/remove-empty": "on"
@@ -23,6 +34,58 @@ npm i @putout/plugin-putout-config -D
23
34
  }
24
35
  ```
25
36
 
37
+ ## apply-labels
38
+
39
+ Apply [`labels`](https://github.com/coderaiser/putout/tree/master/packages/plugin-labels#readme) according to 🐊[**Putout v36**](https://github.com/coderaiser/putout/releases/tag/v36.0.0). Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/9a3493fedfafdb25e86cf76af69dd003/8678f3b271ee6f6d13bceeedbe3b143f34be9f55).
40
+
41
+ ### ❌ Example of incorrect code
42
+
43
+ ```json
44
+ {
45
+ "rules": {
46
+ "remove-unused-labels": "on",
47
+ "convert-label-to-object": "on"
48
+ }
49
+ }
50
+ ```
51
+
52
+ ### ✅ Example of correct code
53
+
54
+ ```json
55
+ {
56
+ "rules": {
57
+ "labels/remove-unused": "on",
58
+ "labels/convert-to-object": "on"
59
+ }
60
+ }
61
+ ```
62
+
63
+ ## apply-nodejs
64
+
65
+ Apply [`nodejs`](https://github.com/coderaiser/putout/tree/master/packages/plugin-nodejs#readme) according to 🐊[**Putout v34**](https://github.com/coderaiser/putout/releases/tag/v34.0.0).
66
+
67
+ ### ❌ Example of incorrect code
68
+
69
+ ```json
70
+ {
71
+ "rules": {
72
+ "strict-mode/add-missing": "off",
73
+ "strict-mode/remove-useless": "off"
74
+ }
75
+ }
76
+ ```
77
+
78
+ ### ✅ Example of correct code
79
+
80
+ ```json
81
+ {
82
+ "rules": {
83
+ "nodejs/add-missing-strict-mode": "off",
84
+ "nodejs/remove-useless-strict-mode": "off"
85
+ }
86
+ }
87
+ ```
88
+
26
89
  ## convert-boolean-to-string
27
90
 
28
91
  ### ❌ Example of incorrect code
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+
3
+ const {createRenameProperty} = require('../rename-property');
4
+
5
+ module.exports = createRenameProperty([
6
+ ['remove-unused-labels', 'labels/remove-unused'],
7
+ ['convert-label-to-object', 'labels/convert-to-object'],
8
+ ]);
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+
3
+ const {createRenameProperty} = require('../rename-property');
4
+
5
+ module.exports = createRenameProperty([
6
+ ['strict-mode/add-missing', 'nodejs/add-missing-strict-mode'],
7
+ ['strict-mode/remove-useless', 'nodejs/remove-useless-strict-mode'],
8
+ ]);
package/lib/index.js CHANGED
@@ -1,11 +1,15 @@
1
1
  'use strict';
2
2
 
3
+ const applyLabels = require('./apply-labels');
4
+ const applyNodejs = require('./apply-nodejs');
3
5
  const convertBooleanToString = require('./convert-boolean-to-string');
4
6
  const removeEmpty = require('./remove-empty');
5
7
  const MoveFormatterUp = require('./move-formatter-up');
6
8
 
7
9
  module.exports.rules = {
10
+ 'apply-labels': applyLabels,
11
+ 'apply-nodejs': applyNodejs,
8
12
  'convert-boolean-to-string': convertBooleanToString,
9
- 'remove-empty': removeEmpty,
10
13
  'move-formatter-up': MoveFormatterUp,
14
+ 'remove-empty': removeEmpty,
11
15
  };
@@ -13,6 +13,7 @@ module.exports.include = () => [
13
13
  'ObjectExpression',
14
14
  'ArrayExpression',
15
15
  ];
16
+
16
17
  module.exports.filter = (path) => {
17
18
  const {parentPath, node} = path;
18
19
 
@@ -0,0 +1,34 @@
1
+ 'use strict';
2
+
3
+ const {operator} = require('putout');
4
+ const {
5
+ traverseProperties,
6
+ __json,
7
+ setLiteralValue,
8
+ } = operator;
9
+
10
+ module.exports.createRenameProperty = (tuples) => ({
11
+ report,
12
+ fix,
13
+ traverse: createTraverse(tuples),
14
+ });
15
+
16
+ const report = ({from, to}) => `Rename property: '${from}' -> '${to}'`;
17
+
18
+ const fix = ({path, to}) => {
19
+ setLiteralValue(path.node.key, to);
20
+ };
21
+
22
+ const createTraverse = (tuples) => ({push}) => ({
23
+ [__json](mainPath) {
24
+ for (const [from, to] of tuples) {
25
+ for (const path of traverseProperties(mainPath, from)) {
26
+ push({
27
+ path,
28
+ from,
29
+ to,
30
+ });
31
+ }
32
+ }
33
+ },
34
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-putout-config",
3
- "version": "5.0.0",
3
+ "version": "6.1.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,17 +32,17 @@
32
32
  "config"
33
33
  ],
34
34
  "devDependencies": {
35
- "@putout/test": "^8.0.0",
36
- "c8": "^8.0.0",
37
- "eslint": "^8.0.1",
38
- "eslint-plugin-n": "^16.0.0",
39
- "eslint-plugin-putout": "^22.0.0",
35
+ "@putout/test": "^11.0.0",
36
+ "c8": "^10.0.0",
37
+ "eslint": "^9.0.0",
38
+ "eslint-plugin-n": "^17.0.0",
39
+ "eslint-plugin-putout": "^23.0.0",
40
40
  "lerna": "^6.0.1",
41
41
  "madrun": "^10.0.0",
42
42
  "nodemon": "^3.0.1"
43
43
  },
44
44
  "peerDependencies": {
45
- "putout": ">=34"
45
+ "putout": ">=36"
46
46
  },
47
47
  "license": "MIT",
48
48
  "engines": {