@putout/plugin-putout 23.0.0 → 23.0.1

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.
@@ -29,7 +29,10 @@ module.exports.traverse = ({push}) => ({
29
29
  if (!statement)
30
30
  return;
31
31
 
32
- const forOfCount = statement.parentPath.get('body').filter(isForOfStatement).length;
32
+ const forOfCount = statement.parentPath
33
+ .get('body')
34
+ .filter(isForOfStatement)
35
+ .length;
33
36
 
34
37
  if (forOfCount > 1)
35
38
  return;
@@ -15,10 +15,6 @@ const {
15
15
  insertBefore,
16
16
  } = operator;
17
17
 
18
- const isRecast = (program) => program.get('body.0.expression').isStringLiteral({
19
- value: 'use strict',
20
- });
21
-
22
18
  module.exports.report = () => {
23
19
  return `Use 'operator.replaceWith()' instead of 'path.replaceWith()'`;
24
20
  };
@@ -41,9 +37,7 @@ module.exports.fix = ({path, calleePath, property, object, program, isInserted})
41
37
  const first = program.get('body.0');
42
38
  const pathToInsert = types ? types.path.parentPath : first;
43
39
 
44
- if (isRecast(program))
45
- insertAfter(pathToInsert, replaceWithAST);
46
- else if (types)
40
+ if (types)
47
41
  insertAfter(pathToInsert, replaceWithAST);
48
42
  else
49
43
  insertBefore(pathToInsert, replaceWithAST);
@@ -6,19 +6,10 @@ const {
6
6
  types,
7
7
  } = require('putout');
8
8
 
9
- const {
10
- insertAfter,
11
- replaceWith,
12
- insertBefore,
13
- } = operator;
9
+ const {replaceWith, insertBefore} = operator;
14
10
 
15
11
  const {Identifier, ObjectProperty} = types;
16
12
 
17
- const isRecast = (program) => program.get('body.0').get('expression')
18
- .isStringLiteral({
19
- value: 'use strict',
20
- });
21
-
22
13
  module.exports.report = () => {
23
14
  return `"operate.replaceWithMultiple" should be called instead of "path.replaceWithMultiple"`;
24
15
  };
@@ -37,12 +28,8 @@ module.exports.fix = ({path, calleePath, property, object, program}) => {
37
28
  if (bindings.replaceWithMultiple)
38
29
  return;
39
30
 
40
- if (!bindings.replaceWith && !bindings.insertAfter) {
41
- if (isRecast(program))
42
- return insertAfter(first, replaceWithAST);
43
-
31
+ if (!bindings.replaceWith && !bindings.insertAfter)
44
32
  return insertBefore(first, replaceWithAST);
45
- }
46
33
 
47
34
  const id = Identifier('replaceWithMultiple');
48
35
  const varPath = getVarPath(bindings);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-putout",
3
- "version": "23.0.0",
3
+ "version": "23.0.1",
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",