Skip to content

Commit 005b1d7

Browse files
committed
feature: @putout/plugin-putout: drop support of recast
1 parent 925f010 commit 005b1d7

File tree

8 files changed

+3
-122
lines changed

8 files changed

+3
-122
lines changed

packages/plugin-putout/lib/convert-replace-with-multiple/fixture/recast-replace-with-multiple-fix.js

Lines changed: 0 additions & 19 deletions
This file was deleted.

packages/plugin-putout/lib/convert-replace-with-multiple/fixture/recast-replace-with-multiple.js

Lines changed: 0 additions & 15 deletions
This file was deleted.

packages/plugin-putout/lib/convert-replace-with-multiple/index.js

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,10 @@ const {
66
types,
77
} = require('putout');
88

9-
const {
10-
insertAfter,
11-
replaceWith,
12-
insertBefore,
13-
} = operator;
9+
const {replaceWith, insertBefore} = operator;
1410

1511
const {Identifier, ObjectProperty} = types;
1612

17-
const isRecast = (program) => program.get('body.0').get('expression')
18-
.isStringLiteral({
19-
value: 'use strict',
20-
});
21-
2213
module.exports.report = () => {
2314
return `"operate.replaceWithMultiple" should be called instead of "path.replaceWithMultiple"`;
2415
};
@@ -37,12 +28,8 @@ module.exports.fix = ({path, calleePath, property, object, program}) => {
3728
if (bindings.replaceWithMultiple)
3829
return;
3930

40-
if (!bindings.replaceWith && !bindings.insertAfter) {
41-
if (isRecast(program))
42-
return insertAfter(first, replaceWithAST);
43-
31+
if (!bindings.replaceWith && !bindings.insertAfter)
4432
return insertBefore(first, replaceWithAST);
45-
}
4633

4734
const id = Identifier('replaceWithMultiple');
4835
const varPath = getVarPath(bindings);

packages/plugin-putout/lib/convert-replace-with-multiple/recast.spec.js

Lines changed: 0 additions & 16 deletions
This file was deleted.

packages/plugin-putout/lib/convert-replace-with/fixture/recast-replace-with-fix.js

Lines changed: 0 additions & 19 deletions
This file was deleted.

packages/plugin-putout/lib/convert-replace-with/fixture/recast-replace-with.js

Lines changed: 0 additions & 15 deletions
This file was deleted.

packages/plugin-putout/lib/convert-replace-with/index.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ const {
1515
insertBefore,
1616
} = operator;
1717

18-
const isRecast = (program) => program.get('body.0.expression').isStringLiteral({
19-
value: 'use strict',
20-
});
21-
2218
module.exports.report = () => {
2319
return `Use 'operator.replaceWith()' instead of 'path.replaceWith()'`;
2420
};
@@ -41,9 +37,7 @@ module.exports.fix = ({path, calleePath, property, object, program, isInserted})
4137
const first = program.get('body.0');
4238
const pathToInsert = types ? types.path.parentPath : first;
4339

44-
if (isRecast(program))
45-
insertAfter(pathToInsert, replaceWithAST);
46-
else if (types)
40+
if (types)
4741
insertAfter(pathToInsert, replaceWithAST);
4842
else
4943
insertBefore(pathToInsert, replaceWithAST);

packages/plugin-putout/lib/convert-replace-with/recast.spec.js

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)