@putout/plugin-putout-config 5.0.0 → 6.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.
package/README.md CHANGED
@@ -13,9 +13,18 @@ npm i @putout/plugin-putout-config -D
13
13
 
14
14
  ## Rules
15
15
 
16
+ - ✅ [apply-labels][#apply-labels];
17
+ - ✅ [convert-boolean-to-string][#convert-boolean-to-string];
18
+ - ✅ [move-formatter-up][#move-formatter-up];
19
+ - ✅ [remove-empty][#remove-empty];
20
+ - ✅ [rename-property.js][#rename-property.js];
21
+
22
+ ## Config
23
+
16
24
  ```json
17
25
  {
18
26
  "rules": {
27
+ "putout-config/apply-labels": "on",
19
28
  "putout-config/convert-boolean-to-string": "on",
20
29
  "putout-config/move-formatter-up": "on",
21
30
  "putout-config/remove-empty": "on"
@@ -23,6 +32,32 @@ npm i @putout/plugin-putout-config -D
23
32
  }
24
33
  ```
25
34
 
35
+ ## apply-labels
36
+
37
+ 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)
38
+
39
+ ### ❌ Example of incorrect code
40
+
41
+ ```json
42
+ {
43
+ "rules": {
44
+ "remove-unused-labels": "on",
45
+ "convert-label-to-object": "on"
46
+ }
47
+ }
48
+ ```
49
+
50
+ ### ✅ Example of correct code
51
+
52
+ ```json
53
+ {
54
+ "rules": {
55
+ "labels/remove-unused": "on",
56
+ "labels/convert-to-object": "on"
57
+ }
58
+ }
59
+ ```
60
+
26
61
  ## convert-boolean-to-string
27
62
 
28
63
  ### ❌ 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
+ ]);
package/lib/index.js CHANGED
@@ -3,9 +3,11 @@
3
3
  const convertBooleanToString = require('./convert-boolean-to-string');
4
4
  const removeEmpty = require('./remove-empty');
5
5
  const MoveFormatterUp = require('./move-formatter-up');
6
+ const applyLabels = require('./apply-labels');
6
7
 
7
8
  module.exports.rules = {
9
+ 'apply-labels': applyLabels,
8
10
  'convert-boolean-to-string': convertBooleanToString,
9
- 'remove-empty': removeEmpty,
10
11
  'move-formatter-up': MoveFormatterUp,
12
+ 'remove-empty': removeEmpty,
11
13
  };
@@ -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.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,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": {