Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports = function transformer(file, api) {
const j = getParser(api);
const options = getOptions();
const root = j(file.source);
const createInit = (props, exp1, exp2) => {
// First create the super call for init
let superCall = j.expressionStatement(
j.callExpression(j.memberExpression(j.thisExpression(), j.identifier("_super"), false), [
j.identifier("...arguments")
])
);
let initProp = j.objectMethod("method", j.identifier("init"), [], j.blockStatement([superCall, exp1, exp2]));
props.push(initProp);
};
function transform(file, api) {
let source = file.source;
let j = getParser(api);
let root = j(source);
let replacements = root
.find(j.CallExpression)
.filter(({ node }) => isGlobalHelperExpression(j, node))
;
if (replacements.length > 0) {
makeAwait(j, replacements);
dropAndThen(j, root);
addImportStatement(['click']);
}
writeImportStatements(j, root);
return root.toSource({ quote: 'single' });
function transform(file, api) {
let source = file.source;
let j = getParser(api);
let root = j(source);
let replacements = root
.find(j.CallExpression)
.filter(({ node }) => isGlobalHelperExpression(j, node))
;
if (replacements.length > 0) {
makeAwait(j, replacements);
dropAndThen(j, root);
addImportStatement(['visit']);
}
writeImportStatements(j, root);
return root.toSource({ quote: 'single' });
function transform(file, api) {
let source = file.source;
let j = getParser(api);
let root = j(source);
let replacements = root
.find(j.CallExpression)
.filter((path) => isJQueryExpression(j, path))
.replaceWith(({ node }) => createExpression(j, node.callee.object.arguments));
if (replacements.length > 0) {
addImportStatement(['find']);
}
writeImportStatements(j, root);
return root.toSource({quote: 'single'});
}
function transform(file, api) {
let source = file.source;
let j = getParser(api);
let root = j(source);
let replacements = root
.find(j.CallExpression)
.filter((path) => isJQueryExpression(j, path))
.replaceWith(({ node }) => createExpression(j, node.callee.object.arguments[0], node.arguments[0], node.arguments[1].properties[0].value))
.forEach((path) => makeParentFunctionAsync(j, path))
;
if (replacements.length > 0) {
addImportStatement(['keyEvent']);
}
writeImportStatements(j, root);
return root.toSource({ quote: 'single' });
function transform(file, api) {
let source = file.source;
let j = getParser(api);
let root = j(source);
let propReplacements = root
.find(j.CallExpression)
.filter((path) => isJQueryExpression(j, path))
.filter(({ node }) => isPropertyAccessPreferred(j, node))
.replaceWith(({ node }) => createPropExpression(j, node.callee.object.arguments, node.arguments[0].value));
let attrReplacements = root
.find(j.CallExpression)
.filter((path) => isJQueryExpression(j, path))
.filter(({ node }) => !isPropertyAccessPreferred(j, node))
.replaceWith(({ node }) => createAttributeExpression(j, node.callee.object.arguments, node.arguments[0]));
if (propReplacements.length > 0 || attrReplacements.length > 0) {
function transform(file, api) {
let source = file.source;
let j = getParser(api);
let root = j(source);
let replacements = root
.find(j.CallExpression)
.filter(({ node }) => isAnEqExpression(j, node))
.replaceWith(({ node }) => {
let eqExpression = migrateSelector(j, node.arguments[0]);
node.arguments = [ eqExpression, ...node.arguments.slice(1) ];
return node;
})
;
if (replacements.length > 0) {
addImportStatement(['findAll']);
}
function transform(file, api) {
let source = file.source;
let j = getParser(api);
let root = j(source);
let replacements = root
.find(j.CallExpression)
.filter((path) => isJQueryExpression(j, path))
.replaceWith(({ node }) => createPropExpression(j, node.callee.object.arguments, node.arguments[0].value))
;
if (replacements.length > 0) {
addImportStatement(['find']);
}
writeImportStatements(j, root);
return root.toSource({ quote: 'single' });
}
function transform(file, api) {
let source = file.source;
let j = getParser(api);
let root = j(source);
let nativeDomImportStatements = root.find(j.ImportDeclaration, {
source: { value: 'ember-native-dom-helpers' }
});
if (nativeDomImportStatements.length === 0) {
return root.toSource({ quote: 'single' });
}
let newImports = [];
nativeDomImportStatements.forEach((importStatement) => {
let oldSpecifiers = importStatement.get('specifiers');
let newSpecifiers = [];
oldSpecifiers.each(({ node: specifier }) => {
function transform(file, api) {
let source = file.source;
let j = getParser(api);
let root = j(source);
let replacements = root
.find(j.CallExpression)
.filter(({ node }) => isJQueryExpression(j, node))
.replaceWith(({ node }) => createExpression(j, node.callee.object.arguments, node.arguments[0]));
if (replacements.length > 0) {
addImportStatement(['find']);
}
writeImportStatements(j, root);
return root.toSource({ quote: 'single' });
}