Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'use strict';
const { getParser } = require('codemod-cli').jscodeshift;
const { createFindExpression, isJQuerySelectExpression, addImportStatement, writeImportStatements } = require('../../utils');
/**
* Creates a `find(selector).textContent` expression
*
* @param j
* @param findArgs
* @returns {*}
*/
function createExpression(j, findArgs) {
return j.memberExpression(
createFindExpression(j, findArgs),
j.identifier('textContent')
);
}
'use strict';
const { getParser } = require('codemod-cli').jscodeshift;
const { createFindExpression, createPropExpression, isJQuerySelectExpression, addImportStatement, writeImportStatements } = require('../../utils');
/**
* Creates a `find(selector).getAttribute(attr)` expression
*
* @param j
* @param findArgs
* @param attr
* @returns {*}
*/
function createAttributeExpression(j, findArgs, attr) {
return j.callExpression(
j.memberExpression(
createFindExpression(j, findArgs),
j.identifier('getAttribute')
), [attr]
'use strict';
const { getParser } = require('codemod-cli').jscodeshift;
const {
createFindAllExpression,
isJQuerySelectExpression,
addImportStatement,
writeImportStatements,
} = require('../../utils');
/**
* Creates a `findAll(selector)[0]` expression
*
* @param j
* @param findArgs
* @param indexArg
* @returns {*}
*/
function createExpression(j, findArgs, indexArg) {
'use strict';
const { getParser } = require('codemod-cli').jscodeshift;
const { createClickExpression, makeParentFunctionAsync, isJQuerySelectExpression, addImportStatement, writeImportStatements } = require('../../utils');
/**
* Check if `node` is a `this.$(selector).click()` expression
*
* @param j
* @param node
* @returns {*|boolean}
*/
function isJQueryExpression(j, path) {
let node = path.node;
return j.CallExpression.check(node)
&& j.MemberExpression.check(node.callee)
&& isJQuerySelectExpression(j, node.callee.object, path)
&& j.Identifier.check(node.callee.property)
&& node.callee.property.name === 'click';
'use strict';
const { getParser } = require('codemod-cli').jscodeshift;
const { createQuerySelectorExpression, createQuerySelectorAllExpression } = require('../utils');
/**
* Transform find/findAll to this.element.querySelector/-All
*
* @param file
* @param api
* @returns {*|string}
*/
function transform(file, api) {
let source = file.source;
let j = getParser(api);
let root = j(source);
let importStatement = root.find(j.ImportDeclaration, {
source: { value: '@ember/test-helpers' }
'use strict';
const { getParser } = require('codemod-cli').jscodeshift;
const { createFindExpression, isFindExpression, addImportStatement, writeImportStatements } = require('../../utils');
/**
* Creates a `find(selector).value` expression
*
* @param j
* @param findArgs
* @returns {*}
*/
function createExpression(j, findArgs) {
return j.memberExpression(
createFindExpression(j, findArgs),
j.identifier('value')
);
}
'use strict';
const { getParser } = require('codemod-cli').jscodeshift;
const { migrateSelector, makeParentFunctionAsync, isJQuerySelectExpression, addImportStatement, writeImportStatements } = require('../../utils');
/**
* Creates a `await keyEvent(selector, eventName, keyCode)` expression
*
* @param j
* @param selector
* @param eventName
* @param keyCode
* @returns {*}
*/
function createExpression(j, selector, eventName, keyCode) {
return j.awaitExpression(
j.callExpression(
j.identifier('keyEvent'),
[migrateSelector(j, selector), eventName, keyCode]
'use strict';
const { getParser } = require('codemod-cli').jscodeshift;
const { addImportStatement, writeImportStatements } = require('../utils');
const importMigrations = [
'click',
'find',
'findAll',
'fillIn',
'focus',
'blur',
'triggerEvent',
['keyEvent', 'triggerKeyEvent'],
'waitFor',
'waitUntil',
'currentURL',
'currentRouteName',
'visit'
'use strict';
const { getParser } = require('codemod-cli').jscodeshift;
const { makeParentFunctionAsync, createTriggerExpression, createClickExpression, isJQuerySelectExpression, addImportStatement, writeImportStatements } = require('../../utils');
/**
* Check if `node` is a `this.$(selector).trigger(eventName)` expression
*
* @param j
* @param node
* @returns {*|boolean}
*/
function isJQueryExpression(j, path) {
let node = path.node;
return j.CallExpression.check(node)
&& j.MemberExpression.check(node.callee)
&& isJQuerySelectExpression(j, node.callee.object, path)
&& j.Identifier.check(node.callee.property)
&& node.callee.property.name === 'trigger'
const { getParser } = require('codemod-cli').jscodeshift;
const { getOptions } = require('codemod-cli');
module.exports = function transformer(file, api) {
const j = getParser(api);
const options = getOptions();
const root = j(file.source);
root
.find(j.CallExpression, {
callee: {
object: {
callee: {
object: {
type: "ThisExpression"
},
property: {