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);
};
module.exports = function transformer(file, api) {
const extension = path.extname(file.path);
if (!['.js', '.ts'].includes(extension.toLowerCase())) {
// do nothing on non-js/ts files
return;
}
const j = api.jscodeshift;
const options = Object.assign({}, DEFAULT_OPTIONS, getOptions());
let { source } = file;
const root = j(source);
const replaced = replaceEmberObjectExpressions(j, root, file.path, options);
if (replaced) {
source = root.toSource({
quote: options.quotes || options.quote,
});
}
return source;
};
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);
};
(async () => {
await gatherTelemetryForUrl(process.argv[2], analyzeEmberObject);
require('codemod-cli').runTransform(
__dirname,
'angle-brackets' /* transform name */,
process.argv.slice(2) /* paths or globs */,
'hbs'
);
})();
(async () => {
await gatherTelemetryForUrl(process.argv[2], analyzeEmberObject);
require('codemod-cli').runTransform(
__dirname,
'ember-object',
process.argv.slice(2) /* paths or globs */
);
})();
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' });
'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) {