-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathindex.js
45 lines (37 loc) · 1.04 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
'use strict';
const { getParser } = require('codemod-cli').jscodeshift;
const { addImportStatement, writeImportStatements } = require('../utils');
module.exports = function transformer(file, api) {
const j = getParser(api);
const root = j(file.source);
/**
* Replace deprecated this.render() with render() from '@ember/test-helpers' package
*/
function transform() {
root
.find(j.CallExpression, {
callee: {
type: 'MemberExpression',
object: {
type: 'ThisExpression',
},
property: {
type: 'Identifier',
name: 'render',
},
},
})
.replaceWith((path) => {
let oldCallExpressionArguments = path.node.arguments;
return j.callExpression(j.identifier('render'), oldCallExpressionArguments);
});
let newImports = ['render'];
addImportStatement(newImports);
writeImportStatements(j, root);
}
transform();
return root.toSource({
quote: 'single',
trailingComma: true,
});
};