@putout/plugin-cloudcmd 4.0.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.
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # @putout/plugin-cloudcmd [![NPM version][NPMIMGURL]][NPMURL]
2
2
 
3
3
  [NPMIMGURL]: https://img.shields.io/npm/v/@putout/plugin-cloudcmd.svg?style=flat&longCache=true
4
- [NPMURL]: https://npmjs.org/package/@putout/plugin-cloudcmd"npm"
4
+ [NPMURL]: https://npmjs.org/package/@putout/plugin-cloudcmd "npm"
5
5
 
6
6
  🐊[**Putout**](https://github.com/coderaiser/putout) plugin adds ability to transform to new [Cloud Commander](https://cloudcmd.io) API.
7
7
 
@@ -11,7 +11,14 @@
11
11
  npm i putout @putout/plugin-cloudcmd -D
12
12
  ```
13
13
 
14
- Add `.putout.json` with:
14
+ ## Rules
15
+
16
+ - βœ… [convert-io-mv-to-io-move](#convert-io-mv-to-io-move);
17
+ - βœ… [convert-io-cp-to-io-copy](#convert-io-cp-to-io-copy);
18
+ - βœ… [convert-load-dir-to-change-dir](#convert-load-dir-to-change-dir);
19
+ - βœ… [convert-arrow-to-declaration](#convert-arrow-to-declaration);
20
+
21
+ ## Config
15
22
 
16
23
  ```json
17
24
  {
@@ -28,7 +35,8 @@ Add `.putout.json` with:
28
35
  "rules": {
29
36
  "cloudcmd/convert-io-mv-to-io-move": "on",
30
37
  "cloudcmd/convert-io-cp-to-io-copy": "on",
31
- "cloudcmd/convert-load-dir-to-change-dir": "on"
38
+ "cloudcmd/convert-load-dir-to-change-dir": "on",
39
+ "cloudcmd/convert-arrow-to-declaration": "on"
32
40
  }
33
41
  }
34
42
  ```
@@ -104,6 +112,52 @@ await CloudCmd.changeDir('/', {
104
112
  });
105
113
  ```
106
114
 
115
+ # convert-arrow-to-declaration
116
+
117
+ Because right now all exported methods saved to global variable on top of a file.
118
+
119
+ ```js
120
+ CloudCmd.EditNamesVim = {
121
+ init,
122
+ show,
123
+ hide,
124
+ };
125
+ ```
126
+
127
+ Check out in 🐊[Putout Editor](https://putout.cloudcmd.io/#/gist/8c21c0599b5d4d7c5faf49f3da604c9e/04a71d323fe1b0c25c1f34635c6f15eff805eff7).
128
+
129
+ ## ❌ Example of incorrect code
130
+
131
+ ```js
132
+ export const init = async (hello) => {
133
+ await CloudCmd.EditNames();
134
+ };
135
+
136
+ export const show = () => {
137
+ Events.addKey(listener);
138
+ };
139
+
140
+ export const hide = () => {
141
+ CloudCmd.Edit.hide();
142
+ };
143
+ ```
144
+
145
+ ## βœ… Example of correct code
146
+
147
+ ```js
148
+ export async function init(hello) {
149
+ await CloudCmd.EditNames();
150
+ }
151
+
152
+ export function show() {
153
+ Events.addKey(listener);
154
+ }
155
+
156
+ export function hide() {
157
+ CloudCmd.Edit.hide();
158
+ }
159
+ ```
160
+
107
161
  ## License
108
162
 
109
163
  MIT
@@ -0,0 +1,17 @@
1
+ export const report = () => `Use 'declaration' instead 'arrow' for 'init/show/hide'`;
2
+
3
+ export const match = () => ({
4
+ 'export const __a = async (__args) => __body': isClientModule,
5
+ 'export const __a = (__args) => __body': isClientModule,
6
+ });
7
+
8
+ export const replace = () => ({
9
+ 'export const __a = async (__args) => __body': 'export async function __a(__args) {__body}',
10
+ 'export const __a = (__args) => __body': 'export function __a(__args) {__body}',
11
+ });
12
+
13
+ const isClientModule = ({__a}) => {
14
+ const {name} = __a;
15
+
16
+ return /^(init|show|hide)$/.test(name);
17
+ };
package/lib/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ import * as convertArrowToDeclaration from './convert-arrow-to-declaration/index.js';
1
2
  import * as convertIoMvToIoMove from './convert-io-mv-to-io-move/index.js';
2
3
  import * as convertIoCpToIoCopy from './convert-io-cp-to-io-copy/index.js';
3
4
  import * as convertIoWriteToIoCreateDirectory from './convert-io-write-to-io-create-directory/index.js';
@@ -8,4 +9,5 @@ export const rules = {
8
9
  'convert-io-cp-to-io-copy': convertIoCpToIoCopy,
9
10
  'convert-io-write-to-io-create-directory': convertIoWriteToIoCreateDirectory,
10
11
  'convert-load-dir-to-change-dir': convertLoadDirToChangeDir,
12
+ 'convert-arrow-to-declaration': convertArrowToDeclaration,
11
13
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-cloudcmd",
3
- "version": "4.0.0",
3
+ "version": "5.0.0",
4
4
  "type": "module",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "🐊Putout plugin adds ability to transform code to new API of Cloud Commander",
@@ -31,23 +31,22 @@
31
31
  "cloudcmd"
32
32
  ],
33
33
  "devDependencies": {
34
- "@putout/eslint-flat": "^3.0.0",
34
+ "@putout/eslint-flat": "^4.0.0",
35
35
  "@putout/plugin-remove-unused-expressions": "*",
36
- "@putout/plugin-strict-mode": "*",
37
- "@putout/test": "^13.0.0",
36
+ "@putout/test": "^15.0.0",
38
37
  "c8": "^10.0.0",
39
- "eslint": "^9.0.0",
38
+ "eslint": "^10.0.0-alpha.0",
40
39
  "eslint-plugin-n": "^17.0.0",
41
- "eslint-plugin-putout": "^26.0.0",
42
- "madrun": "^11.0.0",
40
+ "eslint-plugin-putout": "^30.0.0",
41
+ "madrun": "^12.0.0",
43
42
  "nodemon": "^3.0.1"
44
43
  },
45
44
  "peerDependencies": {
46
- "putout": ">=39"
45
+ "putout": ">=41"
47
46
  },
48
47
  "license": "MIT",
49
48
  "engines": {
50
- "node": ">=20"
49
+ "node": ">=22"
51
50
  },
52
51
  "publishConfig": {
53
52
  "access": "public"