@putout/plugin-putout 20.10.0 → 21.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-putout -D
16
16
  - ✅ [add-await-to-progress](#add-await-to-progress);
17
17
  - ✅ [add-index-to-import](#add-index-to-import);
18
18
  - ✅ [add-places-to-compare-places](#add-places-to-compare-places);
19
+ - ✅ [add-path-arg-to-fix](#add-path-arg-to-fix);
19
20
  - ✅ [add-test-args](#add-test-args);
20
21
  - ✅ [add-traverse-args](#add-traverse-args);
21
22
  - ✅ [add-track-file](#add-track-file);
@@ -71,6 +72,13 @@ npm i @putout/plugin-putout -D
71
72
  ```json
72
73
  {
73
74
  "rules": {
75
+ "putout/add-places-to-compare-places": "on",
76
+ "putout/add-path-arg-to-fix": "on",
77
+ "putout/add-test-args": "on",
78
+ "putout/add-traverse-args": "on",
79
+ "putout/add-track-file": "on",
80
+ "putout/add-await-to-progress": "on",
81
+ "putout/add-index-to-import": "on",
74
82
  "putout/apply-create-test": "on",
75
83
  "putout/apply-processors-destructuring": "on",
76
84
  "putout/apply-async-formatter": "on",
@@ -82,12 +90,6 @@ npm i @putout/plugin-putout -D
82
90
  "putout/apply-short-processors": "on",
83
91
  "putout/apply-namespace-specifier": "on",
84
92
  "putout/apply-for-of-to-track-file": "on",
85
- "putout/add-places-to-compare-places": "on",
86
- "putout/add-test-args": "on",
87
- "putout/add-traverse-args": "on",
88
- "putout/add-track-file": "on",
89
- "putout/add-await-to-progress": "on",
90
- "putout/add-index-to-import": "on",
91
93
  "putout/check-match": "on",
92
94
  "putout/check-replace-code": ["on", {
93
95
  "once": true
@@ -820,6 +822,26 @@ comparePlaces('hello');
820
822
  comparePlaces('hello', []);
821
823
  ```
822
824
 
825
+ ## add-path-arg-to-fix
826
+
827
+ Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/3d3fb6b8f5e5376cdd1674c9b19e0e27/4872f77e680a2fc443618f4bf5fae3ffab11046a).
828
+
829
+ ### ❌ Example of incorrect code
830
+
831
+ ```js
832
+ export const fix = () => {
833
+ path.remove();
834
+ };
835
+ ```
836
+
837
+ ### ✅ Example of correct code
838
+
839
+ ```js
840
+ export const fix = (path) => {
841
+ path.remove();
842
+ };
843
+ ```
844
+
823
845
  ## add-test-args
824
846
 
825
847
  ### ❌ Example of incorrect code
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+
3
+ module.exports.report = () => `Add 'path' argument to 'fix'`;
4
+
5
+ module.exports.replace = () => ({
6
+ 'const fix = () => __a': 'const fix = (path) => __a',
7
+ 'module.exports.fix = () => {}': 'module.exports.fix = (path) => {}',
8
+ });
@@ -22,12 +22,14 @@ module.exports.match = () => ({
22
22
  if (__aPath.isBlockStatement())
23
23
  return false;
24
24
 
25
- for (const propertyPath of __aPath.get('properties')) {
26
- if (isPush(propertyPath) || isBlock(propertyPath))
27
- return true;
25
+ const properties = __aPath.get('properties');
26
+
27
+ for (const propertyPath of properties) {
28
+ if (!isPush(propertyPath) && !isBlock(propertyPath))
29
+ return false;
28
30
  }
29
31
 
30
- return false;
32
+ return true;
31
33
  },
32
34
  });
33
35
 
@@ -35,8 +37,9 @@ module.exports.replace = () => ({
35
37
  'module.exports.traverse = __a': (vars, path) => {
36
38
  const node = template.ast.fresh('module.exports.include = () => []');
37
39
  const __aPath = path.get('right.body');
40
+ const properties = __aPath.get('properties');
38
41
 
39
- for (const propertyPath of __aPath.get('properties')) {
42
+ for (const propertyPath of properties) {
40
43
  const name = getName(propertyPath);
41
44
 
42
45
  if (isPush(propertyPath) || isBlock(propertyPath)) {
package/lib/index.js CHANGED
@@ -52,6 +52,7 @@ const removeUnusedGetPropertiesArgument = require('./remove-unused-get-propertie
52
52
  const simplifyReplaceTemplate = require('./simplify-replace-template');
53
53
  const removeEmptyArrayFromProcess = require('./remove-empty-array-from-process');
54
54
  const addPlacesToComparePlaces = require('./add-places-to-compare-places');
55
+ const addPathArgToFix = require('./add-path-arg-to-fix');
55
56
 
56
57
  module.exports.rules = {
57
58
  'apply-processors-destructuring': applyProcessorsDestructuring,
@@ -106,4 +107,5 @@ module.exports.rules = {
106
107
  'simplify-replace-template': simplifyReplaceTemplate,
107
108
  'remove-empty-array-from-process': removeEmptyArrayFromProcess,
108
109
  'add-places-to-compare-places': addPlacesToComparePlaces,
110
+ 'add-path-arg-to-fix': addPathArgToFix,
109
111
  };
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
2
 
3
3
  const justCamelCase = require('just-camel-case');
4
-
5
4
  const {types, template} = require('putout');
6
5
 
7
6
  const TEST = `
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-putout",
3
- "version": "20.10.0",
3
+ "version": "21.1.0",
4
4
  "type": "commonjs",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "🐊Putout plugin helps with plugins development",
@@ -26,7 +26,7 @@
26
26
  },
27
27
  "dependencies": {
28
28
  "fullstore": "^3.0.0",
29
- "just-camel-case": "^6.0.1",
29
+ "just-camel-case": "^6.2.0",
30
30
  "parse-import-specifiers": "^1.0.2",
31
31
  "try-catch": "^3.0.0"
32
32
  },
@@ -38,11 +38,11 @@
38
38
  ],
39
39
  "devDependencies": {
40
40
  "@putout/plugin-tape": "*",
41
- "@putout/test": "^10.0.0",
41
+ "@putout/test": "^11.0.0",
42
42
  "c8": "^10.0.0",
43
43
  "eslint": "^9.0.0",
44
44
  "eslint-plugin-n": "^17.0.0",
45
- "eslint-plugin-putout": "^22.0.0",
45
+ "eslint-plugin-putout": "^23.0.0",
46
46
  "lerna": "^6.0.1",
47
47
  "madrun": "^10.0.0",
48
48
  "montag": "^1.2.1",
@@ -50,7 +50,7 @@
50
50
  "supertape": "^10.0.0"
51
51
  },
52
52
  "peerDependencies": {
53
- "putout": ">=35"
53
+ "putout": ">=36"
54
54
  },
55
55
  "license": "MIT",
56
56
  "engines": {