@putout/plugin-putout 23.12.0 → 23.13.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);
@@ -91,6 +92,7 @@ npm i @putout/plugin-putout -D
91
92
  "putout/add-await-to-progress": "on",
92
93
  "putout/add-index-to-import": "on",
93
94
  "putout/apply-create-test": "on",
95
+ "putout/apply-create-nested-directory": "on",
94
96
  "putout/apply-async-formatter": "on",
95
97
  "putout/apply-declare": "on",
96
98
  "putout/apply-processors-destructuring": "on",
@@ -441,6 +443,24 @@ const test = createTest({
441
443
  });
442
444
  ```
443
445
 
446
+ ## apply-create-nested-directory
447
+
448
+ Checkout in [**Putout Editor**](https://putout.cloudcmd.io/#/gist/d97578b334963b2f573d1980a61034de/0b876a781268916344fa0ed4c19bdbc9fd7bbc3f).
449
+
450
+ ### ❌ Example of incorrect code
451
+
452
+ ```js
453
+ const dirPath = createDirectory(path, '/hello/world');
454
+ const dirPath2 = createNestedDirectory(path, 'world');
455
+ ```
456
+
457
+ ### ✅ Example of correct code
458
+
459
+ ```js
460
+ const dirPath = createNestedDirectory(path, '/hello/world');
461
+ const dirPath2 = createDirectory(path, 'world');
462
+ ```
463
+
444
464
  ## apply-for-of-to-track-file
445
465
 
446
466
  > 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
+ });
@@ -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,7 @@ 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');
66
67
 
67
68
  module.exports.rules = {
68
69
  'apply-processors-destructuring': applyProcessorsDestructuring,
@@ -128,4 +129,5 @@ module.exports.rules = {
128
129
  'declare-path-variable': declarePathVariable,
129
130
  'apply-parens': applyParens,
130
131
  'apply-lowercase-to-node-builders': applyLowercaseToNodeBuilders,
132
+ 'apply-create-nested-directory': applyCreateNestedDirectory,
131
133
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-putout",
3
- "version": "23.12.0",
3
+ "version": "23.13.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",