Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
language: node_js
node_js:
- "8"
- "10"

sudo: false
dist: trusty
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
},
"dependencies": {
"codemod-cli": "^2.0.0",
"ember-codemods-telemetry-helpers": "^1.0.0",
"ember-codemods-telemetry-helpers": "^2.0.0",
"fs-extra": "^8.0.1",
"git-repo-info": "^2.1.0",
"minimatch": "^3.0.4",
Expand All @@ -56,7 +56,7 @@
"release-it-lerna-changelog": "^2.1.2"
},
"engines": {
"node": "8.* || 10.* || >= 12.*"
"node": "10.* || 12.* || >= 14"
},
"publishConfig": {
"registry": "https://registry.npmjs.org"
Expand Down
4 changes: 2 additions & 2 deletions test/run-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ const execOpts = { cwd: inputDir, stderr: 'inherit' };
const emberServe = spawn('yarn', ['start'], execOpts);
emberServe.stderr.pipe(process.stderr);

await new Promise(resolve => {
emberServe.stdout.on('data', data => {
await new Promise((resolve) => {
emberServe.stdout.on('data', (data) => {
if (data.toString().includes('Build successful')) {
resolve();
}
Expand Down
14 changes: 7 additions & 7 deletions transforms/helpers/EOProp.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class EOProp {
if (
kind === 'init' &&
this.hasDecorators &&
this.decorators.find(d => d.importedName === 'computed')
this.decorators.find((d) => d.importedName === 'computed')
) {
kind = 'get';
}
Expand Down Expand Up @@ -122,7 +122,7 @@ class EOProp {
}

get decoratorNames() {
return this.decorators.map(d => d.name);
return this.decorators.map((d) => d.name);
}

get classDecoratorName() {
Expand Down Expand Up @@ -157,15 +157,15 @@ class EOProp {
}

get hasModifierWithArgs() {
return this.modifiers.some(modifier => modifier.args.length);
return this.modifiers.some((modifier) => modifier.args.length);
}

get hasVolatile() {
return this.modifiers.some(modifier => get(modifier, 'prop.name') === 'volatile');
return this.modifiers.some((modifier) => get(modifier, 'prop.name') === 'volatile');
}

get hasReadOnly() {
return this.modifiers.some(modifier => get(modifier, 'prop.name') === 'readOnly');
return this.modifiers.some((modifier) => get(modifier, 'prop.name') === 'readOnly');
}

get isVolatileReadOnly() {
Expand Down Expand Up @@ -205,11 +205,11 @@ class EOProp {
}

get hasMethodDecorator() {
return this.decorators.find(d => d.isMethodDecorator);
return this.decorators.find((d) => d.isMethodDecorator);
}

get hasMetaDecorator() {
return this.decorators.find(d => d.isMetaDecorator);
return this.decorators.find((d) => d.isMetaDecorator);
}
}

Expand Down
11 changes: 9 additions & 2 deletions transforms/helpers/decorator-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,14 @@ function createCallExpressionDecorators(j, decoratorName, instanceProp) {
* @returns {Decorator[]}
*/
function createDecoratorsWithArgs(j, identifier, args) {
return [j.decorator(j.callExpression(j.identifier(identifier), args.map(arg => j.literal(arg))))];
return [
j.decorator(
j.callExpression(
j.identifier(identifier),
args.map((arg) => j.literal(arg))
)
),
];
}

/**
Expand All @@ -104,7 +111,7 @@ function createIdentifierDecorators(j, identifier = 'action') {
function createBindingDecorators(j, decoratorName, instanceProp) {
const propList = get(instanceProp, 'propList');
if (propList && propList.length) {
const propArgs = propList.map(prop => j.literal(prop));
const propArgs = propList.map((prop) => j.literal(prop));
return [j.decorator(j.callExpression(j.identifier(decoratorName), propArgs))];
}
return [j.decorator(j.identifier(decoratorName))];
Expand Down
8 changes: 4 additions & 4 deletions transforms/helpers/import-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ function createNewImportDeclarations(

// Create new import statements which do not have any matching existing imports
Object.keys(EMBER_DECORATOR_SPECIFIERS)
.filter(path => !decoratorPathsToIgnore.includes(path))
.forEach(path => {
.filter((path) => !decoratorPathsToIgnore.includes(path))
.forEach((path) => {
const specifiers = createEmberDecoratorSpecifiers(
j,
EMBER_DECORATOR_SPECIFIERS[path],
Expand Down Expand Up @@ -219,7 +219,7 @@ function getDecoratorPathSpecifiers(j, root, decoratorsToImport = []) {
existingSpecifier
);
} else {
const isSpecifierPresent = decoratedSpecifiers.some(specifier => {
const isSpecifierPresent = decoratedSpecifiers.some((specifier) => {
return (
!get(specifier, 'local.name') &&
get(specifier, 'imported.name') === get(existingSpecifier, 'imported.name')
Expand Down Expand Up @@ -291,7 +291,7 @@ function createDecoratorImportDeclarations(j, root, decoratorsToImport = [], opt
const firstDeclaration = getFirstDeclaration(j, root);
const decoratorPathsImported = Object.keys(decoratorPathSpecifierMap);
// Create import statement replacing the existing ones with specifiers importing from ember-decorators namespace
decoratorPathsImported.forEach(decoratorPath => {
decoratorPathsImported.forEach((decoratorPath) => {
const specifiers = decoratorPathSpecifierMap[decoratorPath];
const existingImport = getExistingImportForPath(j, root, decoratorPath);
if (existingImport) {
Expand Down
2 changes: 1 addition & 1 deletion transforms/helpers/log-helper.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { createLogger, format, transports } = require('winston');
const { combine, timestamp, printf } = format;

const logFormatter = printf(info => {
const logFormatter = printf((info) => {
return `${info.timestamp} [${info.level}] ${info.message}`;
});

Expand Down
10 changes: 5 additions & 5 deletions transforms/helpers/parse-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function getEmberObjectProps(j, eoExpression, importedDecoratedProps = {}, runti

return {
instanceProps: objProps.map(
objProp => new EOProp(objProp, runtimeData, importedDecoratedProps)
(objProp) => new EOProp(objProp, runtimeData, importedDecoratedProps)
),
};
}
Expand Down Expand Up @@ -65,7 +65,7 @@ function getEmberObjectCallExpressions(j, root) {
return root
.find(j.CallExpression, { callee: { property: { name: 'extend' } } })
.filter(
eoCallExpression =>
(eoCallExpression) =>
startsWithUpperCaseLetter(get(eoCallExpression, 'value.callee.object.name')) &&
get(eoCallExpression, 'parentPath.value.type') !== 'ClassDeclaration'
);
Expand Down Expand Up @@ -155,7 +155,7 @@ function parseEmberObjectCallExpression(eoCallExpression) {
eoExpression: null,
mixins: [],
};
callExpressionArgs.forEach(callExpressionArg => {
callExpressionArgs.forEach((callExpressionArg) => {
if (callExpressionArg.type === 'ObjectExpression') {
props.eoExpression = callExpressionArg;
} else {
Expand Down Expand Up @@ -197,7 +197,7 @@ function replaceEmberObjectExpressions(j, root, filePath, options = {}) {
let transformed = false;
let decoratorsToImportMap = {};

getEmberObjectCallExpressions(j, root).forEach(eoCallExpression => {
getEmberObjectCallExpressions(j, root).forEach((eoCallExpression) => {
const { eoExpression, mixins } = parseEmberObjectCallExpression(eoCallExpression);

const eoProps = getEmberObjectProps(
Expand Down Expand Up @@ -242,7 +242,7 @@ function replaceEmberObjectExpressions(j, root, filePath, options = {}) {
// one object from a file is transformed and other is not
if (transformed) {
const decoratorsToImport = Object.keys(decoratorsToImportMap).filter(
key => decoratorsToImportMap[key]
(key) => decoratorsToImportMap[key]
);
createDecoratorImportDeclarations(j, root, decoratorsToImport, options);
logger.info(`[${filePath}]: SUCCESS`);
Expand Down
16 changes: 8 additions & 8 deletions transforms/helpers/transform-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function withComments(to, from) {
* @returns {CommentLine[]}
*/
function createLineComments(j, lines = []) {
return lines.map(line => j.commentLine(line));
return lines.map((line) => j.commentLine(line));
}

/**
Expand All @@ -46,7 +46,7 @@ function createLineComments(j, lines = []) {
* @returns {ExpressionStatement[]}
*/
function instancePropsToExpressions(j, instanceProps) {
return instanceProps.map(instanceProp =>
return instanceProps.map((instanceProp) =>
withComments(
j.expressionStatement(
j.assignmentExpression(
Expand Down Expand Up @@ -93,7 +93,7 @@ function replaceSuperExpressions(j, methodDefinition, functionProp) {
if (!superExprs.length) {
return methodDefinition;
}
superExprs.forEach(superExpr => {
superExprs.forEach((superExpr) => {
if (replaceWithUndefined) {
j(superExpr).replaceWith(j.identifier('undefined'));
} else {
Expand Down Expand Up @@ -279,7 +279,7 @@ function createActionDecoratedProps(j, actionsProp) {
const actionProps = get(actionsProp, 'value.properties');
const overriddenActions = get(actionsProp, 'overriddenActions') || [];
const actionDecorators = createIdentifierDecorators(j);
return actionProps.map(actionProp => {
return actionProps.map((actionProp) => {
if (get(actionProp, 'value.type') === 'Identifier') {
return convertIdentifierActionToMethod(j, actionProp, actionDecorators);
} else {
Expand Down Expand Up @@ -318,7 +318,7 @@ function createCallExpressionProp(j, callExprProp) {
};
return [createMethodProp(j, functionExpr, createInstancePropDecorators(j, callExprProp))];
} else if (lastArgType === 'ObjectExpression') {
const callExprMethods = callExprLastArg.properties.map(callExprFunction => {
const callExprMethods = callExprLastArg.properties.map((callExprFunction) => {
callExprFunction.isComputed = true;
callExprFunction.kind = getPropName(callExprFunction);
callExprFunction.key = callExprProp.key;
Expand Down Expand Up @@ -382,7 +382,7 @@ function createClass(
classDecorators.push(j.decorator(j.identifier('classic')));
}

instanceProps.forEach(prop => {
instanceProps.forEach((prop) => {
if (prop.isClassDecorator) {
classDecorators.push(createClassDecorator(j, prop));
} else if (prop.type === 'FunctionExpression') {
Expand Down Expand Up @@ -428,8 +428,8 @@ function createImportDeclaration(j, specifiers, path) {
*/
function createEmberDecoratorSpecifiers(j, pathSpecifiers = [], decoratorsToImport = []) {
return pathSpecifiers
.filter(specifier => decoratorsToImport.includes(specifier))
.map(specifier => {
.filter((specifier) => decoratorsToImport.includes(specifier))
.map((specifier) => {
const importedSpecifier =
specifier === LAYOUT_DECORATOR_LOCAL_NAME ? LAYOUT_DECORATOR_NAME : specifier;
return j.importSpecifier(j.identifier(importedSpecifier), j.identifier(specifier));
Expand Down
11 changes: 3 additions & 8 deletions transforms/helpers/util/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ const LIFECYCLE_HOOKS = [
* @returns {Any}
*/
function get(obj, path) {
return path.split('.').reduce(function(currentObject, pathSegment) {
return path.split('.').reduce(function (currentObject, pathSegment) {
return typeof currentObject == 'undefined' || currentObject === null
? currentObject
: currentObject[pathSegment];
Expand All @@ -168,12 +168,7 @@ function get(obj, path) {
* @param {File} root
*/
function getFirstDeclaration(j, root) {
return j(
root
.find(j.Declaration)
.at(0)
.get()
);
return j(root.find(j.Declaration).at(0).get());
}

/**
Expand Down Expand Up @@ -217,7 +212,7 @@ function shouldSetValue(prop) {
return true;
}
return prop.decoratorNames.every(
decoratorName => decoratorName === 'className' || decoratorName === 'attribute'
(decoratorName) => decoratorName === 'className' || decoratorName === 'attribute'
);
}

Expand Down
Loading