@putout/plugin-putout 23.12.0 → 23.14.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
@@ -23,6 +23,7 @@ npm i @putout/plugin-putout -D
23
23
  - ✅ [add-track-file](#add-track-file);
24
24
  - ✅ [apply-async-formatter](#apply-async-formatter);
25
25
  - ✅ [apply-create-test](#apply-create-test);
26
+ - ✅ [apply-create-nested-directory](#apply-create-nested-directory);
26
27
  - ✅ [apply-declare](#apply-declare);
27
28
  - ✅ [apply-for-of-to-track-file](#apply-for-of-to-track-file);
28
29
  - ✅ [apply-fixture-name-to-message](#apply-fixture-name-to-message);
@@ -31,6 +32,7 @@ npm i @putout/plugin-putout -D
31
32
  - ✅ [apply-vars](#apply-vars);
32
33
  - ✅ [apply-lowercase-to-node-builders](#apply-lowercase-to-node-builders);
33
34
  - ✅ [apply-namespace-specifier](#apply-namespace-specifier);
35
+ - ✅ [apply-report](#apply-report);
34
36
  - ✅ [apply-processors-destructuring](#apply-processors-destructuring);
35
37
  - ✅ [apply-remove](#apply-remove);
36
38
  - ✅ [apply-rename](#apply-rename);
@@ -91,8 +93,10 @@ npm i @putout/plugin-putout -D
91
93
  "putout/add-await-to-progress": "on",
92
94
  "putout/add-index-to-import": "on",
93
95
  "putout/apply-create-test": "on",
96
+ "putout/apply-create-nested-directory": "on",
94
97
  "putout/apply-async-formatter": "on",
95
98
  "putout/apply-declare": "on",
99
+ "putout/apply-report": "on",
96
100
  "putout/apply-processors-destructuring": "on",
97
101
  "putout/apply-rename": "on",
98
102
  "putout/apply-parens": "on",
@@ -164,6 +168,56 @@ path.node = Identifier('x');
164
168
  path.node = identifier('x');
165
169
  ```
166
170
 
171
+ ## apply-report
172
+
173
+ Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/e9debc0b256556a632fb031be86afffc/afefbd44443f07dbb7d8f2972f2e40a9a82c214f).
174
+
175
+ ### ❌ Example of incorrect code
176
+
177
+ ```js
178
+ t.noReport('rename-files-full', {
179
+ from: ['/'],
180
+ to: [],
181
+ });
182
+
183
+ t.noReportWithOptions('rename-files-full');
184
+
185
+ t.noReport('a', 'Use b');
186
+ t.report('a');
187
+ ```
188
+
189
+ ### ✅ Example of correct code
190
+
191
+ ```js
192
+ t.noReportWithOptons('rename-files-full', {
193
+ from: ['/'],
194
+ to: [],
195
+ });
196
+
197
+ t.noReport('rename-files-full');
198
+
199
+ t.report('a', 'Use b');
200
+ t.noReport('a');
201
+ ```
202
+
203
+ ## apply-processors-destructuring
204
+
205
+ ### ❌ Example of incorrect code
206
+
207
+ ```js
208
+ test('', async (t) => {
209
+ await t.process({});
210
+ });
211
+ ```
212
+
213
+ ### ✅ Example of correct code
214
+
215
+ ```js
216
+ test('', async ({process}) => {
217
+ await process({});
218
+ });
219
+ ```
220
+
167
221
  ## apply-processors-destructuring
168
222
 
169
223
  ### ❌ Example of incorrect code
@@ -441,6 +495,24 @@ const test = createTest({
441
495
  });
442
496
  ```
443
497
 
498
+ ## apply-create-nested-directory
499
+
500
+ Checkout in [**Putout Editor**](https://putout.cloudcmd.io/#/gist/d97578b334963b2f573d1980a61034de/0b876a781268916344fa0ed4c19bdbc9fd7bbc3f).
501
+
502
+ ### ❌ Example of incorrect code
503
+
504
+ ```js
505
+ const dirPath = createDirectory(path, '/hello/world');
506
+ const dirPath2 = createNestedDirectory(path, 'world');
507
+ ```
508
+
509
+ ### ✅ Example of correct code
510
+
511
+ ```js
512
+ const dirPath = createNestedDirectory(path, '/hello/world');
513
+ const dirPath2 = createDirectory(path, 'world');
514
+ ```
515
+
444
516
  ## apply-for-of-to-track-file
445
517
 
446
518
  > The **Generator** object is returned by a `generator function` and it conforms to both the iterable protocol and the `iterator` protocol.
@@ -0,0 +1,34 @@
1
+ 'use strict';
2
+
3
+ const {types} = require('putout');
4
+ const {isStringLiteral} = types;
5
+
6
+ const NESTED = {
7
+ createDirectory: 'createNestedDirectory',
8
+ createNestedDirectory: 'createDirectory',
9
+ };
10
+
11
+ module.exports.report = (path) => {
12
+ const {name} = path.node.callee;
13
+ return `Use '${NESTED[name]}()' instead of '${name}()'`;
14
+ };
15
+
16
+ module.exports.match = () => ({
17
+ 'createDirectory(__a, __b)': ({__b}) => {
18
+ if (!isStringLiteral(__b))
19
+ return false;
20
+
21
+ return __b.value.includes('/');
22
+ },
23
+ 'createNestedDirectory(__a, __b)': ({__b}) => {
24
+ if (!isStringLiteral(__b))
25
+ return false;
26
+
27
+ return !__b.value.includes('/');
28
+ },
29
+ });
30
+
31
+ module.exports.replace = () => ({
32
+ 'createDirectory(__a, __b)': 'createNestedDirectory(__a, __b)',
33
+ 'createNestedDirectory(__a, __b)': 'createDirectory(__a, __b)',
34
+ });
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+
3
+ const {operator} = require('putout');
4
+ const {compare} = operator;
5
+ const TYPES = {
6
+ noReport: 'noReportWithOptions',
7
+ report: 'noReport',
8
+ noReportWithOptions: 'noReport',
9
+ };
10
+
11
+ module.exports.report = (path) => {
12
+ const {name} = path.node.callee.property;
13
+
14
+ if (compare(path, 't.noReport(__a, "__b")'))
15
+ return `Use 't.noReport(__a)' instead of 't.noReport(__a, "__b")'`;
16
+
17
+ return `Use '${TYPES[name]}()' instead of '${name}()'`;
18
+ };
19
+
20
+ module.exports.replace = () => ({
21
+ 't.noReport(__a, __object)': 't.noReportWithOptons(__a, __object)',
22
+ 't.noReport(__a, "__b")': 't.noReport(__a)',
23
+ 't.report(__a)': 't.noReport(__a)',
24
+ 't.noReportWithOptions(__a)': 't.noReport(__a)',
25
+ });
@@ -8,6 +8,7 @@ module.exports = {
8
8
  moveFile: 'const {moveFile} = operator',
9
9
  createFile: 'const {createFile} = operator',
10
10
  createDirectory: 'const {createDirectory} = operator',
11
+ createNestedDirectory: 'const {createNestedDirectory} = operator',
11
12
  getParentDirectory: 'const {getParentDirectory} = operator',
12
13
  readFileContent: 'const {readFileContent} = operator',
13
14
  writeFileContent: 'const {writeFileContent} = operator',
package/lib/index.js CHANGED
@@ -63,6 +63,8 @@ const declareTemplateVariables = require('./declare-template-variables');
63
63
  const declarePathVariable = require('./declare-path-variable');
64
64
  const applyParens = require('./apply-parens');
65
65
  const applyLowercaseToNodeBuilders = require('./apply-lowercase-to-node-builders');
66
+ const applyCreateNestedDirectory = require('./apply-create-nested-directory');
67
+ const applyReport = require('./apply-report');
66
68
 
67
69
  module.exports.rules = {
68
70
  'apply-processors-destructuring': applyProcessorsDestructuring,
@@ -128,4 +130,6 @@ module.exports.rules = {
128
130
  'declare-path-variable': declarePathVariable,
129
131
  'apply-parens': applyParens,
130
132
  'apply-lowercase-to-node-builders': applyLowercaseToNodeBuilders,
133
+ 'apply-create-nested-directory': applyCreateNestedDirectory,
134
+ 'apply-report': applyReport,
131
135
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-putout",
3
- "version": "23.12.0",
3
+ "version": "23.14.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",